This seemingly tame solid gives Mathematica (v9) a bit of a workout if you want to generate a good picture:

rinner[y_] = Sqrt[y];
router[y_] = 1;
RegionPlot3D[rinner[y]^2 <= x^2 + z^2 <= router[y]^2, 
  {x, -1, 1}, {z, -1, 1}, {y, 0, 1}, AxesLabel -> {x, y, z}, PlotPoints -> 100, 
  PlotStyle -> Opacity[.75], MeshFunctions -> {#3 &}, Mesh -> 5]

Mathematica graphics

I kept increasing PlotPoints from 100 to 200 to 300 and things get pretty slow---without much of an improvement in the rendering of the choppy part of the region at the top. Bumping up MaxRecursion and PerformanceGoal->"Quality" didn't seem to help.

I tried playing with variations like PlotPoints->{100,100,300} to get better results faster, and this leads to my two questions.

  1. What else should I try? (I experimented with RevolutionPlot3D, but I want solids.)
  2. Is it possible to tailor the placement of PlotPoints to a subset of either

    (a) an axis (say, 10x more points in the $z$ direction, but pack them into $0.9\le z\le 1$?, or

    (b) a specific portion of the overall space (say, $x,y,z$ with $0.9^2\le x^2+y^2\le 1^2$ and $0.9\le z\le 1$, etc.)?

Thanks for any insight.


If you want to stick with RegionPlot3D but don't want the jagged edges, then you can smooth them by excluding the creased line from the plot region:

rinner[y_] = Sqrt[y];
router[y_] = 1;
ε = .05;
RegionPlot3D[(rinner[y])^2 <= x^2 + z^2 <= (router[y])^2 && 
  router[y] - rinner[y] > ε, {x, -1, 1}, {z, -1, 1}, {y, 0, 
  1}, AxesLabel -> {x, y, z}, PlotPoints -> 100, 
 PlotStyle -> Opacity[.75], MeshFunctions -> {#3 &}, Mesh -> 5]


Edges are always rounded in RegionPlot3D anyway, so rounding them by hand as I did here with the parameter ε may be acceptable.

The small parameter ε determines how close the inner and outer walls are allowed to come - thus preventing them from touching. The choice of PlotPoints will determine how small you can make ε.

  • $\begingroup$ Very nice--and quick---result. Thanks. $\endgroup$ – JohnD Dec 16 '12 at 4:14

The big problem you have here is, that RegionPlot3D really tries to determine the inner of your object. On the top you have an extremely thin rim and RegionPlot3D would have to find the same rim high on a circular boundary. Too hard, at least for the standard settings.

You could try to plot only the contour of your object:

ContourPlot3D[ {router[y]^2 == x^2 + z^2 , rinner[y]^2 == x^2 + z^2},
   {x, -1, 1}, {z, -1, 1}, {y, 0, 1}, AxesLabel -> {x, y, z}, 
 PlotPoints -> 20, ContourStyle -> Opacity[0.75],
  MeshFunctions -> {#3 &}, Mesh -> 5]

Mathematica graphics

  • $\begingroup$ Well, now this is embarrassing... $\endgroup$ – JohnD Dec 16 '12 at 4:10
  • $\begingroup$ @halirutan: Should AxesLabel->{x,y,z} be changed to AxesLabel->{x,z,y} in this image? $\endgroup$ – David Nov 10 '14 at 17:19

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.