Question: how to animate a plot for a space probe

Hello everyone,

I am a studen and have an astrophysics class where I programmed a basic space probe to go from a planet A to a Planet B.

I have a 2D grap and a 3D graph already done however I would like to animate them.

I have included both a picture and my whole program. Also see some code below. 

Thanks to all.

 

Download SondeII_(1).mwSondeII_(1).mwSondeII_(1).mw

restart:

with(linalg):
with(DEtools):

#Sonde
Position := [x(t), y(t)]:

#Terre
omega1 :=2*Pi:
r1 := [cos(omega1*t), sin(omega1*t)]:
x1(t) := innerprod([1, 0], r1):
y1(t) := innerprod([0, 1], r1):

#Mars
omega2 := sqrt(2)*Pi/2:
phi2 := Pi/2:
r2 := [2*cos(omega2*t + phi2), 2*sin(omega2*t+ phi2)]:
x2(t):= innerprod([1, 0], r2):
y2(t):= innerprod([0, 1], r2):

#Les couplages gravitationnelles (masse).
c1 := 1.0:
c2 := 0.2:
c0 := 100:

#Les forces appliqués sur la sonde
ForceGravitationnelle1 := -c1*(Position-r1)/(sqrt((x(t)-x1(t))^2+(y(t)-y1(t))^2))^3:
ForceGravitationnelle2 := -c2*(Position-r2)/(sqrt((x(t)-x2(t))^2+(y(t)-y2(t))^2))^3:
ForceGravitationnelle0 := -c0*(Position)/(sqrt((x(t))^2+(y(t))^2))^3:

#La somme des forces.
Force := ForceGravitationnelle1 + ForceGravitationnelle2 + ForceGravitationnelle0:

Fx := innerprod([1, 0], Force):
Fy := innerprod([0, 1], Force):

#L'interval de temps.
TempsInit := 0:
TempsFinal := 3:

#Les équations différentielles de deuxieme ordre.
eq1x := (D(D(x)))(t) = Fx:
eq1y := (D(D(y)))(t) = Fy:

#Les conditions initiales..
phi0 :=(Pi)/2:
V0 := 12.946802:
x0 := 1:
y0 := 0.1:
Vx0 := V0*cos(phi0):
Vy0 := V0*sin(phi0):

ConditionsInit := x(0) = x0, y(0) = y0, D(x)(0) = Vx0, D(y)(0) = Vy0:

#La trajectoire de la sonde.
Trajectoire := dsolve({eq1x, eq1y, ConditionsInit}, {x(t), y(t)}, numeric, range = TempsInit..TempsFinal, maxfun=0):

#Tracage du graphique de la trajectoire en 2D
plots[odeplot](Trajectoire, [[0,0],[x1(t),y1(t)],[x2(t), y2(t)], [x(t), y(t)]],
TempsInit..TempsFinal, numpoints = 1000, axes = boxed, scaling = constrained, thickness = [2],
color = ["Black", "Green", "Blue", "Red"],
labels = ["X (L)", "Y (L)"],
labelfont = ["Times", 14], title = "Mouvement de la sonde dans le plan",
titlefont = ["Helvetica", 14], style=[point,line,line,line], symbol = solidcircle);

#Tracage du graphique en 3D:
plots[odeplot](Trajectoire, [[0,0,t],[x1(t),y1(t), t],[x2(t), y2(t), t], [x(t), y(t), t]],
TempsInit..TempsFinal, numpoints = 1000, axes = boxed, scaling = constrained, thickness = [3],
color = ["Black", "Green", "Blue", "Red"],
labels = ["X (L)", "Y (L)", "t"],
labelfont = ["Times", 14], title = "Mouvement de la sonde dans le plan",
titlefont = ["Helvetica", 14], style=[point,line,line,line], symbol = solidcircle);
 

 

 

 

 

 


 

Please Wait...