planetsun - the kepler problem in 3d
Physics behind

The astronom Johannes Kepler (1571 - 1630) was the first to discover that the planet's motions is described by ellipses. Later, he proposed the famous three Kepler's laws, which describe (in good approximation) the basic constants of motions of our solar system. These laws are:

  1. The orbit of a planet about a sun is an ellipse with the Sun's center of mass at one focus
  2. A line joining a planet and a sun sweeps out equal areas in equal intervals of time
  3. The squares of the periods of the planets are proportional to the cubes of their semimajor axes

Some mathematics:

The following provides a (very rough) introduction into the physics and mathematics behind the Kepler problem and how it was applied to the planetsun sample applications:

The Kepler problem means to solve the equation of motion for two masses with mass m1 and m2 in Newton's gravitatioanl field.

The Lagrange function of the problem is given by

L = m1/2 * v1**2 + m2/2 * v2**2 - G*m1*m2/|r1 -r2|


r1 = the position of mass 1
r2 = the position of mass 2
v1 = dr1/dt = velocity of mass 1
v2 = dr2/dt = velocity of mass 1
G = Newton's gravitional constant

Inserting the Lagrange function in the Lagrange equation, we get a coupled system of six second order differential equations. By using the symmetries of the problem (1. translation symmetry 2. rotation symmetry 3. time symmetry) this problem can be reduced to two first order differential equation:

E = m * (dr/dt)**2 + L**2 / (2 * m * r**2) - a / r
L = m * r**2 * dphi/dt


(r, phi) = polar coordinates of the relative vector r1 - r2
E = energy of the system
L = angular momentum of the system
m = the 'reduced mass': m1 * m2 / (m1 + m2).
a = G * m1 * m2

After some computation the solution is given by

p / r = 1 + e * cos (phi)

where the two constants e and p are defined through:

p = L**2 / (m * a)
e = sqrt(1 + 2 * E * L**2 / (m * a**2)) [excentricity]

Unfortunately, the equation cannot be solved in a closed form like r = r(t). But with some additional help parameter w defined through

r - a = -a * e * cos (w)

We can write the solution for the radius r, the angle phi and the time t like:

  1. t = sqrt(m * p**3 / a) * (e * cos(w) - w)
  2. r = p * (1 + w**2) / 2
  3. phi = acos((1/r - 1) / e)

The position of the planet and the sun at any time is now calculated by first finding the corresponding parameter w in equation (1). This is done with the iterative 'Newton Method'. After finding w, we can use (2) to find the relative radius r and finally equation (3) to find the angle phi.

That's the basic mathematics of the planetsun program!

planetsun - the kepler problem in 3d is a bitsoup project
last modified: 2007 JUL 21
Valid HTML 4.01!spacerValid CSS!