JavaScript Physics Orbiting Objects
Finally I’ve found a decent example of a JS physics simulation. This example by Jorn Zaefferer shows how to model a bouncing ball with vector arithmetic.
I’ve tweaked this code to build a simulation of objects orbiting about a point. The only key difference is that the gravity for each ball is recalculated relative to the “sun” with each animation step. I’ve also removed collision detection with the window borders.
There’s a live example here. View the source for the.. er.. source.