I need to plot triangular mesh on a cylinder. However the function Cylinder
doesn't have a Mesh
option. By using ParametricPlot3D[{Cos[phi], Sin[phi], z}, {phi, 0, 2 Pi}, {z, -4, 4}, Mesh -> All]
, it gives a hollow cylindrical surface with fine mesh. How can I get a "solid" cylinder with coarse triangular mesh?
$\begingroup$
$\endgroup$
2
-
1$\begingroup$ maybe TetGenLink could help.. $\endgroup$– halmirCommented Mar 19, 2013 at 20:03
-
1$\begingroup$ Are you attempting to triangulate the cylinder as a surface or as a solid (using 3-simplices rather than triangles)? $\endgroup$– whuberCommented Mar 19, 2013 at 22:59
Add a comment
|
2 Answers
$\begingroup$
$\endgroup$
1
I just followed examples in TetGenLink documentation:
Needs["TetGenLink`"]
data3D =
N@Flatten[Table[{r Cos[phi], r Sin[phi], z}, {phi, 0, 2 Pi, .5},
{z, -4, 4, .5}, {r, .2, 1, .4}], 2];
in = TetGenCreate[];
TetGenSetPoints[in, data3D];
out = TetGenTetrahedralize[in, ""];
coords = TetGenGetPoints[out];
meshElements = TetGenGetElements[out];
TetrahedraWireframe[i_] :=
Line[ Flatten[
i[[All, #]] & /@ {{1, 2}, {2, 3}, {3, 1}, {1, 4}, {2, 4}, {3, 4}}, 1]]
Graphics3D[GraphicsComplex[coords, TetrahedraWireframe[meshElements]],
Boxed -> False]
-
$\begingroup$ Thanks a lot, halmir. This is exactly what I want. Following you, I plot the surface with mesh by using
faces = TetGenGetFaces[out]; Graphics3D[GraphicsComplex[coords, Polygon[faces]], Boxed -> False]
. $\endgroup$ Commented Mar 19, 2013 at 21:32
$\begingroup$
$\endgroup$
You could put caps on your cylinder and control the mesh with PlotPoints
and MaxRecursion
:
Show[
ParametricPlot3D[{r Cos[phi], r Sin[phi], 4}, {phi, 0, 2 Pi}, {r, 0, 1},
Mesh -> All, PlotPoints -> {25, 4}, MaxRecursion -> 0],
ParametricPlot3D[{r Cos[phi], r Sin[phi], -4}, {phi, 0, 2 Pi}, {r, 0, 1},
Mesh -> All, PlotPoints -> {25, 4}, MaxRecursion -> 0],
ParametricPlot3D[{Cos[phi], Sin[phi], z}, {phi, 0, 2 Pi}, {z, -4, 4},
Mesh -> All, PlotPoints -> {25, 13}, MaxRecursion -> 0],
PlotRange -> All, Boxed -> False, Axes -> False
]