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'm trying to animate some curves that wrap around a cylinder. OK so far:

Animate[ParametricPlot3D[{{Cos[α t], Sin[α t], 
Sqrt[1 - α^2] t}, {Cos[α t], 
Sin[α t], -Sqrt[1 - α^2] t}}, {α, -1, 1}, 
PlotRange -> {{-1, 1}, {-1, 1}, {-2 π, 2 π}}], {t, 0, 
2 π}, AnimationRunning -> False]

But I'm struggling to incorporate the cylinder itself:

Graphics3D[Cylinder[{{0, 0, -2 π}, {0, 0, 2 π}}, 1]]

You can probably see the problem: the curves run around an invisible cylinder. I'd be much happier if I could see it! I've tried to squeeze the cylinder in in a few different ways (putting it into the Animate[ParametricPlot3D[...]] in different places, and using Epilog), but no luck. Any suggestions?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

I think the simplest way is to include a Show:

Animate[
  Show[
    ParametricPlot3D[{{Cos[α t], Sin[α t], 
      Sqrt[1 - α^2] t}, {Cos[α t], 
      Sin[α t], -Sqrt[1 - α^2] t}}, {α, -1, 1}, 
    PlotRange -> {{-1, 1}, {-1, 1}, {-2 π, 2 π}}], 

    Graphics3D[Cylinder[{{0, 0, -2 π}, {0, 0, 2 π}}, 1]]
  ], 
{t, 0, 2 π}, AnimationRunning -> False]

enter image description here

Show returns a graphics object that can be further customized in a similar way to ParametricPlot3D.

EDIT I really liked the animation, but think the Cylinder by default masks the function. Perhaps the following is easier to see:

Animate[
  Show[
    ParametricPlot3D[{{Cos[α t], Sin[α t], 
      Sqrt[1 - α^2] t}, {Cos[α t], 
      Sin[α t], -Sqrt[1 - α^2] t}}, {α, -1, 1}, 
      PlotRange -> {{-1, 1}, {-1, 1}, {-2 π, 2 π}}, 
      Axes -> False, BoxStyle -> Opacity[0]], 
    Graphics3D[{EdgeForm[None], Yellow, Opacity[0.2], 
      Cylinder[{{0, 0, -2 π}, {0, 0, 2 π}}, 1]}]
  ], 
{t, 0, 2 π}, AnimationRunning -> False]

enter image description here

share|improve this answer
    
Thanks, that does the trick nicely. Much appreciated. –  user12477 Mar 8 '12 at 16:20
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.