Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
1  
maybe TetGenLink could help.. –  halmir Mar 19 '13 at 20:03
1  
Are you attempting to triangulate the cylinder as a surface or as a solid (using 3-simplices rather than triangles)? –  whuber Mar 19 '13 at 22:59
add comment

2 Answers 2

up vote 11 down vote accepted

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

share|improve this answer
    
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]. –  Tony Dong Mar 19 '13 at 21:32
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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