Newtonian gravity (2) - solar system demo
Previous page: Introduction.
This is part two of a series of three pages describing my Newtonian gravity demo
program.
The "inner solar system" scenario in the Newtonian gravity demo models
the sun and the four inner planets (Mercury, Venus, Earth and Mars). It gives
a pretty accurate account of some physical properties:
- The planets' relative distances from the sun
- The planets' relative velocities
- The planets' sizes relative to the size of the earth
- The planets' orbital properties, especially inclination and eccentricity
However, if this was a perfect scale model then all you would see is the sun.
The following properties have been exaggerated:
- The planets are much bigger than they should be, relative to the sun
- The planets are much closer to the sun than they should be, relative to the size
of the sun
- The whole demo is on fast-forward - one demo second is equivalent to 20 real-world
days
- The scene contains a bit of ambient light so that you can see the half of each planet
that is not in direct sunlight
One more inaccuracy that's a bit annoying: when the planets pass behind the
sun they actually appear in front of it! I guess that WPF/DirectX's geometry
calculations get messed up by the astronomical distance scales and extremely small
angles.
The most interesting thing about this demo is the way that it initializes the planets.
Remember, the idea is to create the planet in an initial position with an initial
velocity and let the laws of gravity do the rest. The trick is to choose the
initial position and velocity so that our model planet will then follow the correct
real-world orbit. Orbital mechanics is a bit complicated. As you may
know, the planets' orbits are ellipses with the sun at one of the focii.
Orbits are defined by six properties:
- Semi-major axis - the size of the ellipse
- Eccentricity - how 'stretched' is the ellipse; 0 is a perfect circle
and 1 would be a straight line
- Inclination - the tilt of the orbit relative to the ecliptic plane
- Argument of periapsis - the alignment of the inclination (is the tilt 'axis'
at the ends or in the middle of the ellipse?)
- Longitude of the ascending node - the alignment of the whole orbit relative
to a fixed star
- Mean anomaly - describes the position of the body in the orbit at a given
moment in time
So the first step was to lift these values from the excellent pages on
Wikipedia. Then I was helped (read rescued) by a
web utility that handles the tricky mathematics for converting these
values into an initial position and velocity. I ported the Javascript code
to C# and used it in my application with permission of the author. (I was
pleased to see that his algorithm for converting mean anomaly to eccentric anomaly
was exactly the same as the one that I derived years ago when I wrote my first Hohmann
orbit demo!)
When you run the program, click and drag with the mouse to view the scene from different
angles. Try viewing straight along the ecliptic plane: you will see how the
planets (especially Mars) drift slightly 'up and down' as they go around
(this is the property of inclination). Zoom in on Mercury and notice the great
eccentricity and speed of its orbit.
Next page: The Hohmann transfer orbit demo.