Link: http://walter.bislins.ch/Helio
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 MoonSun off EarthSun off Sun off Reset
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.
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.
So if this simulation can produce stable orbits obeying Newton's laws, then such orbits are possible in reality too.
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:
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:
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.
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 3dimensional. 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.
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 EarthMoon 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
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 10^{23} times more mass than a human, so the earth's displacement caused by you attracting it is 10^{23} 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:
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).
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.
Lets calculate the accelerations in the real solar system:
Sun accelerating Earth  0.00593 m/s^{2} 
Sun accelerating Moon  (0.00593 ± 0.00003) m/s^{2} 
Earth accelerating Moon  0.00270 m/s^{2} 
Moon accelerating Earth  0.0000332 m/s^{2} 
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?
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:
(1) 
 
where^{'} 

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
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:
This has 3 reasons:
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 nonaccelerated 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.
Is a rotating planet orbiting a sun a nonaccelerated 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 LASERGyros.
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:
(2) 
 
where^{'} 

(3) 
 
where^{'} 

So a 100 kg weight measured at the poles would weigh 340 g less at the equator.
(4) 
 
where^{'} 

(5) 
 
where^{'} 

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:
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:
Source: Wikipedia Noether's theorem
This symmetries of the universe are one reason why stable orbits can exist.
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 nonaccelerated 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 nonaccelerated reference frame, no matter which observer coordinate system is choosen. But any nonaccelerated reference frame will do the same.
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:
(6) 
 
where^{'} 

\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 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:
(7) 
\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 }
 
where^{'} 

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:
(8) 
 
where^{'} 

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.
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:
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):
(9) 
 
where^{'} 

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:
The same applies to accelerations:
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:
(10) 
 
where^{'} 

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.
The App divides the simulation in many tiny time steps of length Δt = 50 μs. For each time step the following algorithm is executed:
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.
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:
(11) 
 
with 
\hat r_{i,j} = { \vec P_j  \vec P_i \over d } \qquad\qquad d =  \vec P_j  \vec P_i 
 
where^{'} 

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:
(12) 
\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:
(13) 
 \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:
(14) 

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.
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:
(15) 
 
where^{'} 

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?
To get the velocity for each object, we have to integrate the acceleration. This is mathematically expressed as follows:
(16) 
\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:
(17) 
\mathrm{d} \vec v_i(t) = \vec a_i(t) \cdot \mathrm{d} t

Similar we can calculate the position for each object at each time by integrating the velocity:
(18) 
\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:
(19) 
\mathrm{d} \vec P_i(t) = \vec v_i(t) \cdot \mathrm{d} t

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:
(20) 
\Delta \vec v( t ) = \vec a( t ) \cdot \Delta t

\vec v( t + \Delta t) = \vec v( t ) + \vec \Delta v( t )

(21) 
\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.
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.
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:
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:
(22) 
 
where^{'} 

(23) 
 
where^{'} 

The mass of the moon is computed from the relative position of the common center of mass (CM_{EarthMoon}) between earth and moon:
(24) 
 
where^{'} 

The sun and earthmoon system orbits around a common center of mass. The distance between sun and earthmoon system as given by the parameter D_{SunEarth} has to be corrected by incorporating the calculated mass of the sun and mass of the earthmoon system from above:
(25) 
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 sunearth from the earth is:
(26) 
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 sunearth from the sun is:
(27) 
D_\mathrm{SunCm} = D_\mathrm{SunEarth}  D_\mathrm{CmEarth}

The tangential velocity of the sun around the CM is:
(28) 
v_{\mathrm{t},\mathrm{Sun}} = { 2 \cdot \pi \cdot D_\mathrm{SunCm} \over T_\mathrm{Earth} }

And the tangential velocity of the earthmoon CM around the CM of the sun is:
(29) 
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:
(30) 

(31) 

The earth and moon orbit around a common center of mass between them. The distance between earth and moon as given by the parameter D_{EarthMoon} has to be corrected by incorporating the calculated masses of the earth and moon:
(32) 
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 earthmoon from the moon is:
(33) 
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 earthmoon from the earth is:
(34) 
D_\mathrm{EarthCm} = D_\mathrm{EarthMoon}  D_\mathrm{CmMoon}

The tangential velocity of the Earth around the CM is:
(35) 
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:
(36) 
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:
(37) 

(38) 

(39) 

(40) 

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 px^{3}/(kg·s^{2}) 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:
(41) 
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:
(42) 
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}
EXCELLENT  well done Walter.
George
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.
Stellar work as always.
I've also done something similar in a simple spreadsheet program, and found that you can run into problems with simple Euler integration pretty quickly. However using Verlet integration (which skips the velocity intermediate step) you get much more stable results. Might be worth looking into for this stuff.
cearnicus: Might be worth looking into [Verlet integration] for this stuff.
Thank you very much for this information.
And thank you for your contribution to gravity on the comment section of Flat Earth Dome Model. Below is a copy of your comment, because it better fits to this articel.
cearnicus:
Re gravity: it may also be instructive to look at how one can derive the basic form of Newton's law of gravitation from the observations.
In 2d, circular motion is given by (x, y) = (r \cdot cos( \omega t ), r \cdot sin( \omega t) ), with r the circle's radius and ω the angular velocity. To get the velocity and acceleration you have to differentiate once and twice with respect to time. If you look at the magnitude of those, you have
v = \omega r (= speed along the circle)
a = \omega^2 r = v^2 / r ( = centripetal acceleration)
Note: this stuff is simply part of motion along a circular path. This has nothing to do with gravity (yet), this is what it means to move in a circle. In terms of forces, by definition \vec{F} = m \cdot \vec{a}, meaning that any force that points directly inward and has the same magnitude at constant r results in a circular path.
Kepler's laws provide an accurate description of planetary motion. They are essentially summaries of the observations. Simplifying things to circles, his third law states that the radius cubed is proportional to the period squared: r^3 \propto T^2. Again, no magic; this is what the observations tell us.
So, let's rewrite that so that it fits the formula for the centripetal force.
\begin{eqnarray} T^2 \propto r^3 \\ \left( \frac{2 \pi}{T}\right)^2 \propto \frac{1}{r^3} \\ \left( \frac{2 \pi}{T}\right)^2 r \propto \frac{1}{r^2} \\ \omega^2 r \propto \frac{1}{r^2} \\ a_{centripetal} \propto \frac{1}{r^2} \end{eqnarray}
In other words, the pattern we see in planetary motion can be explained by a force that's inversely proportional to the distance squared between the planet and the sun. And, again, since \vec{F} = m \cdot \vec{a}, we also know that this force is proportional to the mass m_p of the planet:
F_p \propto m_p / r^2.
Now, technically it's not just simply F_1. It's actually the force of one object (the sun S) acting on another (a planet P). So really we have F_{s\rightarrow p} \propto m_p / r^2.Finally, from Newton's third law we know action = reaction, so F_{s \rightarrow p} = F_{p \rightarrow s}. For that we have the something similar: F_{p \rightarrow s} \propto m_s \ r^2.
Putting all of this together, we get:
F \propto \frac{m_{s} \cdot m_{p}}{r_{sp}^2}
Again, all I've done here is distill the observed paths of planets into a formula of a force. And, oh hey, looks suspiciously like Newton's Law of gravity. Note that right now I've only looked at circles and magnitudes, but if you generalize it to vectors and ellipses, you'll find that the law of gravity correctly describes all of Kepler's laws (see its wikipedia page for details). It also correctly predicts that the falling acceleration on earth should decrease with altitude, the atmospheric pressure profile, buoyancy, periodvsdistance relation between the moons of the solar system, etc, etc.
So yes, a force of this form is required to accurately describe nature. We call this force "gravity". Flat earthers can whine about it all they like, but this is what the observations tell us.