Return to Gravitorium Home Page
Return to Gravitorium Help

How Gravitorium Works

Gravitorium loads or creates a collection of bodies in memory. For each "tick" of the clock (the length of the tick is determined by the simulation speed), the program cycles through each body in the collection and works out the force on it from each other body's gravity.

These forces are determined by an equation worked out nearly 300 years ago by Isaac Newton:

...where F is the force, M1 and M2 are the masses of the first body and the second body respectively, r is the distance between the bodies, and G is a constant called the gravitational constant. In non-mathematical terms, it says that every body is gravitationally attracted by every other body, with a force which varies by an 'inverse-square' law. Simply put, the closer the bodies are, the stronger the force attracting them. Halve the distance, and the force quadruples.

These forces cause bodies to undergo acceleration (a change in velocity), following another one of Newton's formulas:

...where A is the acceleration in metres per second per second.

Gravitorium then adds up all of these accelerations (the accelerations may be in many different directions, so some accelerations cancel out others).

Once all of the accelerations have been worked out for all bodies, Gravitorium then goes through the collection again, and works out a new position and a new velocity for each body. Here's some more equations:

...where V2 is the new velocity, V1 is the old velocity, A is the acceleration we worked out above, and T is how long the acceleration is applied in seconds. In Gravitorium, T varies in length depending on your simulation speed (the shorter the T, the slower the simulation).

This change of velocity also involves a change of position of the body:

...where X2 is the new position, X1 is the original position, V is the velocity worked out above, and A and T are as before.

Every so often (by default, about every 6 simulated hours), the program plots a point on each of the displays.

That's about it! Amazingly enough, these simple repeated calculations are accurate enough to simulate the motion of heavenly bodies.