1

I have an arbitrary polygon, not necessarily convex, described by the coordinates of its vertices. I need to obtain the 3D Region R delimited by a prism with base defined by the polygon and a given height h (such as I can for example RegionPlot3D[R]). Polygon example

Graphics[
    Line[{{2, 0}, {-2, 0}, {-2, 1}, {-1.5, 1}, {-1.5, 0.5}, {1.5, 0.5},{1.5, 1}, {2, 1}, {2, 0}}]
]  
Kuba
  • 136,707
  • 13
  • 279
  • 740
jss
  • 405
  • 3
  • 8

1 Answers1

3

This is closely related to:

How to extrude a 3D image from a binary 2D image

and one of answers (J.M.) does exactly that:

poly = Polygon[{{2, 0}, {-2, 0}, {-2, 1}, {-1.5, 1}, {-1.5, 
    0.5}, {1.5, 0.5}, {1.5, 1}, {2, 1}, {2, 0}}];

With[{h = 2}, 
  region = RegionProduct[
      poly, MeshRegion[{{0}, {h}}, Line[{1, 2}]]
  ]
] // Show[#, Axes -> True] &

enter image description here

Volume@region
5.
Kuba
  • 136,707
  • 13
  • 279
  • 740