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 want to demonstrate generating a solid of revolution by revolving a planar region about, say, a horizontal axis. However, RevolutionPlot3D doesn't seem to have an option for revolving a curve about something other than the $z$ axis. I'm curious how you all would handle this.

Here's a simple example:

theta0 = Pi;
Manipulate[
  GraphicsRow[{
    Plot[x^2, {x, 0, 1}, PlotStyle -> {Thick, Black}, Filling -> Axis],
    Rotate[RevolutionPlot3D[Sqrt[x], {x, 0, 1}, {t, theta0 - .001, T},
    PlotRange -> {{-1, 1}, {-1, 1}, {0, 1}}, BoxRatios -> 1, 
    Boxed -> False, Axes -> False, ViewPoint -> {0, -2, 1}], -Pi/2]
  }],
{T, theta0, theta0 + 2 Pi}]

enter image description here

My questions:

  1. Is there a "better" way to showcase revolving about a horizontal axis of revolution than what I've done with Rotate?

  2. Is it possible to generate the higher quality, finished surface of revolution while the slider bar is moving instead of only when the slider is released?

  3. How do I prevent the vertical tick labels on the far left edge as well as the graphic on the far right edge from being clipped? (I tried Spacings and ImagePadding.)

  4. How do I vertically align the horizontal axis of revolution of the right graphic with the horizontal axis of the left graphic?

Edit: I had a follow up question but I will spin that off as a separate question.

share|improve this question

3 Answers 3

up vote 16 down vote accepted

Answers:

  1. RevolutionAxis, set to either "X" or {1,0,0}. (This also required adjustments to the PlotRange and ViewPoint options.)
  2. PerformanceGoal -> "Quality"
  3. I switched from GraphicsRow to Row, which I like much better. (I then also set ImageSize -> Small to make the plots a bit bigger than they'd naturally be in Row.)
  4. I was able to align the plots pretty well by setting BaselinePosition for each of the plots.

I also turned off the Mesh since I felt it was distracting, especially at the beginning of the sequence.

theta0 = Pi;
Manipulate[Row[{
   Plot[x^2, {x, 0, 1}, PlotStyle -> {Thick, Black}, 
       Filling -> Axis, BaselinePosition -> Axis, ImageSize -> Small], 
   RevolutionPlot3D[x^2, {x, 0, 1}, {t, theta0 - .001, T}, 
       PlotRange -> {{0, 1}, {-1, 1}, {-1, 1}}, BoxRatios -> 1, 
       Boxed -> False, Axes -> False, ViewPoint -> {1, -2, 0}, 
       Mesh -> None, RevolutionAxis -> "X", PerformanceGoal -> "Quality",
       BaselinePosition -> Center, ImageSize -> Small]
   }], {T, theta0, theta0 + 2 Pi}]

enter image description here

share|improve this answer
    
Wow, I don't know how I missed the RevolutionAxis option. As for #3, is there an explicit parameter which controls the amount of white space surrounding the outside edge of the graphics (but inside the Manipulate frame)? –  JohnD Jul 19 '12 at 0:40
    
ImagePadding should do that. –  Brett Champion Jul 19 '12 at 0:44

If you really would like to show volume, then an alternative simple approach is to use RegionPlot3D, which is easy to specify in cylindrical coordinates and then come back to Cartesian. We need some clever trick though to improve Arg function's limited domain, because this Demo stops at Pi/2:

Manipulate[

 Show[ParametricPlot3D[{u, 0, u^2}, {u, 0, 1}, 
   PlotStyle -> Directive[Red, Thick]],

  RegionPlot3D[Arg[z + I y] < T && 0 < Sqrt[y^2 + z^2] < x^2 && 0 < x < 10, {x, 0,
     1}, {y, 0, 1}, {z, 0, 1}, Mesh -> None, 
   PlotStyle -> Directive[Yellow, Opacity[0.5]], PlotPoints -> 25]

  , PlotRange -> {{0, 1}, {-1, 1}, {-1, 1}}, Axes -> True, 
  AxesOrigin -> {0, 0, 0}, Boxed -> False, SphericalRegion -> True, 
  ViewAngle -> .3]

 , {{T, 0, "rotation angle"}, 0, 2 Pi, Appearance -> "Labeled"}]

enter image description here

Other fancy things you could do are below. Which axes to rotate about is relative. You can do many things to beautify your plot. Is it something like that you need? Note you can rotate the plot freely - so axis point in directions you want. Take a look at some Demonstrations and their code here to learn other techniques.

Manipulate[

 Show[

  ParametricPlot3D[{u^2, 0, u}, {u, 0, 1}, 
   PlotStyle -> Directive[Red, Thick]],

  RevolutionPlot3D[Sqrt[x], {x, 0, 1}, {t, 0, T}, 
   PlotStyle -> {Opacity[.5], Specularity[White, 10]}, 
   ColorFunction -> "Rainbow", MeshStyle -> Opacity[.3], 
   MeshShading -> ms, PlotPoints -> 30]

  , Axes -> True, Boxed -> False, BoxRatios -> {1, 1, 1.5}, 
  AxesOrigin -> {0, 0, 0}, PlotRange -> {{-1, 1}, {-1, 1}, {0, 1}}, 
  ViewPoint -> {1.1, 2.6, 1.73}, ViewVertical -> {1.4, 0.3, 0.2}, 
  SphericalRegion -> True, ViewAngle -> .4, ImageSize -> 600, 
  AxesStyle -> Directive[Black, Thick]]

 , {{ms, None, 
   "shades"}, {None -> "NO", {{Red, Yellow}, {Pink, Orange}} -> "YES"}}
 , {{T, 2 Pi}, .001, 2 Pi, Appearance -> "Labeled"}, 
 FrameMargins -> 0]

enter image description here

enter image description here

share|improve this answer
    
Maybe "accomplish" would have been a better word than "showcase" in Question #1. I don't necessarily want anything fancy, like coloring options, etc. I just want to rotate about a horizontal axis with code that is simple for students. –  JohnD Jul 18 '12 at 21:36

For completeness: one can always fall back on using the definition of a surface of revolution if you are not satisfied with how Mathematica is rotating your curve. (I assume that your starting curves are embedded in the $x$-$z$ coordinate plane.) Either of

With[{axis = {1, 0, 0}},
     ParametricPlot3D[RotationMatrix[θ, axis].{x, 0, x^2} // Evaluate,
                      {x, 0, 1}, {θ, 0, 2 π}, Axes -> None, Boxed -> False,
                      ViewPoint -> {3, -2, 1}]]

or

With[{axis = {1, 0, 0}},
     ParametricPlot3D[RotationTransform[θ, axis][{x, 0, x^2}] // Evaluate,
                      {x, 0, 1}, {θ, 0, 2 π}, Axes -> None, Boxed -> False,
                      ViewPoint -> {3, -2, 1}]]

work nicely:

some surface of revolution

If you need to rotate with respect to some axis not passing through the origin, the code I gave is easily modified:

With[{origin = {3, 1, 0}, axis = {1, 0, 1}},
     ParametricPlot3D[RotationTransform[θ, axis, origin][{Cos[t], 0, Sin[t]}] // Evaluate,
                      {t, π, 2 π}, {θ, 0, 2 π}, Axes -> None, Boxed -> False,
                      ViewPoint -> {3, -2, 1}]]

some torus

Note that in this example, I rotated a general parametric curve as opposed to a function.

share|improve this answer
    
That is very helpful, thanks. –  JohnD Jul 20 '12 at 3:19

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.