Gravity, Two-Body Problem

This HTML5 app can simulate how two bodies (assumed as point masses) move under the influence of gravity. The problem of calculating such a motion was solved by Isaac Newton for the first time and is known as two-body problem.

The motion of the two bodies is displayed in the center-of-mass frame. This means that the origin of the coordinate system coincides with the barycenter of the two masses at all times. The initial position of body 1 is on the negative x-axis, the initial position of body 2 on the positive x-axis. At the moment of start, the two bodies move in negative respectively positive y-direction.

The time is indicated in the top left-hand corner. At the bottom left, a comparison line shows the scale of the drawing.

The first button of the control panel ("Reset") brings the simulation into the initial state. You can start or stop and continue the simulation by using the second button. If you choose the option "Slow motion", the animation will be 10 times slower.

There are five input (output) fields for the initial state. Scientific notation (with powers of 10) is used because the numbers can be very large or very small.

By pressing the button "Circular orbit" respectively "Parabolic trajectory", you can set the initial velocities so that the two bodies move on corresponding paths.

The selection field at the bottom gives the possibility to output data on different aspects:

This browser doesn't support HTML5 canvas!