Gravity and how the Heliocentric Model works

Wednesday, September 5, 2018 - 01:30 | Author: wabis | Topics: Knowlegde, Space, Physic, Interactive, Simulation | Comments(2)
In the coordinate system of the sun, the moon tracks a weird path, sometimes speeding up, sometimes slowing down. At the nearer side to the sun the moon gets attracted more by the sun than at the further side. The sun is much bigger than the earth and its attracting force is bigger than that of the earth. So why is it that the moon does not left earth's orbit and crash into the sun? I give the detailed explanation in this article, which includes an interactive simulation.

Simulation of the Solar System

The model is a scaled down numerical simulation of 3 bodies (sun, earth, moon), obeying only Newton's law of universal gravitation and Newton's laws of motion. The simulation shows, that stable orbits can exist in the Heliocentric Model. You can change parameters of the simulated solar system and disable some forces to study the consequences.

Restart Stop Moon-Sun off Earth-Sun off Sun off Reset

Parameters and Buttons

The big gray circle around the earth is the Hill Sphere. It defines the range where stable orbits around the earth are possible. As long as the moon orbits within the light gray circle with the thick border, the orbit is stable. Outside this circle the orbit is instable and the moon may be lost in space or captured by the sun.

The other cicles show the initial orbits of earth and moon. You can disable all circles by disabling Show Orbits Checkbox.

Restart Button
Restart the simulation with the current parameters.
Stop/Continue Button
Stops the simulation or continues the simulation without changing anything. You may also click into the graphic to stop or continue the simulation.
Moon-Sun off/on Button
switches the force between moon and sun on or off. If you switch off the force the moon is only held by earth's gravity. This results commonly in loosing the moon and changing the orbit of the earth.
Earth-Sun off/on Button
switches the force between earth and sun on or off. If you swich off the force, the earth flies away from the sun. The moon tries to follow, sometime crashing into the earth, sometimes breaking free from the earth and entering an orbit around the sun.
Sun off Button
switches the sun off or on. If the sun is switched off, earth and moon fly away tangentially. The moon keeps its orbit around the earth.
Reset Button
Sets all parameters to their default values.
Time Slider
slows down or speeds up the simulation. If you choose a to high value, depending on your computer power, the simulation may not be able to keep up the frame rate and loose some frames. The precision of the simulation is not affected by that. Note: the Time slider snaps to the value 1 if you come close to it.
Arrows Slider
scales the force or acceleration arrows. Note, the lengths of the arrows are not proportional to the force/acceleration magnitudes. The forces are scaled by a function x1/3 and the accelerations are scaled by x in addition to the slider value to make them more even in length, because their magnitude differs very much. But if an arrow's length is longer than another, it's force/acceleration is stronger than the other. You can choose ArrorType = off to hide the arrows.
CoordSys Selection
chooses a coordinate system which gets centered in the display. The Galaxy coordinate system will not be centered in the display but rather the display follows the center of the solar system with the grid fixed to the Galaxy system.
Note: the trails are always drawn relative to the choosen coordinate system. They show how the objects appear to move as seen from an observer in that system.
Show Selection
turns on/off some items on the screen.
Orbits shows the initial orbits of earth and moon. The orbits can change over time, but the shown orbit cirles keep their size and position as a reference.
CM shows the center of masses between Earth and Moon (black cross), sun and earth (blue cross) and from the whole solar system (red crosshair).
Speeds displays the speeds of the bodies relative to a chooses coordinate system. The choosen system is stated above the speeds.
ArrowType Selection
chooses wheter the force or acceleration vectors are displayed.
Arrow Selection
Single shows the singe components of the forces or accelerations due to each other body.
Sum shows the effective sum of the forces or accelerations which controls the bodies movements.
All shows the sum and the individual components together. Note: the green force vectors and the red acceleration vectors are the vectorial sum of the individual vectors.
DSunEarth, DEarthMoon Field
Distance between the 2 bodies in pixels. The distances together with the orbital periods determine the masses and sizes of the bodies, see How the Simulations works.
TEarth, TMoon Field
Orbital period in seconds. If the period of the moon is in the same magnitude as the period of the sun, the moon can be ejected into space, because the gravity of the earth gets too low to hold it.
Note: The mass and hence the gravitational attraction is calculated from the distances D and periods T, see How the Simulations works. Some combinations result in too low mass for the earth to hold the moon.
CMEarthMoon Field
Location of the common Center of Mass (CM) between earth and moon in % of the distance between earth and moon as measured from the earth. This value determines the masses of earth and moon. The CM for the real earth-moon system is at about 1%.

Simulation or Animation?

The App on this page is a Simulation, not an Animation. An animation is a predetermined programmed sequence of movements, following explicit steps or certain formulas that describe the motions.

A simulation is not predetermined. It follows physical laws. The motions are generally not predictable in detail and depend on start conditions and interactions with the user.

This simulation uses Newton's laws of universal gravitation and the laws of motion. The shown trajectories and orbits are the result of this natural laws, implemented in a computer program. The simulations shows what would happen in reality given the same parameters.

 See How the Simulations works

So if this simulation can produce stable orbits obeying Newton's laws, then such orbits are possible in reality too.

Role of the Observer

From an observer stationary with respect to the sun we can see that the moon traces a weird epicyclic path: Sometimes he is taking over the earth on the far side of the sun, gets nearer to the sun, seems to come to a halt and the suddenly gets accelerated to catch up with the earth again:

Moons epicycles as seen by an observer stationary with respect to the sun

Show Simulation of Moon's Epicycles

Even weirder is the corkscrew path of earth and moon as seen from an observer stationary with respect to the galaxy:

Corkscrew path of earth and moon as seen from an observer in rest with respect to the galaxy

Show Simulation of Corkscrew Path

How is it possible that the apparent path of the bodies depend on the observer? How is it possible, that the orbits are stable despite the observation that they trace weird paths depending on the observer?

To answer this question, ask yourself the following: How does an observer influence the motion (positions and velocities) of objects which he does not affect by exerting a force on them, only by looking at them?

The answer is: The motions of observed objects are not affected by a pure observer at all. The traces of moving objects are illusions caused by the relative motion of the observer with respect to the observed objects. The traces are only pictures emerging from plotting past relative positions of objects in the coordinate system of the observer. So each observer sees their own traces, but no observer has any influence on positions, velocities or any other physical properties of the objects, as described in Relativity of Positions and Velocities.

How do Orbits work?

To get a deeper inside into orbital mechanics, we need to understand some basic properties of the universe and their implications on motion in general and on orbits in particular. Here I start with a rough description of how orbits work. Read Basic Properties of the Universe to get a deeper understanding.

Gravity, Inertia, Conservation of Energy and tangential velocity are the ingredients that keep planets and moons in their orbits.

The attractive force between two bodies creates an acceleration that is directed from one body to the other. If both bodies were initially at rest with respect to each other, this would result in the bodies getting closer until they collide. But if the bodies have relative velocities that are not in the direction of the acceleration, they constantly miss each other. Because there is no friction in space slowing things down the bodies keep orbiting each other around a common center of mass, called the Barycenter.

If one body is much more massive than the other, the barycenter lies near the center of the heavier body, so the less massive body practically orbits the heavier body, while the heavy body seams to stay rather stationary, only wiggles slowly around the barycenter.

Orbits are generally not perfect circles but ellipses. Only if the velocitiy is always exactly at 90° to the acceleration vector and the magnitude has exactly a certain value then the orbit is a perfect circle. Although the orbits of the planets and moons in the solar system are all slightly elliptical, the deviation from a perfect circle is barely noticable.

On elliptical orbits the distance between two bodies and the speed of the orbiting body constantly changes, which means that the forces/accelerations between the bodies are constantly changing too. How can such orbits be stable?

This has to do with Symmetries and Conservation Laws, which are Basic Properties of the Universe.

In orbits (circular and elliptic), the total energy = sum of potential and kinetic energy at each point of the orbit is constant = conserved. It is not dependent on the excentricity of the orbit. This is also a consequence of the inverse square law of Gravity. The inverse square law on the other hand is a consequence of the universe being 3-dimensional. All this enables stable elliptical orbits.

In the simulation the darker gray circle around the earth shows the range of the so called Hill Sphere. Orbits inside 1/2 (lighter gray circle) to 1/3 of this sphere are stable. Greater orbits are instable due to the influence of the sun or other big planets. Bodies outside of the Hill sphere can not orbit the earth.

If the Hill sphere lies inside a body, then there are no orbits possible around the body. For example the Hill sphere of the ISS lies inside the hull of the ISS, so an astronaut outside can not orbit the station although he gets attracted to it.

The Barycenter of the Solar System

ZoomMoving Barycenter of the solar system

One consequence of the fact, that all masses in the solar system attract each other, is, that the earth and the other planets do not orbit around the center of the sun, but all planets and the sun orbit around the common center of mass, called the Barycenter.

The barycenter of two bodies lies on the line connecting the center of the two bodies and is nearer the body with the greater mass. In our solar system the barycenter of the sun and all planets makes complicated figures and lies sometimes inside the sun, sometimes outside.

So with respect to the common center of mass of the solar system the sun makes very slow complicated movements.

In the simulation it can be observed, that the sun revolves around a center that is not the center of the sun. Select the option Show CM to show the center of masses. The barycenter of the whole system is indicated by the red crosshair.

The barycenter of earth and moon lies also not at the center of the earth (black cross). The Earth-Moon systems barycenter revolves around the sun on the orange orbit. Earth and moon revolve around this barycenter on their orbit. This feature of the simulation can be observed in reality.

Show Simulation of Barycenters

Why does the Moon not get caught by the Sun?

Now that we understand how the paths of objects are an illusion created by the observer and the observer has no effect on the motion of the objects, we can analyze the paths without having an observer to take into account.


To determine the trajectory of the moon we have to determine all forces acting on the moon all the times.

In the solar system all bodies exert a force on each other due to Gravity. Because the force gets much weaker as further away a body is (proportional to one over distance squared), only the force of the earth and the sun are relevant to the motion of the moon. Although the sun is very far away from the moon compared to the earth, its influence can not be neglegted, because the sun has an enormous mass.

More than 99.8% of the mass of the whole solar system is concentrated in the sun. In fact the attracting force on the moon is more than twice as strong as the attracting force of the earth on the moon. See Hill Sphere for an explanation why the moon orbits the earth anyway.

Lets explore the forces between sun, earth and moon. Because the earth has a bigger mass than the moon, the attraction force between sun and earth is greater than the attraction force between the sun and moon. The attraction force between earth and moon is the same for both, according to Newton's third law of motion.

This may be surprising. It implies that you are attracting the earth with the same force as the earth is attracting you. But because acceleration is also dependent on the mass of the attracted object, the movement of the earth caused by you attracting it is not perceivable, but not zero!

To be specific: The earth has roughly 1023 times more mass than a human, so the earth's displacement caused by you attracting it is 1023 times smaller than the displacement of you caused by earth's attraction. Nowadays we can measure the change in earths rotation rate due to the displacement of large masses, like when we empty a big artificial lake.

But back to the forces between sun, earth and moon. You can visualize the forces in the simulation:

ZoomForces acting between sun, earth and moon

Show Forces

Note that the forces between earth and moon are equal but opposite. The moon is attracting the earth with the same force as the earth is attracting the moon (Newton's third law).

Accelerations of earth and moon

Show Accelerations

Note that the acceleration of the moon and earth caused by the sun are almost the same. So they both orbit the sun at about the same path, because their mean speed around the sun is the same too.

In the left image above you see the individual force components. The total force on a body is the vector sum of the force components acting on the body. By showing the individual force components, it is easier to see what's going on.


Notice, that the attraction force sun/earth is greater than the attraction force sun/moon. You may ask, how can the moon follow a nearly circular orbit around the earth, if earth and moon are not attracted with the same force to the sun? Sould not the earth get caught by the sun or the moon get lost into space?

This is not the case. It has to do with the fact that not the force is responsible for the motion of objects, but the resulting acceleration. The acceleration is not only dependent on the force, but depends on the mass of the object too: a = F / m. So if we look at the components of the acceleration in the right image above, we notice that the acceleration in direction to the sun is the same for earth and moon! So the sun accelerates earth and moon with the same amount towards it.

This may be surprising. But on the earth we can observer the same phenomenon: each mass is accelerated exactly the same amount to the center of the earth, no matter how much mass an object has. This also applies to space. If two objects are the same distance to the sun, they get attracted to the sun with the same acceleration. So the whole earth/moon system orbits the sun on the same track.

Strictly speaking, this is not quite right. The orbit of the moon is not always exactly at the same distance to the sun. So the attraction between sun and moon changes constantly. But as long as the attraction between sun and moon does not vary a lot with respect to the mean attraction, the orbit of the moon around the earth is not disturbed much by the sun. This is the case if the distance between the earth/moon system and sun is much greater than the distance between earth and moon, so that the moon lies well inside the Hill Sphere, which is the case in reality.

Acceleration in the real Solar System

Lets calculate the accelerations in the real solar system:

Sun accelerating Earth 0.00593 m/s2
Sun accelerating Moon (0.00593 ± 0.00003) m/s2
Earth accelerating Moon 0.00270 m/s2
Moon accelerating Earth 0.0000332 m/s2

We can see that the sun is accelerating earth and moon the same amount, so earth and moon orbit the sun together. But surprisingly the sun is accelerating the moon about twice as much as the earth is accelerating the moon. Why does the moon not get accelerated away from the earth?

Hill Sphere

To anwer this we have to calculate the range around the earth in which the influence of the earth on any satellite like the moon is greater than the sun. This range is a sphere around the earh which radius is the distance from the center of the earth to the Lagrangian Points L1 and L2. This sphere is called Hill sphere. As long as a satellite stays within this sphere it keeps orbiting the earth.

The radius of the Hill sphere for the earth is:

r_\mathrm{H} = d_\mathrm{se} \cdot \sqrt[3]{ { M_\mathrm{e} \over 3 \cdot M_\mathrm{s} } } = 1{,}500{,}000\ \mathrm{km}
r_\mathrm{H} ' =' 'radius of the Hill sphere of the earth
d_\mathrm{se} ' =' '150,000,000 km = distance between sun and earth
M_\mathrm{e} ' =' '5.97 × 1024 kg = mass of the earth
M_\mathrm{s} ' =' '1.99 × 1030 kg = mass of the sun

Detailed numerical calculations show that orbits at or just within the Hill sphere are not stable in the long term; it appears that stable satellite orbits exist only inside 1/2 to 1/3 of the Hill radius (Source Wikipedia: Hill sphere). The distance between earth and moon is with 384,000 km smaller than 1/3 of the Hill sphere radius, so it's orbit is stable.

In the simulation the Hill sphere around the earth is displayed in light grey. You can simulate a solar system where the acceleration of the moon from the sun is bigger than the acceleration of the moon from the earth maintaining a stable orbit by clicking the following button:

Show stable orbit withing the Hill sphere

Playing with Gravity

In the simulation, using the blue buttons, you can deactivate the attraction between sun, earth and moon to simulate what happens. Try to disable one force only for a very short time to disturb the orbits. There are three possibles outcomes of such disturbances:

  1. the moon or the earth/moon system get captured by the sun again but now follow an elliptical orbit
  2. the moon my get captured by the sun if its orbit leaves the Hill Sphere
  3. the moon or the earth/moon system escape the solar system

Try and disable some Forces

Why can't we feel motion?

This has 3 reasons:

  1. Uniform, non-accelerated motion of a system is not detectable in the system itself.
  2. The human body gets used to uniform forces and can not feel constant accelerations below a certain level.
  3. Changes in accelerations below a certain magnitude or rate can not be felt by the human body.

Uniform motion

Because of the Relativity of Positions and Velocities, which states that there is no such thing as absolute position and velocity, it follows, that in all systems that are not accelerated, the physical laws are not dependent on the motion of the system with respect to anything. Therefore there is no way to measure or feel any motion in a non-accelerated system. There is no physical effect that is caused by uniform motion.

Because the impression of motion is caused by forces acting on a person and there are no forces caused by uniform motion, you can not feel uniform motion. The impression of motion can be caused by vibrations or accelerations of the vehicle. The impression of motion can also be caused by looking at objects which are moving relative to the observer. Without such a reference this impression vanishes.

Accelerations due to Rotation and Orbits

Is a rotating planet orbiting a sun a non-accelerated system?

No, orbits are accelerated motions and an object on the surface of a rotating body is in an accelerated state too. Acceleration can be measured with accelerometers. Rotations can be measured eg. with LASER-Gyros.

So why can't we feel the accelerations due to rotation of the earth and the moon orbiting the earth and the orbit of the earth around the sun?

Because this accelerations are too small to be noticed.

To be specific, the accelerations are:

g = { G \cdot M_\mathrm{E} \over R^2 } = 9{.}816\ \mathrm{m}/\mathrm{s}^{2}
g ' =' 'earth's gravitational acceleration (mean value)
G ' =' '6.674 × 10−11 m3/(kg·s2) = gravitational constant
M_\mathrm{E} ' =' '5.97 × 1024 kg = mass of the earth
R ' =' '6371 km = radius of the earth
a_\mathrm{rot} = {\omega_\mathrm{rot}}^2 \cdot R = 0{.}0337\ \mathrm{m}/\mathrm{s}^{2}
a_\mathrm{rot} ' =' 'centrifugal acceleration at the equator due to earth's rotation
\omega_\mathrm{rot} ' =' '2·π/Trot = 7.27 × 10−5 s−1 = angular speed of earth's rotation
T_\mathrm{rot} ' =' '24·3600 s = rotation period (1 day)
R ' =' '6371 km = radius of the earth

So a 100 kg weight measured at the poles would weigh 340 g less at the equator.

a_\mathrm{moon} = G \cdot M_\mathrm{moon} \cdot \left[ { 1 \over (d_\mathrm{em} - R)^2 } - { 1 \over {d_\mathrm{em}}^2 } \right] = 0{.}00000113\ \mathrm{m}/\mathrm{s}^{2}
a_\mathrm{moon} ' =' 'maximal acceleration due to moons gravity in direction to the moon
G ' =' '6.674 × 10−11 m3/(kg·s2) = gravitational constant
M_\mathrm{moon} ' =' '7.34 × 1022 kg = mass of the moon
d_\mathrm{em} ' =' '384,400 km = distance from earth to moon
R ' =' '6371 km = radius of the earth
a_\mathrm{sun} = G \cdot M_\mathrm{sun} \cdot \left[ { 1 \over (d_\mathrm{se} - R)^2 } - { 1 \over {d_\mathrm{se}}^2 } \right] = 0{.}000000501\ \mathrm{m}/\mathrm{s}^{2}
a_\mathrm{sun} ' =' 'maximal acceleration due to sun's gravity in direction to the sun
G ' =' '6.674 × 10−11 m3/(kg·s2) = gravitational constant
M_\mathrm{sun} ' =' '1.99 × 1030 kg = mass of the sun
d_\mathrm{se} ' =' '150,000,000 km = distance from earth to sun
R ' =' '6371 km = radius of the earth

Basic Properties of the Universe

To understand orbital mechanics, we need to understand some basic properties of the universe and their implications on motion in general and on orbits specifically. All motions of gravitational bound objects obey the following basic observable properties of the universe:

Symmetries and Conservation Laws

Note: it is not nessesary that you understand what Noether's theorem is, only the physical consequences due to observable properties of the universe are important here.

Noether's theorem states that every differentiable symmetry of the action of a physical system has a corresponding conservation law. The theorem was proven by mathematician Emmy Noether in 1915 and published in 1918.

The action of a physical system is the integral over time of a Lagrangian function, from which the system's behavior can be determined by the principle of least action. The principle of least action can be used to obtain the equations of motion for a system.

Loosely speaking, symmetries in nature account for conservations laws like:

Place and Time Symmetry
If a physical process exhibits the same outcomes regardless of place or time, then its Lagrangian is symmetric under continuous translations in space and time respectively: by Noether's theorem, these symmetries account for the conservation of linear momentum and energy within this system, respectively.
Rotational Symmetry
If a physical system behaves the same regardless of how it is oriented in space, its Lagrangian is symmetric under continuous rotations: by Noerther's theorem, this symmetry accounts for the conservation of angular momentum of the system. The physical system itself need not be symmetric; a jagged asteroid tumbling in space conserves angular momentum despite its asymmetry. It is the laws of its motion that are symmetric.

Source: Wikipedia Noether's theorem

This symmetries of the universe are one reason why stable orbits can exist.

Relativity of Positions and Velocities

Position and velocity are not properties that can be assigned to a single object or system of objects. Position and velocity are relations between different objects or systems. There is no absolute reference point or center of the universe that would allow to assign an absolute position and velocity to an object or system.

You always have to measure position and velocity with respect to a certain observer or reference frame. An observer, moving relativ to another observer measures different positions and velocities of the same observed object or system.

The physical laws are the same at any point in the universe. Therefore there is no special point in the universe that is distinct from any other point, that we could call origin and use as an universal reference point. All positions and velocities are relative to a certain observer and the corresponding values are unique for this observer but different for any other observer.

Because we cannot assign any position or velocity to an object or system itself, no matter what position and velocity that system has with respect to any observer, it has no effect on the system itself whatsoever. You cannot measure a position or velocity or feel a velocity of a system itself, because it has no position and velocity assigned to itself. Position and velocity only exist in the context of relations between objects and observers and do not change the physics in the observed object or system.

This implies that we can choose an arbitrary non-accelerated point, observer or frame as our reference to describe the motion of an object or system of objects, but for all computations we have to use the same choosen observer or reference frame.

This is reflected in the simulation as you can choose between four observer coordinate systems CoordSys and it does not change the orbits of the bodies. It only changes the apparent paths of the bodies, as apparent paths are distinct for each observer.

The simulation uses for all calculations the galaxy as the non-accelerated reference frame, no matter which observer coordinate system is choosen. But any non-accelerated reference frame will do the same.

Absoluteness of Accelerations and Forces

Contrary to position and velocity, accelerations and forces are absolute and not relative to an observer. Each object can have an acceleration of its own due to forces acting on it independent of any observer. This means each observer measures the same acceleration of a certain object (the same change in velocity) and the same forces acting on that object. This includes an observer that is on the observed object itself at any moment in time.

So accelerations and forces that change the trajectory are local properties of an object or system that can be measured within the system itself without reference to something external. That is the reason why we can feel accelerations respectively the corresponding forces, if they are not constant and/or are greater than a certain threshold.

Accelerations and forces are related according to Newton's second law of motion:

\sum \vec F_i = m \cdot \vec a \qquad\Leftrightarrow\qquad \vec a = { \sum \vec F_i \over m }
\vec F_i ' =' 'one individual force acting on the object of mass m
m ' =' 'mass of the object
\vec a ' =' 'acceleration of the object

\sum \vec F_i means, sum of all forces. The arrows above the symbols denote that the forces and the acceleration have a direction in 3D space. So you have to take the vector sum of all forces acting on an object. The acceleration has then the direction of the vector sum.

Why are accelerations and forces absolute local properties of an object while position and velocity are relative to an observer?

This has to do with how acceleration is defined:

acceleration = change_in_velocity / change_in_time = \Delta \vec v / \Delta t

Acceleration and velocity are vector quantities. At time t the velocity of an object relative to an observer is \vec v_1. At time (t + Δt) the velocity is \vec v_2 = \vec v_1 + \Delta \vec v. The change in velocity \Delta \vec v over the time period Δt is the difference between the velocity (\vec v_1 + \Delta \vec v) at time (t + Δt) and the velocitiy \vec v_1 at time t relative to an observer. So taking this difference cancels the relative velocity between any observer and observed object:

\vec a = { \vec v_2 - \vec v_1 \over \Delta t } = { \vec v( t + \Delta t ) - \vec v( t ) \over \Delta t } = { ( \vec v_1 + \Delta \vec v ) - \vec v_1 \over \Delta t } = { \Delta \vec v \over \Delta t }
\vec a ' =' 'acceleration
\vec v_1 = \vec v(t) ' =' 'relative velocity between observer and object at time t
\vec v_2 = \vec v( t + \Delta t) ' =' 'relative velocity at time t + Δt
\Delta \vec v ' =' 'change in velocity
\Delta t ' =' 'time step

We can see that the relative velocities \vec v_1, \vec v_2 between observer and object fall out of the equation. Only the change in velocity \Delta \vec v is relevant for the acceleration, which is now independent of the velocity between any observer and object. This means every observer sees the same acceleration of an object, no matter how the relative velocity is between observer and object. This includes an observer at the object itself. Therefore it follows, that the acceleration is observable from within the object itself. Acceleration is a property that can be assigned to an object itself and is independent of an observer.

Because forces and accelerations are proportional to each other, forces, like accelerations, are not dependent on any observer.


Mass attracts Mass: This property of mass can be measured eg. with the Cavendish Experiment. The force between two masses is according to Newton's law of universal gravitation:

F = { G \cdot m_1 \cdot m_2 \over d^2 }
F ' =' 'magnitude of the force between the two bodies m1 and m2
G ' =' '6.674 × 10−11 N·m2/kg2 = gravitational constant
m_1, m_2 ' =' 'attracting masses
d ' =' 'distance between the centers of the masses

According to Newton's third law body 1 attracts body 2 with the same force F as body 2 attracts body 1. The force vectors are pointing from one body to the other. For the vector form of this equation see Computing all Forces.

Laws of Motion

Now that we know how to compute all forces acting on an object due to gravity we can compute its acceleration, velocity and path.

Newton's laws of motion describe the connection between forces, accelerations, velocities and positions:

First law
In an inertial frame of reference (non-accelerated system), an object either remains at rest or continues to move at a constant velocity, unless acted upon by a force. The resistance of any physical object to any change in its position and state of motion is called Inertia.
Second law
In an inertial reference frame, the vector sum of the forces F on an object is equal to the mass m of that object multiplied by the acceleration a of the object: F = m·a (or solved for acceleration: a = F/m).
Third law
When one body exerts a force on a second body, the second body simultaneously exerts a force equal in magnitude and opposite in direction on the first body.

The second law is also called Equation of motion. If we know all forces acting on an object, we can calculate the acceleration of the object which determines the change in velocity and position in time. The connection between acceleration, velocity and position is described by the following differential equations (bare with me, I explain it below):

\vec v(t) = { \mathrm{d} \vec P(t) \over \mathrm{d} t } \qquad\qquad \vec a(t) = { \mathrm{d} \vec v(t) \over \mathrm{d} t }
\vec v(t) ' =' 'velocity as a function of time
\vec P(t) ' =' 'position as a function of time
\mathrm{d} \vec P(t)/ \mathrm{d} t ' =' 'means the derivative of \vec P(t) with respect to time
\vec a(t) ' =' 'acceleration as a function of time
\mathrm{d} \vec v(t)/ \mathrm{d} t ' =' 'means the derivative of \vec v(t) with respect to time

This equations simply mean, that current velocity at any time t is nothing more than an infinitesimal small path \mathrm{d} \vec P traveled at that time divided by the time \mathrm{d} t it takes to travel this path. This is the definition of velocity. The d stands for delta, that is a symbol for an infinitely small change of:

velocity = change_in_distance / change_in_time

The same applies to accelerations:

acceleration = change_in_velocity / change_in_time.

But we don't know the path of an object and it's velocity. That is what we want to calculate from the known acceleration. This can be achieved by integrating the differential equations above, so we get:

\vec v(t) = \int \vec a(t) \ \mathrm{dt} + \vec v_0 \qquad\qquad \vec P(t) = \int \vec v(t) \ \mathrm{dt} + \vec P_0
\vec v_0 ' =' 'initial velocity
\vec P_0 ' =' 'initial position

These are the foundations of classical mechanics and can be applied to any system of objects, as long as the speeds involved are much smaller than the speed of light and gravity is weak (eg. far from a neutron star or black hole).

The simulation uses Numerical Integration to compute velocity and position from acceleration.

How the Simulations works

The App divides the simulation in many tiny time steps of length Δt = 50 μs. For each time step the following algorithm is executed:

  1. Computing all forces acting on each body from the current positions of the bodies using Newton's law of gravitation
  2. Computing the acceleration of each body from the sum of the forces acting on it using Newtons second law of motion a = F / m
  3. Computing the change in velocity due to acceleration for each body
  4. Computing the new velocity by adding the change in velocity for each body
  5. Computing the change in position due to velocity for each body
  6. Computing the new position by adding the change in position for each body

This algorithm is repeatet over and over again and produces the shown orbits. The essential parts of the simulation code is explained in Simulation Code of Solar System Animation explained. The whole source code can be inspected in Source Code: Solar System Animation.

Computing all Forces

First the simulation computes the forces between all bodies according to Newton's law of universal gravitation. Given the positions \vec P and masses M of two bodies i and j, the attractive force between them can be computed as follows:

\vec F_{i,j} = - { G \cdot m_i \cdot m_j \over d^2 } \cdot \hat r_{i,j}
\hat r_{i,j} = { \vec P_j - \vec P_i \over d } \qquad\qquad d = | \vec P_j - \vec P_i |
\vec F_{i,j} ' =' 'force of mass m_i on mass m_j in the direction from m_j to m_i
G ' =' '6.674 × 10−11 m3/(kg·s2) = Gravitational constant
m_i, m_j ' =' 'the two masses attracting each other
d ' =' 'distance between the two masses
\hat r_{i,j} ' =' 'unit-vector pointing from position of mass m_i to position of mass m_j
\vec P_i, \vec P_j ' =' 'positions of the two masses

Note that the attraction force is a vector pointing from one mass to the other. According to Newton's fist law of motion the force pointing from object i to object j is the same in magnitude but in opposite direction as the force pointing from object j to object i:

\vec F_{i,j} = - \vec F_{j,i}

The expression | \vec P_j - \vec P_i | means: take the vector pointing from P_i to P_j and compute its length. So generally |\vec x| means the length of the vector x. The length of a vector can be computed applying Pythagoras on its components x_1, x_2, x_3:

| \vec x | = \sqrt{ {x_1}^2 + {x_2}^2 + {x_3}^2 }

For each of the 3 bodies we get 2 forces respectively. One force to each other body. Now we have to combine all forces acting on one body by vectorial addition to get the vector sum:

\vec F_{\mathrm{tot},i} = \vec F_{1,i} + \vec F_{2,i}

To add vectors, you simply add the corresponding components of the vectors to get a new vector. Note, the new vector \vec F_{\mathrm{tot},i} of object i is pointing in another direction somewhere between the single vectors that are added.

Computing the Acceleration of each Body

Now each object has one single combined force acting on it. From Newton's second law of motion F = m·a we can compute the acceleration of each object due to the combined forces acting on it:

\vec a_i = { \vec F_{\mathrm{tot},i} \over m_i }
\vec a_i ' =' 'acceleration vector of object i
\vec F_{\mathrm{tot},i} ' =' 'combined force acting on object i
m_i ' =' 'mass of object i

Note that the acceleration vector \vec a_i acts in the direction of the vectorial sum of all Forces \vec F_{\mathrm{tot},i} acting on the object i.

Now we have the acceleration of each body and the direction in which the acceleration acts. How do we get from this the individual velocities and poisitions while the time is passing?

Computing the Velocity of each Body

To get the velocity for each object, we have to integrate the acceleration. This is mathematically expressed as follows:

\vec v_i(t) = \int \vec a_i(t) \ \mathrm{dt} + \vec v_{i,0}

Or we can get the change in velocity \mathrm{d} \vec v in the timespan \mathrm{d} t:

\mathrm{d} \vec v_i(t) = \vec a_i(t) \cdot \mathrm{d} t

Computing the Position of each Body

Similar we can calculate the position for each object at each time by integrating the velocity:

\vec P_i(t) = \int \vec v_i(t) \ \mathrm{dt} + \vec P_{i,0}

Or the change \mathrm{d} \vec P in the timespan \mathrm{d} t is:

\mathrm{d} \vec P_i(t) = \vec v_i(t) \cdot \mathrm{d} t

Numerical Integration

We can not integrate \vec a_i(t) and \vec v_i(t) algebraically for a 3 body system. So we have to use numerical algorithms. In principle we divide the motions into small chunks of time length \Delta t. Then we compute for each time step from the known acceleration of each body the change in velocity and the change in position. We add the change in velocity to the current velocity and the change in position to the current position and get velocity and position for the next time step:

\Delta \vec v( t ) = \vec a( t ) \cdot \Delta t
\vec v( t + \Delta t) = \vec v( t ) + \vec \Delta v( t )
\Delta \vec P( t ) = \vec v( t ) \cdot \Delta t
\vec P( t + \Delta t ) = \vec P( t ) + \vec \Delta P( t )

This steps are continuously repeatet for each time step \Delta t and the objects are drawn at the calculated positions.

Note: the simulation uses a more sophisticated rule for the integration, that halves the error compared to the above method.

Problems of Numeric Simulations

Numeric simulations like this one have one big problem: small rounding errors accumulate by the integration process. In the case of this simulation it results in slowly decaying orbits, especially if the angular speed around an object gets big. To minimize the errors the simulation computes 20,000 steps for each frame, ie 20,000 steps each 16.7 ms!

If you encounter decaying orbits, it's due to accumulating numerical errors. In reality such decays do not happen, except a body is slowed down by friction.

Computing the Start Values

We have to compute start conditions, the values for positions and velocities of the bodys, so that they initially produce stable orbits. We can use Kepler's laws to compute the start positions and velocities given distances between the bodies and their orbital period.

The App also computes the masses and their corresponding sizes of the objects from the distances and periods, assuming some density of the objects, so that their pixel size is appropriate.

Note: in reality the masses, their distances and their velocities and start positions are given and the orbital periods and center of masses depend on that. For the simulation it was a priority, that the graphics fits onto the sceen. Therefor the data is computed the other way around as follows:

Computing the Masses

Given the orbital period T and the distance between two bodies D we can compute the central mass needed to hold the body in orbit using Kepler's law:

M_\mathrm{Sun} = { 4 \cdot \pi^2 \cdot (D_\mathrm{SunEarth})^3 \over G \cdot (T_\mathrm{Earth})^2 }
M_\mathrm{Sun} ' =' 'Mass of sun
D_\mathrm{SunEarth} ' =' 'Distance sun to earth-moon center of mass
G ' =' '6.674 × 10−11 m3/(kg·s2) = Gravitational constant
T_\mathrm{Earth} ' =' 'Orbital period of earth-moon system
M_\mathrm{Earth} = { 4 \cdot \pi^2 \cdot (D_\mathrm{EarthMoon})^3 \over G \cdot (T_\mathrm{Moon})^2 }
M_\mathrm{Earth} ' =' 'Mass of earth
D_\mathrm{EarthMoon} ' =' 'Distance earth to moon
G ' =' '6.674 × 10−11 m3/(kg·s2) = Gravitational constant
T_\mathrm{Moon} ' =' 'Orbital period of moon

The mass of the moon is computed from the relative position of the common center of mass (CMEarthMoon) between earth and moon:

M_\mathrm{Moon} = M_\mathrm{Earth} \cdot { CM_\mathrm{EarthMoon} \over 1 - CM_\mathrm{EarthMoon} }
M_\mathrm{Moon} ' =' 'Mass of the moon
M_\mathrm{Earth} ' =' 'Mass of the earth as computed with (23)
CM_\mathrm{EarthMoon} ' =' 'relative Distance earth to center of mass (CM). 0.5 means the same distance from CM to earth and moon.

Initial Positions and Velocities for the Sun

The sun and earth-moon system orbits around a common center of mass. The distance between sun and earth-moon system as given by the parameter DSunEarth has to be corrected by incorporating the calculated mass of the sun and mass of the earth-moon system from above:

D_\mathrm{SunEarth} = \left[ { G \cdot ( M_\mathrm{Sun} + M_\mathrm{Earth} + M_\mathrm{Moon} ) \cdot (T_\mathrm{Earth})^2 \over 4 \cdot \pi^2 } \right]^{1/3}

The distance of the common center of mass sun-earth from the earth is:

D_\mathrm{CmEarth} = D_\mathrm{SunEarth} \cdot { M_\mathrm{Sun} \over M_\mathrm{Sun} + M_\mathrm{Earth} + M_\mathrm{Moon} }

The distance of the common center of mass sun-earth from the sun is:

D_\mathrm{SunCm} = D_\mathrm{SunEarth} - D_\mathrm{CmEarth}

The tangential velocity of the sun around the CM is:

v_{\mathrm{t},\mathrm{Sun}} = { 2 \cdot \pi \cdot D_\mathrm{SunCm} \over T_\mathrm{Earth} }

And the tangential velocity of the earth-moon CM around the CM of the sun is:

v_{\mathrm{t},\mathrm{EarthMoon}} = { 2 \cdot \pi \cdot D_\mathrm{CmEarth} \over T_\mathrm{Earth} }

Now we can setup an initial state for the sun. To simulate movement of the whole solar system through the galaxy in the left direction we add a negative velocity component v_\mathrm{Galaxy} to the x axis of the start velocity vector of each body:

\vec P_\mathrm{Sun} = \pmatrix{ -D_\mathrm{SunCm} \\ 0 }
\vec v_\mathrm{Sun} = \pmatrix{ -v_\mathrm{Galaxy} \\ -v_{\mathrm{t},\mathrm{Sun}} }

Initial Positions and Velocities for Earth and Moon

The earth and moon orbit around a common center of mass between them. The distance between earth and moon as given by the parameter DEarthMoon has to be corrected by incorporating the calculated masses of the earth and moon:

D_\mathrm{EarthMoon} = \left[ { G \cdot ( M_\mathrm{Earth} + M_\mathrm{Moon} ) \cdot (T_\mathrm{Moon})^2 \over 4 \cdot \pi^2 } \right]^{1/3}

The distance of the common center of mass earth-moon from the moon is:

D_\mathrm{CmMoon} = D_\mathrm{EarthMoon} \cdot { M_\mathrm{Earth} \over M_\mathrm{Earth} + M_\mathrm{Moon} }

The distance of the common center of mass earth-moon from the earth is:

D_\mathrm{EarthCm} = D_\mathrm{EarthMoon} - D_\mathrm{CmMoon}

The tangential velocity of the Earth around the CM is:

v_{\mathrm{t},\mathrm{Earth}} = { 2 \cdot \pi \cdot D_\mathrm{EarthCm} \over T_\mathrm{Moon} }

And the tangential velocity of the moon around the CM is:

v_{\mathrm{t},\mathrm{Moon}} = { 2 \cdot \pi \cdot D_\mathrm{CmMoon} \over T_\mathrm{Moon} }

Now we can setup an initial states for earth and moon:

\vec P_\mathrm{Earth} = \pmatrix{ D_\mathrm{CmEarth} - D_\mathrm{EarthCm} \\ 0 }
\vec v_\mathrm{Earth} = \pmatrix{ -v_\mathrm{Galaxy} \\ v_{\mathrm{t},\mathrm{EarthMoon}} - v_{\mathrm{t},\mathrm{Earth}} }
\vec P_\mathrm{Moon} = \pmatrix{ D_\mathrm{CmEarth} + D_\mathrm{CmMoon} \\ 0 }
\vec v_\mathrm{Earth} = \pmatrix{ -v_\mathrm{Galaxy} \\ v_{\mathrm{t},\mathrm{EarthMoon}} + v_{\mathrm{t},\mathrm{Moon}} }

Implementation Detail

The presented formulas work for a real solar system. The model however uses distances in pixels and periods in seconds. To account for that, the gravitational constant was scaled to G = 1 px3/(kg·s2) and all masses are scaled accordingly. The size of the bodies are computed from the scaled masses by incorporating a scaled density, so that the radius of the bodies gets in a range of 8 to 80 pixels.

The radius of a sphere with mass M and density ρ is:

R = { \left( { 3 \cdot M \over 4 \cdot \pi \cdot \rho } \right) }^{ 1/3 }

So the radius is proportional the the cube root of the mass. I can define a density factor ρ', that converts a scaled simulator mass to a decent radius:

R = \sqrt[3]{ { M \over \rho^{\,\prime} } }

The following density factors turned out to be usefull to get decent pixel sizes depending on the masses:

ρ' for sun  : 84{.}6\ \mathrm{kg}/\mathrm{px}^{3}
ρ' for earth: 705\ \mathrm{kg}/\mathrm{px}^{3}
ρ' for moon : 625\ \mathrm{kg}/\mathrm{px}^{3}


1george Hnatiuk 9/6/2018 | 21:01

EXCELLENT - well done Walter.


2Therumpus 9/13/2018 | 18:15

Really, really excellent Walter, I might contact you by email so you can have a look at my ray tracer modelling of refraction.

Fabby stuff.

Your Comment to this Article
Email optional; wird nicht angezeigt
  • Name is displayed on your Comment.
  • Email is only for the Admin, will not be displayed.
  • You can edit or delete your Comment for some Time.
  • You can use Comment Formatings, eg Codes, Formulas...
  • External Links and Pictures will not be displayed, until enabled by the Admin.
Weitere Infos zur Seite
Erzeugt Wednesday, September 5, 2018
von wabis
Zum Seitenanfang
Geändert Sunday, September 9, 2018
von wabis