12
$\begingroup$

I recently stumbled upon the Cycloid and was working on finding its length and such when I found this animation on Wikipedia.

Strikingly pretty and small in size too (66KB)

So on searching how he made that particular animation and others I stumbled upon this talk

What software edited the animations?

... None at all. I used MSVC++ to write a little program that calls some GDI+ functions and draws a multi-layer TIF picture each layer of which is a single frame (Only Math, C++ & some Windows API that are well-documented). ...

I went on searching libraries to program with but ultimately quit because it was too much of a bother.

Somewhile later I saw this and thank goodness the author used a software package (MuPAD). But the software costs a lot and is now part of MATLAB, and the size of the .gif was way too large.

Finally I've come back to Mathematica and want to know how to go about it.

Don't just tell me the code right away; give me some pointers, text, documentation, other questions, etc.

EDIT : Thank you people, here's my rendering (not exactly, because I used J.M.'s code)

$\endgroup$
4
  • $\begingroup$ Start with the documentation/examples for Manipulate and/or Animate. $\endgroup$
    – JohnD
    Jul 29, 2012 at 13:51
  • $\begingroup$ I'd suggest starting at demonstrations.wolfram.com. I haven't looked, but I'd bet at least 10 pence there would be a demonstration like this over there. $\endgroup$
    – cormullion
    Jul 29, 2012 at 14:04
  • 2
    $\begingroup$ This question appears to be overly broad. Perhaps it would be better for you to ask how to create the first animation in Mathematica and see what you can learn from the answers. Or, you could ask about the tools that one might use to animate a graphic (e.g. Animate). To simply ask about mathematical animations in general isn't really an answerable question. $\endgroup$
    – Mr.Wizard
    Jul 29, 2012 at 14:04
  • $\begingroup$ Related: blog.wolfram.com/2011/07/15/mathematica-qa-creating-movie-files $\endgroup$ Jul 29, 2012 at 15:35

2 Answers 2

16
$\begingroup$

I'll switch it up a bit: I'll give you somewhat simplified code, and your task is to figure out what I'm trying to do:

With[{frames = 15}, 
 Animate[
     ParametricPlot[{u - Sin[u], 1 - Cos[u]}, {u, -$MachineEpsilon, t},
                    Axes -> None,
                    Epilog -> {Line[{{t, 1}, {t - Sin[t], 1 - Cos[t]}}],
                              {AbsolutePointSize[3], Point[{t - Sin[t], 1 - Cos[t]}]}},
                    Frame -> True, PlotRange -> {{-1, 2 Pi + 1}, {0, 2}}, 
                    PlotStyle -> Directive[AbsoluteThickness[3], Red], 
                    Prolog -> Circle[{t, 1}, 1]],
         {t, 0, 2 Pi, 2 Pi/(frames - 1)}]]

You'll want to see Stan Wagon's treatment as well. Among other things, he gives a visual demonstration of where the cycloid's parametric equations come from:

rolling penny

$\endgroup$
1
  • $\begingroup$ dude you are amazing.....gosh this one example taught me Mathematica animation using some math I'd done earlier . Crazy $\endgroup$ Jul 29, 2012 at 14:48
17
$\begingroup$

Just the code:)

Animate[Show[
Graphics[Translate[Rotate[{Circle[], Thick, Blue, Line[{{0, 0}, {0, -1}}], Red, 
  PointSize[.02], Point[{0, -1}]}, -t], {t , 0}], 
PlotRange -> {{0, 4 Pi}, {-2, 2}}, ImageSize -> {Large, Tiny}, 
Axes -> {True, False}, AxesOrigin -> {0, -1}], 
ParametricPlot[{(a - Sin[a]), (-Cos[a])}, {a, 0, t}, 
PlotStyle -> Directive[Thick, Orange]]], {t, 0.001, 4 Pi}, 
AnimationRunning -> False]

enter image description here

enter image description here

$\endgroup$
1
  • 3
    $\begingroup$ If you want to export such an animation, instead of directly using Animate, define a function frame[t_] := Show[Graphics[...PlotStyle->Directive[Thick,Orange]]] with body as above. Create a table of snapshots: movie = ParallelTable[frame[t], {t, 0.001, 4 Pi, (4 Pi - 0.001)/100}];. Then export it to your favorite animated graphics format, e.g.: Export["rolling.mov", movie]. $\endgroup$
    – murray
    May 12, 2013 at 22:23

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.