7
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ maybe TetGenLink could help.. $\endgroup$ – halmir Mar 19 '13 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$ – whuber Mar 19 '13 at 22:59
11
$\begingroup$

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]

tetrahedralized cylinder

$\endgroup$
  • $\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$ – Tony Dong Mar 19 '13 at 21:32
8
$\begingroup$

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
 ]

Solid cylinder with triangular mesh

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