Animating a moving circle
By Nasser M. Abbasi, oct
10,2009
I saw nice animation of a moving circle and cycloid written by amca01 on the web. It was implemented in sage.
Here is the sage implementation by amca01 and below it is the Mathematica implementation I wrote of the same idea as the above. I also include Mathematica animated gif file.
Sage code:
step = 0.3
v = []
for t in srange(0,2*pi,step):
v.append(circle((t,1),1))
a = animate(v, xmin=-1, ymin=0, xmax=8,
ymax=2, figsize=[9,2])
w = []
for t in srange(0,2*pi,step):
w.append(point((t-sin(t),1-cos(t)),pointsize=20))
b = animate(w, xmin=-1, ymin=0, xmax=8,
ymax=2, figsize=[9,2])
L = Graphics()
x = []
for t in srange(0,2*pi,step):
L
+= line([(t-step-sin(t-step),1-cos(t-step)),(t-sin(t),1-cos(t))],
rgbcolor=(1,0,0), thickness=2)
x.append(L)
c = animate(x, xmin=-1, ymin=0, xmax=8,
ymax=2, figsize=[9,2])
(a+b+c).show()
Here is the Mathematica code
r
= 1; step = 0.1;
backgroundAxes
= Plot[0, {x, -Pi, 3*Pi},
PlotRange ->
{Automatic, {-r/2, 2*r + 0.5}},
AspectRatio ->
Automatic];
Animate[Show[{backgroundAxes,
ListPlot[Table[{x - Sin[x], 1 -
Cos[x]}, {x, 0, t, step}],
Joined -> True],
Graphics[{PointSize[Large], Red,
Point[{t - Sin[t], 1 - Cos[t]}]}],
Graphics[Circle[{t, 1}, r]]}],{t, 0,
2*Pi, step}, AnimationRate -> 5
]
Here is the GIF animation from the Mathematica code
Here is the Mathematica notebook