HTML and CSS Reference
In-Depth Information
Figure 12-2. When worlds collide
Orbiting
Just to show you how realistic this gets, we will set up a simple planetary system with a sun and planet.
Make a large sun with a mass of 10,000, and a planet with a mass of 1. Then move the planet a distance
away from the sun and give it some velocity perpendicular to the line between it and the sun. The setup
looks something like Figure 12-3.
Figure 12-3. Setting up the solar system
If you get the masses, distance, and velocity just right, you should be able to get the planet into orbit (after
some trial and error). You'll find a working example of this in document 04-orbit.html . All you see here
is the setup code near the top of the script. We create two particles, a big one for the sun, and a small
earth to orbit it; the rest of the code remains the same:
 
Search WWH ::




Custom Search