4
$\begingroup$

So I have A 2D Mesh Region, for example

MeshRegion[{{0, 0}, {3, 0}, {3, 3}, {0, 3}, {1, 1}, {2, 1}, {2, 2}, {1, 2}}, {Polygon[{1, 2, 5}], Polygon[{6, 2, 5}], Polygon[{6, 2, 7}], Polygon[{2, 7, 3}], Polygon[{3, 4, 7}], Polygon[{4, 7, 8}], Polygon[{4, 8, 5}], Polygon[{1, 4, 5}]}] 

and a point named point A Point[{0,0,5}]. Now what I want to do is to "pull" the 2D mesh towards the point, creating a 3D mesh area. Each point of the original 2D mesh is moved towards based on its distance to point A, with a fixed ratio, so that the new 3D object would look like this:

ect

with all the z coordinates of the original 2D mesh to be 0. But how? I found it really hard to create the new faces in this situation.

$\endgroup$

1 Answer 1

4
$\begingroup$

Finally, I found an application for the Prism primitive:

M = MeshRegion[{{0, 0}, {3, 0}, {3, 3}, {0, 3}, {1, 1}, {2, 1}, {2, 2}, {1, 2}}, {Polygon[{1, 2, 5}], Polygon[{6, 2, 5}], Polygon[{6, 2, 7}], Polygon[{2, 7, 3}], Polygon[{3, 4, 7}], Polygon[{4, 7, 8}], Polygon[{4, 8, 5}], Polygon[{1, 4, 5}]}]; p = {0, 0, 5}; x = MeshCoordinates[M]; n = Length[x]; x = Join[x, ConstantArray[0., {n, 1}], 2]; t = 0.5; y = t ConstantArray[p, n] + (1 - t) x; triangles = MeshCells[M, 2, "Multicells" -> True][[1, 1]]; prisms = Join[triangles, triangles + n, 2]; M1 = MeshRegion[Join[x, y], Prism[prisms]] 

enter image description here

So, this MeshRegion consists of Prisms. If you prefer a Tetrahedron-based mesh, just apply DiscretizeRegion to M1.

$\endgroup$
1
  • $\begingroup$ Wow! This is an amazing approach. The elegance of the prisms is beyond what I'd thought to be a solution. $\endgroup$ Commented Jan 14, 2019 at 8:38

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.