3

I am trying to plot a function with ParametricPlot3D with a specified plot range to export as an stl file, however when exporting the graphic mathematica ignores the PlotRange and exports the whole function, is there a way to make this work or some sort of intersection command to work around this? Mathematica Function

Resulting Export

Jason B.
  • 68,381
  • 3
  • 139
  • 286
Ian
  • 31
  • 1

3 Answers3

3

As pointed out by Ivan Sterling, you cannot simply restrict the PlotRange, as this will not be respected when exporting to "STL". Take Louis's example,

ParametricPlot3D[{(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u], 
   Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, 
  PlotRange -> {{0, π}, {0, π}, All}]
Export["test.stl", %] // Import

enter image description here

One method to make sure that you only get the plot you want is to restrict the parameter values, only plotting over the relevant values of u and v. But another option is to supply a RegionFunction

pp1 = ParametricPlot3D[{(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u], 
   Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, 
  RegionFunction -> 
   Function[{x, y, z, u, v}, 0 <= x <= π && 0 <= y <= π]]
Export["test.stl", %] // Import

enter image description here

Jason B.
  • 68,381
  • 3
  • 139
  • 286
0

Works as intended on 10.0 for Mac OS X x86 (64-bit) (December 4, 2014), see also STL (.stl)

pp1 = ParametricPlot3D[{(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u], 
Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}]

Export["MathematicaParametricSurface.stl", pp1]

enter image description here

enter image description here

pp1 = ParametricPlot3D[{(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u], 
Sin[v]}, {u, 0, 1 Pi}, {v, 0, 1 Pi}]

Export["MathematicaParametricSurface.stl", pp1]

enter image description here

enter image description here

Import["MathematicaParametricSurface.stl"]

enter image description here

0

Yes there is. Your problem is your looking at the "true points" not the adjusted points.

See Mathematica BoxRatios[{1,1,1}]. I think that will do it.

If it doesn't all I can say is see the following which will (can) do it. (you can adjust the rayshade.m if needed to suite the need of your renderer, by default rayshade` uses plain text scaling for BoxRatio - your renderer may or may not like that. it also contains ability that can be utilized (not automatically) to scale the actual points). That being said: you can just scale the points using Mathematica yourself BEFORE you export! It's easy just multiply all the vertex by a scaling vertex.

see:

https://sourceforge.net/projects/rayshade-math/

How to Render, raytrace, Export Graphics3D in Mathematica 11.0

john
  • 111
  • 4