# Orbit Simulator

An interactive demonstration of an orbit.

The above demo shows how a body behaves when under the influence of the gravity of a much more massive object. In our example, we have chosen this to be a moon orbiting a planet, but it could equally be a planet orbiting a star.

You can click anywhere on the demo to reposition the moon. And clicking and dragging from within the moon will display an arrow. The length and direction of this arrow gives the moon an initial velocity, which affects the overall shape of the orbit.

Newton's law of gravitation tells us that the force acting on the moon will be $F = \frac{GMm\hat{r}}{r^2}$

Where $$M$$ and $$m$$ are the masses of the planet and moon respectively; $$G$$ is the universal gravitational constant, which has a value of $$6.67384 \times \mathrm{10^{-11} m^3 kg^{-1} s^{-2}}$$; $$r$$ is the distance between the centers of each body, and $$\hat{r}$$ is the unit vector pointing along the direction or $$r$$.

The planet will also experience a force equal in magnitude but opposite in direction to the one the moon experiences. However, because the planet is much more massive than the moon, the acceleration will be much lower, and for the sake of simplicity, is ignored in this demonstration.