I'm trying to create a model of the solar system but I can't set the different revolution speeds of the planets. The not yet complete code that I wrote is this:

   Sphere[mrc[[a]], 0.0244], {Line[vns]}, Sphere[vns[[b]], 0.0605]}, 
  Boxed -> False, ImageSize -> Large, SphericalRegion -> True, 
  PlotRange -> All], {a, 1, 51, 1}, {b, 1, 51, 1}, 
 AnimationRate -> 10, AnimationRunning -> False]

But I can change the speed of the individual variables only through the on-screen controls. "mrc" and "vns" are the orbit paths of two planets taken directly as an entity by mathematica. But I don't know if I can write them here because it's a very long list of numbers.


1 Answer 1


I do not use animation rates. When I done something like this (can't run your code so made up something), I used the tick method and at each tick, each object's position is either updated or not depending on which is meant to be slow and which is fast.

Here is very simple example. In the following, there are 2 particles moving from left to right. If the speed multiplier is 2, then at each tick one moves and the other has to wait for the next tick.

If the speed multiplier is 3, the the slow particle has to wait each third tick to move and so on.

For example here is animation when speed multiplier is 2.

enter image description here

And this is when it is 5 (so one particle is 5 times as fast)

enter image description here

And this is when it is 10 (so one particle is 10 times as fast)

enter image description here

You can use this method for your animations. For example, if you solution is given from NDSolve, you loop over all the time range, and each time do the same.


 (*update x2 only when it is its time*)
 If[ Mod[n, speedMultiplier] == 0, x2 = x2 + 0.1];

 If[x1 > 10, x1 = 0];
 If[x2 > 10, x2 = 0];

 (*x1 is the fast one, it moves at each tick *)
 x1 = x1 + 0.1;

 If[state == "run", tick = Not[tick]];
 Graphics[{{Blue, Disk[{x1, 2}, 1]}, {Red, Disk[{x2, -2}, 1]}}, 
  PlotRange -> {{0, 10}, {-3, 3}}],

    Button["start", {state = "run", tick = Not[tick]}, ImageSize -> {50, 40}],
    Button["stop", {state = "stop", tick = Not[tick]}, ImageSize -> {50, 40}],
    Button["reset", {state = "pause", x1 = 0, x2 = 0, n=0, tick = Not[tick]}, 
     ImageSize -> {50, 40}]

 {{speedMultiplier, 2, "speed Multiplier"}, 1,10,1,Appearance -> "Labeled"},
 {{tick, False}, None},
 {{x1, 0}, None},
 {{x2, 0}, None},
 {{n, 0}, None},
 {{state, "stop"}, None},
 TrackedSymbols :> {tick, state}
  • $\begingroup$ Unfortunately, I would need something simpler because I am unable to create such a complicated code. The part of code that I posted doesn't work because I had omitted a part, now I have modified it should go $\endgroup$
    – Nunu00
    Commented Jul 2, 2020 at 14:41
  • $\begingroup$ @Nasser: How do actually capture that animation? $\endgroup$
    – Moo
    Commented Jul 2, 2020 at 15:02
  • 1
    $\begingroup$ @Moo you can use licecap, free program. just google it. it is screen capture and generates animated gif file. $\endgroup$
    – Nasser
    Commented Jul 2, 2020 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.