# Animate particle's trajectory

Does anyone know how to animate the trajectory of a particle, but make sure before the particle reaching a certain spot, there's nothing. I mean I want to make an animation that look like https://en.wikipedia.org/wiki/Lunar_precession#/media/File:Animation_of_Moon_orbit_around_Earth_-_Polar_view.gif

What I don't want is plotting the parametric plot first and add a moving particle along the line, such as Animating a parametric plot. Because I do not have 50 reputations yet, I cannot ask and comment on this link. So I copy the code below, and see if someone can give me suggestion how to make modification.

Thank you very much for reading my question.

r = 2; l = 6; m = 9; g = -9.81; t0 = 0; tf = 6.67;

x[t_] = (l - r θ[t]) Cos[θ[t]] + r Sin[θ[t]];
y[t_] = r Cos[θ[t]] - (l - r θ[t]) Sin[θ[t]];

kE = (1/2) m ((x'[t])^2 + (y'[t])^2);
pE = m g (r Cos[θ[t]] - (l - r θ[t]) Sin[θ[t]]);
lagrangian = kE - pE;
eL[t_] = (D[lagrangian, θ[t]] - D[D[lagrangian, θ'[t]], t]) //FullSimplify;

soln = NDSolve[{eL[t] == 0, θ == 0, θ' == 0}, θ, {t, t0, tf}];

Animate[ParametricPlot[{(l - r θ) Cos[θ] + r Sin[θ], r Cos[θ] - (l - r θ) Sin[θ]}, {θ, 0, -20}, Epilog -> {PointSize -> 0.015, Evaluate[Point[{(l - r θ[t]) Cos[θ[t]] + r Sin[θ[t]],r Cos[θ[t]] - (l - r θ[t]) Sin[θ[t]]}] /. soln[]]}], {t, t0, tf}]


r = 2; l = 6; m = 9; g = -9.81; t0 = 0; tf = 6.67;

x[t_] = (l - r θ[t]) Cos[θ[t]] + r Sin[θ[t]];
y[t_] = r Cos[θ[t]] - (l - r θ[t]) Sin[θ[t]];

kE = (1/2) m ((x'[t])^2 + (y'[t])^2);
pE = m g (r Cos[θ[t]] - (l - r θ[t]) Sin[θ[t]]);
lagrangian = kE - pE;
eL[t_] = (D[lagrangian, θ[t]] - D[D[lagrangian, θ'[t]], t]) // FullSimplify;

soln = NDSolve[{eL[t] == 0, θ == 0, θ' == 0}, θ, {t, t0, tf}];

ListAnimate[
Table[Graphics[{Blue, Rectangle[{-l*2, 0}, {l*1.2, l*2}], Yellow,
Line[Table[{x[t], y[t]} /. soln, {t, 0, tn, .01*tn}]],
PointSize[Large], Red, Point[{x[tn], y[tn]} /. soln]}], {tn, 0.1,
tf, .01*tf}]] To draw a trajectory with a thick solid line, use the code

ListAnimate[
Table[Graphics[{Blue, Rectangle[{-l*2, 0}, {l*1.2, l*2}], Yellow,
Thick, Line[
Flatten[Table[{x[t], y[t]} /. soln, {t, 0, tn, .01*tn}], 1]],
PointSize[Large], Red, Point[{x[tn], y[tn]} /. soln]}], {tn, 0.1,
tf, .01*tf}]] • Is it possible to show the trajectory with lines instead of ListAnimate? – consideration Feb 3 at 23:43
• Everything is possible. Explain what you want? – Alex Trounev Feb 4 at 0:17
• Thank you for reply. I want smooth line following the particle's motion instead of discrete dots. – consideration Feb 4 at 0:41
• @YunlinZeng See update. – Alex Trounev Feb 4 at 22:45