1
$\begingroup$

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}}]
]  
$\endgroup$
3
$\begingroup$

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.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.