I have a system of differential equations (referred to as "s") and use NDSolve
to obtain the solution. I substitute the interpolated functions for the original functions in order to represent the trajectories of two objects in 3 dimensions. Here is the system that I am working with:
(I added this as an edit after I got some feedback that some more information about what I was attempting to animate would be useful )
sysstars = {((sx[t]^2 + sy[t]^2 + sz[t]^2)^(3/2))*(1 +
2*(mstar1/mstar2) + (mstar1/mstar2)^2)*sx''[t] ==
g*mstar2*(-sx[t]), ((sx[t]^2 + sy[t]^2 + sz[t]^2)^(3/2))*(1 +
2*(mstar1/mstar2) + (mstar1/mstar2)^2)*sy''[t] ==
g*mstar2*(-sy[t]), ((sx[t]^2 + sy[t]^2 + sz[t]^2)^(3/2))*(1 +
2*(mstar1/mstar2) + (mstar1/mstar2)^2)*sz''[t] ==
g*mstar2*(-sz[t]), sx[0] == tpostar1[[1]], sy[0] == tpostar1[[2]],
sz[0] == tpostar1[[3]], sx'[0] == v0com1[[1]],
sy'[0] == v0com1[[2]],
sz'[0] ==
v0com1[[3]], ((qx[t]^2 + qy[t]^2 + qz[t]^2)^(3/2))*(1 +
2*(mstar2/mstar1) + (mstar2/mstar1)^2)*qx''[t] ==
g*mstar1*(-qx[t]), ((qx[t]^2 + qy[t]^2 + qz[t]^2)^(3/2))*(1 +
2*(mstar2/mstar1) + (mstar2/mstar1)^2)*qy''[t] ==
g*mstar2*(-qy[t]), ((qx[t]^2 + qy[t]^2 + qz[t]^2)^(3/2))*(1 +
2*(mstar2/mstar1) + (mstar2/mstar1)^2)*qz''[t] ==
g*mstar2*(-qz[t]), qx[0] == tpostar2[[1]], qy[0] == tpostar2[[2]],
qz[0] == tpostar2[[3]], qx'[0] == v0com2[[1]],
qy'[0] == v0com2[[2]], qz'[0] == v0com2[[3]]}
s = NDSolve[
sysstars, {sx[t], sy[t], sz[t], qx[t], qy[t], qz[t]}, {t, 0,
8*10^7}, MaxSteps -> 10^8]
And here is how I am plotting them:
ParametricPlot3D[
Evaluate[{sx[t], sy[t], sz[t], qx[t], qy[t], qz[t]} /. s, {t, 0,
10^7}], PlotRange -> All]
ParametricPlot3D[
Evaluate[{qx[t] + comx[t], qy[t] + comy[t], qz[t] + comz[t],
sx[t] + comx[t], sy[t] + comy[t], sz[t] + comz[t]} /. s, {t, 0,
3*10^7}], PlotRange -> All,]
(The second Parametric Plot above is where the center of mass vector is added back to show the system from outside the center of mass inertial frame. So the first one plots two objects on initial trajectories that then go into orbit around the center of mass, with the center of mass treated as static)
The results of this are good - static lines in 3D, with the sensible paths. Now, I would like to animate this so that, say two spheres, move as a function of t. I have tried a few on-line suggestions using Manipulate[Show[...
, but without success so far. I believe that the difficulty may relate to the use of Evaluate inside ParametricPlot3D
- in conjunction with the animation techniques. It does not seem possible to get rid of Evaluate
with ParamatricPlot3D
, and still get ParametricPlot3D
to work with the interpolated functions which get substituted to generate the representation. There must be a way to do this in Mathematica - the program is way to good not to have a good way to do such an obvious thing with solutions, but I am stumped.
Suggestions greatly appreciated (after too many hours) !
Delphi
tpostar1
this code doesn't run. finally, it is probably more useful to put a minimal example of what you'd like to do rather than all the actual code you have. $\endgroup$