4
$\begingroup$

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?

$\endgroup$

1 Answer 1

6
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Thanks, that does the trick nicely. Much appreciated. $\endgroup$
    – user12477
    Commented Mar 8, 2012 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.