Message Boards Message Boards

Reducing number of triangles in ParametricPlot3D STL file?

Posted 8 years ago
r = 7;
R = 19;     
ParametricPlot3D[{
               {(u^Cos[(r t)/R]) Cos[t], (u^Cos[(r t)/R]) Sin[t], (-Log[u] Sin[(r t)/R])}
               }, {t, 0, 2 R  Pi}, {u, 1, E}, MaxRecursion -> 0, Mesh-> All, PlotPoints -> 300, PlotStyle -> Thickness[0.02]]

enter image description here

The rendered object has far too many triangles. And to get a good rendering, PlotPoints must be much higher than 300, which will in turn create even more extra triangles. I'm exporting the part as an .stl for 3d printing. I prefer to solve this issue at the rendering and export stage, rather than reducing the number of triangles afterwards. I've looked into Mesh and MeshFunctions options, with no luck so far. Thanks in advance!

POSTED BY: Bryan Lettner
5 Replies

Also use PlotTheme -> “ThickSurface” for a better visualization:

r=7;R=19;
ParametricPlot3D[{
    {(u^Cos[(r t)/R]) Cos[t],(u^Cos[(r t)/R]) Sin[t],(-Log[u] Sin[(r t)/R])}},
    {t,0,2 R Pi},{u,1,E},
    PlotPoints->500,
    PlotTheme->"ThickSurface"]

enter image description here

POSTED BY: Vitaliy Kaurov
Posted 8 years ago

You can choose to sample many points as t varies and few points as u varies. Choosing PlotPoints -> {2000, 3} gives good detail:

r = 7; R = 19;
ParametricPlot3D[{{(u^Cos[(r t)/R]) Cos[t], (u^Cos[(r t)/R]) Sin[t], (-Log[u] Sin[(r t)/R])}}, 
  {t, 0, 2 R Pi}, {u, 1, E}, MaxRecursion -> 0, Mesh -> All, PlotPoints -> {2000, 3}, PlotStyle -> Thickness[0.02]]

enter image description here

There are roughly 24000 triangles in this plot:

MeshCellCount[DiscretizeGraphics[%]]
(* {12000, 35994, 23996} *)
POSTED BY: Greg Hurst
Posted 8 years ago

This solves the issue 100%! Thank you so much.

POSTED BY: Bryan Lettner

So you want high plotpoints but low triangles? Isn't that a contradiction?

POSTED BY: Sander Huisman
Posted 8 years ago

I don't think it is a contradiction. PlotPoints determines how many sample points to use to generate the plot, not how finely to divide up the mesh. In the above plot, we have redundant triangles. It can be reduced from 359,996 triangles to <50,000 without losing any detail:

enter image description here

reduces to

enter image description here

My issue is that the plot renders too precisely for how accurate it is. It is an overly precise depiction of a not-very accurate plot.

enter image description here vs. enter image description here

Of course we can get the more accurate plot by increasing PlotPoints, but it still gives an overly precise plot (far more triangles than necessary). This results in long computation times and huge files that are too big to open with my mesh manipulation software. I hope this clarifies.

Attachments:
POSTED BY: Bryan Lettner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract