Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to make an animation showing how we wrap a rectangle to form a cylinder (by joining a pair of parallel sides).

Here's my first pass:

    t {Cos[theta], Sin[theta], rho} + (1 - t) {rho, -1, theta}, 
    {theta, -Pi, Pi}, {rho, 0, 2}, 
    PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}, {-1.5, 1.5}}, 
    PerformanceGoal -> "Quality", ViewPoint -> {-2.3, 0.77, -2}, 
    ViewVertical -> {-0.08, 1, -0.06}], 
 {t, 0, 1}]

I'd much prefer the simpler looking transformation (without the twists this animation shows) which we'd do by simply rotating the pair of parallel sides until they touch to form the cylinder.

share|improve this question
Copy and paste code from your post to mma - nothing shows up. – Vitaliy Kaurov Nov 18 '12 at 5:41
Weird. It shows up for me. I re-pasted it just in case. Let me know if it works now. – JohnD Nov 18 '12 at 5:55
Something for you to start with: With[{t = Pi/2}, ParametricPlot3D[{Piecewise[{{Cos[u], t <= u}}, Cos[t] + u Sin[t]], Piecewise[{{Sin[t] - u Cos[t], t > u}}, Sin[u]], z}, {u, 0, 2 Pi}, {z, -1, 1}, Exclusions -> None]] – J. M. Nov 18 '12 at 6:00
up vote 12 down vote accepted

Think of this as of a flexible strip of fixed length glued to the side of a cylinder with shrinking radius. If radius >> strip length, strip looks almost flat. Making radius smaller will curve the strip more and more until its ends meet.

 ParametricPlot3D[{Sin[t]/a, Cos[t]/a, u}, {t, 0, a}, {u, 0, .5}, 
  Boxed -> False, Axes -> False, PerformanceGoal -> "Quality", 
  ImageSize -> {300, 300}, MeshStyle -> Opacity[.3], 
  PlotStyle ->  Directive[Opacity[0.7], Orange, Specularity[White, 50]], 
  ViewPoint -> {-2, 2, -2}, BoundaryStyle -> Directive[Black, Opacity[.3]]], 
{{a, .01, "wrap"}, 0.01, 2 Pi}]

enter image description here

share|improve this answer
Very nice. I tweaked yours to get more of the behavior that I am after (where both ends curl up towards one another): Manipulate[ParametricPlot3D[{Sin[t]/a, Cos[t]/a, u}, {t,-a, a}, {u, 0, .5}, Boxed -> False, Axes -> False, PerformanceGoal -> "Quality", ImageSize -> {300, 300}, MeshStyle -> Opacity[.3], PlotStyle -> Directive[Opacity[0.5], Blue, Specularity[White, 50]], BoundaryStyle -> Directive[Black, Opacity[.3]]], {{a, .01, "wrap"}, 0.01, Pi}] which is great except that this parametrization results in nonconstant height of the rectangle. – JohnD Nov 18 '12 at 13:46
@texasAUtiger Thanks. The height of the cylinder is constant as set by fixed range {u, 0, .5} . The "height increase" that you see is a perspective illusion that can be improved in your case, for example, with BoxRatios -> {Automatic, Automatic, 2} . – Vitaliy Kaurov Nov 18 '12 at 17:16
Ah yes. Yes thank you. – JohnD Nov 18 '12 at 19:24

Your Answer


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.