I have been trying to make a simple animation of planetary motion, but I can't seem to get it to work. I'm still new to this program so I am not sure how to make it work. Can anyone help?
Here is my code,
Clear["Global`*"]
G = 1;
m1 = 1;
m2 = 1;
T = 10;
r[t_] := Sqrt[x[t]^2 + y[t]^2];
eqns = {x''[t] == -((G m2)/(r[t]^3) ) x[t], x'[0] == 0, x[0] == 1,
y''[t] == -((G m2)/(r[t]^3) ) y[t], y'[0] == 0.5, y[0] == 0}
{x, y} = NDSolveValue[eqns, {x, y}, {t, 0, T}]
Animate[ParametricPlot[{x[t], y[t]}, {t, 0, T},
PlotRange -> {{-3, 3}, {-3, 3}}, PlotStyle -> {Red, Thick}], {t, 0,
1}]
Animate[..., {t, 0, 1}]
, in part becauset
is local toParametricPlot
there. I'm not quite sure what output you want, becauseParametricPlot
ranges over allt
already...do you maybe want to varyT
instead? orShow
a point moving on top of theParametricPlot
? $\endgroup$