Orbits

With our gravity function, it’s very easy to create a realistic-looking orbits simulation. Figure 6-3 shows a screenshot of what we’ll create: a planet orbiting a sun, against a background of fixed stars. For simplicity, we assume that the sun remains fixed. In reality, as we saw previously, both the sun and the planet will experience a gravitational force of the same magnitude but in opposite directions (with the force on each one pointing toward the other). So both the planet and the sun will move. But if the mass of the sun is much larger than that of the planet, the motion of the sun will be so small it will hardly be perceivable, anyway. That’s because F = ma again, so that the acceleration a = F/m. Thus, if the mass m is very large, ...

Get The Essential Guide to Physics for Flash Games, Animation, and Simulations now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.