This is an EJS example (come with the distribution under _example directory)

VIEW or DOWNLOAD ejs xml source
then click to translate strings for selected locale.

Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop.

You can pause the simulation,then drag sun, earth or moon to different position and see what will happen!

If you want to know how it was calculated from Newton's Law, Click "load Ejs as signed applet" or "View" ejs source.