Project Report 2004 Solar: A Solar System Simulator Author: Sam Morris Supervisor: Dr. Richard Banach
Project Report 2004 Solar: A Solar System Simulator Author: Sam Morris Supervisor: Dr. Richard Banach
Project Report 2004 Solar: A Solar System Simulator Author: Sam Morris Supervisor: Dr. Richard Banach
1
Contents
1 Introduction 7
1.1 Proposal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 About the report . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 Design 14
3.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.1.1 Functional requirements . . . . . . . . . . . . . . . . . 14
3.1.2 Non-functional requirements . . . . . . . . . . . . . . . 15
3.2 What is gravity? . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.3 Program architecture . . . . . . . . . . . . . . . . . . . . . . . 16
3.3.1 SI units . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3.2 Model classes . . . . . . . . . . . . . . . . . . . . . . . 17
3.3.3 View classes . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3.4 Controller classes . . . . . . . . . . . . . . . . . . . . . 23
3.3.5 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4 Implementation 26
4.1 Calculating gravity . . . . . . . . . . . . . . . . . . . . . . . . 26
4.1.1 The force between two planets . . . . . . . . . . . . . . 26
4.1.2 Moving the planets; updating the universe . . . . . . . 27
4.2 Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.2.1 Making the display interesting . . . . . . . . . . . . . . 29
4.2.2 Fake multithreading . . . . . . . . . . . . . . . . . . . 29
2
4.2.3 User interaction with Scene . . . . . . . . . . . . . . . 30
5 Results 32
5.1 A simple solar system . . . . . . . . . . . . . . . . . . . . . . . 32
5.2 More complex systems . . . . . . . . . . . . . . . . . . . . . . 36
5.3 Batch mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7 Conclusions 46
7.1 Requirements reprise . . . . . . . . . . . . . . . . . . . . . . . 46
7.2 Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.3 Project plan reprise . . . . . . . . . . . . . . . . . . . . . . . . 47
7.4 Suggestions for further work . . . . . . . . . . . . . . . . . . . 47
Bibliography 49
A Project plan 51
A.1 Description and Objectives . . . . . . . . . . . . . . . . . . . . 51
A.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
A.2.1 Desired features . . . . . . . . . . . . . . . . . . . . . . 51
A.2.2 Wishlist . . . . . . . . . . . . . . . . . . . . . . . . . . 52
A.3 Reading list . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
A.4 Project plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
B Planetary data 54
3
List of Figures
4
5.12 A demonstration of elliptical, circular and parabolic orbits.
The outermost planet has attained escape velocity by a small
margin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5
List of Tables
6
Chapter 1
Introduction
1.1 Proposal
The aim of the project was to create an interactive three-dimensional solar
system simulator, akin to a “build your own” kit. The program was to be
capable of simulating both real and artificial solar systems, as well as some
interesting astronomical phenomena.
The work was carried out with regard to creating a program that could
be adapted for teaching and demonstration; however the implementation
described in this report does not go down that road itself. Instead care
was taken to make the system extensible; for example, the use of an object
oriented language made it easier to increase module cohesiveness and overall
system flexibility.
The text of the original project proposal can be seen in Appendix A. It
contains a list of preliminary project objectives and a draft plan consisting
of a sequence of milestones and dates.
7
gravitational interactions between different bodies is presented. The system
architecture is then developed, along with an overview of the design of the
classes and modules that comprise the program.
Chapter 4 goes into detail about parts of the implementation that were
interesting or challenging, including a more detailed overview of how gravi-
tational forces were calculated and some notes about aspects of the program
concerning user interaction.
Chapter 5 presents a short tour of the finished product, constructing a
solar system consisting of a single sun and a planet. Some more interesting
systems are then demonstrated, and the chapter ends with information about
the batch mode feature of the program.
Chapter 6 contains information about the methods used to test the system
to ensure that it operates correctly. Some test results are presented and
analysed for accuracy and reliability.
Chapter 7 summarises what the project has achieved. The project is
evaluated against the requirements stated in chapter 3, and recommendations
for further work are put forward.
8
Chapter 2
2.1 Physics
It was generally believed that the Sun, Moon and other planets all orbited the
Earth in concentric circles until the 16th century, when Nicolaus Copernicus
published [Cop43]. This work put forward the idea that that the hitherto
discovered celestial bodies, Earth included, orbited the Sun. Although this
idea was not acceptable to the church of the day, it did explain certain quirks
in the motion of the planets that the old model did not, such as the retrograde
motion of the planets as they traversed the night sky.
Seventy years later, Johannes Kepler published a series of books in which
he described three laws that he had derived from the observations of his
colleague, Tycho Brahe. [Kep09] [Kep19] [Kep21] Briefly, his laws state that
planets move in an ellipse with the Sun at one focal point, that they move
faster when near the Sun’s focal point and that planets closer to the sun
orbit it at higher speeds.
Kepler’s laws did a good job of explaining what was going on in the
heavens, but because they were only derived from observational data, they
could not explain why the planets moved in the way that they did. This
would be done by another man: Isaac Newton.
In [New87], Newton defined the principles and laws of motion and Univer-
sal Gravitation—“Universal” because Newton realised that his laws applied
equally to objects in the heavens (the moon orbiting the earth), and objects
on the Earth (the famous apple falling from its tree). Until then, it was be-
lieved that the two domains were entirely separate and governed by different
physical laws.
9
Newton’s laws allowed the motions of the planets to be predicted to a
hitherto unseen degree of accuracy. It is possible to plot orbits to take space-
craft to other planets and beyond, all with the aid of Newton’s 18th century
mathematics.
Of course, the story does not end there. Newton’s laws do not account for
the orbit of Mercury; it happens that Mercury’s perihelion (point of closest
approach) moves each time it orbits the sun.[Wud98] This was not explained
until the advent of Einstein’s Theory of General Relativity. The cycle con-
tinued with Relativity being usurped by String Theory/M-Theory[Gre00].
Nevertheless, Universal Gravitation remains the first scientifically accurate
description of the motion of the planets and as such, is worth investigating.
2.2.1 Celestia
Celestia[cel] is a highly advanced planetarium; written for KDE in C++, it
allows the user to visit and examine data for over 100,000 stars, planets and
other interesting objects throughout the Milky Way. It comes with detailed
texture maps of famous stellar objects and is capable of producing images of
very high quality (see Figure 2.1).
Celestia is an extremely formidable project; however it does not use grav-
ity to simulate the motion of stellar objects; as far as the physics are con-
cerned, Celestia is an orrery—a mechanical model of the solar system.
2.2.2 Orrery
The ironically named Orrery[orr] is a gravitational simulation of a solar sys-
tem; the user can play and pause the simulation, reversing time if desired;
however time always runs at a fixed, rather slow rate. The gravitational con-
stant (see page 15) is not the same as that of our own universe. This makes
simulation of a “real” solar system difficult, although it does make the pro-
gram more intuitive in some respects; for example, the unit of distance is the
pixel (at the default zoom level). See Figure 2.2.
Orrery is a Java applet, and as such can be embedded in a web page.
This makes it convenient to use as a teaching tool. However the quality
of animation is quite poor as the frame rate is low. It also only calculates
gravity in two dimensions.
10
Figure 2.1: Celestia displaying the Moon, Apollo 11 and Earth.
11
Figure 2.2: Orrery demonstrating an asteroid belt.
Figure 2.3: JPL Solar System Simulator showing a view of Io from Europa,
Jan 1977.
12
2.3 Platform
The following decisions were made regarding the platform upon which the
project would be developed and run.
13
Chapter 3
Design
3.1 Requirements
This section outlines the implementation requirements for the simulator.
Since it was not expected for all the requirements to be completed due to
time constraints, they were prioritised so that the important parts of the
program could be written in the time available.
These features are summarised in Table 7.1 on Page 46.
• The program must provide visual aids[R8] for locating planets, since if
everything was drawn to scale, it would be impossible to see anything
(see Section 3.3.3).
• The user interface must allow the user to edit the universe[R9]; that is,
allow them to create new planets and edit existing ones.
14
• It must be possible to save[R10] the state of the simulation to a file on
disk and restore it[R11] in a subsequent run of the program. This will
allow some interesting example solar systems[R12] to be distributed
with the program.
15
Newton’s Second Law of motion and two of the kinematic equations, where
m is the mass of the particle, a is its acceleration, u is its initial speed, v
is its final speed, t is the amount of time over which we are calculating the
particle’s movement and s is the final relative displacement of the particle:
F = ma v = u + at s = ut
Solving for s will give the position of the particle after t seconds have
elapsed.
Note that since the distance term in Equation 3.1 is squared, it will domi-
nate the overall result at great distances. This reveals a possible optimisation.
Using the values from Table B.1 and Equation 3.1:
• The force between Earth and Jupiter is between 1.90 × 1018 N and
8.75 × 1017 .
The force that Jupiter, the second most massy body in the solar system,
exerts on the Earth is on average four orders of magnitude less than the force
exerted upon the Earth by the Sun. The next massiest body, Saturn, has
one third the mass of Jupiter, and is twice as far from the sun—it will have
even less of an effect on the Earth. It seems that it is not strictly necessary
to simulate the affect of every particle in the universe on every other particle
after all. However, given the speed of today’s computers there is no harm
in doing so, especially since the planets can be treated as as point masses,
instead of simulating each of their atoms.
16
3.3.1 SI units
It was decided to use standard SI units throughout the program, in order
to make creating realistic models of our, and other, solar systems easier.
Distance is measured in meters, mass in kilograms, time in seconds and force
in Newtons.
Vector
Vector (see Figure 3.1) moddled a collection of, and was constructed from,
three floating point numbers. It was used to represent planet positions and
velocities, the three components corresponding to the three spacial dimen-
sions. A Vector could also be constructed from a libxml++ node; this was
done when loading a saved simulation into memory.
Vector
-x: vector_t
-y: vector_t
-z: vector_t
+addAttrsToXmlElement(node:xmlpp::Element)
+dotProduct(vector:Vector): vector_t const
+crossProduct(vector:Vector): Vector const
+toUnitVector(): Vector const
+getX(): vector_t const
+getY(): vector_t const
+getZ(): vector_t const
+setX(x:vector_t)
+setY(y:vector_t)
+setZ(z:vector_t)
+getTheta(): double const
+getPhi(): double const
+getPsi(): double const
+getMagnitude(): vector_t const
Vector was also used to represent colours, since OpenGL considers a colour
to be the standard triple of red, green and blue components.
17
It was decided to create a specialised class to represent a triple of floating
point numbers, rather than to make use of C++’s STL template, std::vector,
because there would be no need to model the situation in a higher number of
dimensions and because of the additional complexity of template program-
ming.
A Vector had accessor and mutator methods for each of its three compo-
nents. Additional methods were defined to manipulate Vectors in ways that
would be useful within the context of the simulation:
crossProduct Returned the cross, or vector, product of two vectors. The
result was a third vector that is orthogonal/perpendicular to both vec-
tors. It was useful for calculating camera placement values.
getMagnitude Returned the length of a vector. It was calculated by sum-
ming the squares of a vector’s components, and taking the square of
the result.
toUnitVector Returned a new Vector with a length of 1, that pointed in
the same direction as the old one. This was done by dividing each
component of the vector by the vector’s magnitude.
dotProduct Returned the dot, or scalar, product of two unit vectors. This
was the cosine of the angle that would have been made between them
if they shared a common start point. It was useful for calculating the
intersection of a ray and a planet (see page 21), for visibility calculations
and for calculating the “absolute” angle components of a Vector.
getTheta, getPhi, getPsi These were used while determining the gravi-
tational force between two Planets. They returned the angle between
a Vector and the x, y and z axes, respectively.
C++’s operator overloading capabilities were used to provide an elegant
way to add and subtract Vectors, and to multiply them by scalar values.
Planet
For the purposes of the simulation, all heavenly bodies were Planets (see
Figure 3.2). A Planet had a mass, a radius, and a name. Vectors were used
to represent a planet’s position, velocity and colour. All these properties had
corresponding accessors and mutators.
A Planet could be constructed from a libxml++ node. This was done
while loading a saved simulation into memory.
Finally, the getGravity method returned a Vector representing the attrac-
tive force due to gravity, in Newtons, between two instances of Planet.
18
Planet
-radius: floar
-mass: float
-position: Vector
-velocity: Vector
-colour: Vector
-name: std::string
+setPosition(position:Vector)
+getPosition(): Vector const
+setVelocity(velocity:Vector)
+getVelocity(): Vector const
+setColour(colour:Vector)
+getColour(): Vector const
+setMass(mass:float)
+getMass(): float const
+setRadius(radius:float)
+getRadius(): float const
+setName(name:std::string)
+getName(): std::string const
+getGravity(planet:Planet): Vector const
Universe
A Universe (Figure 3.3) was a collection of Planets. It was constructed from a
filename which, if non-empty, caused a saved simulation state to be restored
from disk.
A Universe ran in one of two modes. Both depended on the repeated
calling of think, the method where the states of all the planets were examined
and updated.
19
Universe
+planets: std::vector<Planet>
-running: bool
-thinkConnection: SigC::Connection
-timeMult: double
-timeStep: double
-timer: Glib::Timer
-elapsedTime: long double
-timeIntegrationThreshold: int
+saveToFile(filename:std::string) const
+add(p:Planet)
+getRunning(): bool const
+setRunning(running:bool)
+think(): bool
+getTimeMult(): double const
+setTimeMult(timeMult:double)
+getElapsedTime(): long double const
+collideRaySphere(rStart:Vector,rDirection:Vector,sPosition:Vector,sRadius:double): bool const
-doGravity(deltaT:double)
20
over the contents of the planets collection, creating a node in the DOM tree
for each one it found.
collideRaySphere calculated the intersection of a ray with a sphere. It was
used to work out which planet the user had clicked on during the editing of
the Universe.
getElapsedTime simply returned the total running time of the simulation,
in simulated seconds. It was used by the MainWindow class to display the
status of the simulation to the user.
21
Gtk::GL::DrawingArea
Scene
-exaggeration: exaggerateMode
-zoomDistance: double
-followIterator: std::vector<Planet>::iterator
-idleConnection: SigC::Connection
-timer: Glib::Timer
-frameCount: int
-universe: Universe
+getExaggerateMode(): exaggerateMode const
+setExaggerateMode(exaggeration:exaggerateMode)
+getZoomDistance(): double const
+setZoomDistance(zoomDistance:double)
+getCameraPosition(): Vector const
+followNextPlanet()
+followPrevPlanet()
-on_realize()
-on_configure_event(event:GdkEventConfigure): bool
-on_expose_event(event:GdkEventExpose): bool
-on_visibility_notify_event(event:GdkEventVisibility): bool
-on_button_release_event(event:GdkEventVisibility): bool
-on_button_press_event(event:GdkEventButton): bool
-on_idle(): bool
22
3.3.4 Controller classes
The interface mock ups in this section were created with GLADE, a GTK+
user interface design program.
MainWindow
Gtk::Window
MainWindow
-universe: Universe
-scene: Scene
23
At the top of the window was a menu bar which allowed the user to save
the state of universe to disk; add new planets to the universe; and adjust
display parameters, such as the planet chosen for Scene to follow, and the
method to use for the exaggeration of planet sizes.
Below this is a toolbar, giving quick and easy access to commonly used
functions. The first two buttons on the toolbar were toggle buttons—only
one can be pressed at a time. By changing the state of these buttons, the user
could enter Edit or Run mode–this is the mechanism by which the simulation
is stopped and started. The other buttons were to control the simulation time
rate and the Scene zoom level.
Underneath was the scene control. When the program was in Edit mode,
the user could click on a planet to print up a PlanetWindow that would let
them edit the properties of their chosen planet. The scene control did not
interact with the user in any other way.
Finally there was a status bar at the bottom of the window. This was
used to display the simulation’s elapsed time and current time rate, as a
multiple of real time.
PlanetWindow
When the user clicked on a planet in Edit mode, he was presented with the
PlanetWindow dialog. See Figure 3.7.
Gtk::Dialog
PlanetWindow
-planet: Planet
+updatePlanet(p:Planet) const
+run(): int
24
Figure 3.8: PlanetWindow mock up.
the Planet itself, would be tedious and error prone. Therefore, the decision
was made to create an updatePlanet method, which would alter the properties
of the specified Planet to match the state of the controls in the PlanetWindow.
The caller would make this call conditional on run returning a non-zero value,
signifying that the user pressed the “Ok” button.
3.3.5 Modules
The remaining modules were simple, being concerned with setting up the
controller class in a normal run of the program, performing tests of the
Model classes and converting various data types to strings for display.
main Entry point for the program. Also used to perform tests on the Model
classes.
25
Chapter 4
Implementation
26
Figure 4.1: Calculating the x component of a vector.
1. If running in batch mode, set deltaT to the fixed time step value (e.g.
1 hour). Otherwise, set deltaT to the time elapsed between this call to
think and the last one, multiplied by the time rate factor.
27
(f) Update the velocity of p0 , ~v to equal ~a × deltaT .
(g) Update the position of p0 to equal its old value added to ~v ×deltaT .
This approach worked very well as long as the value of deltaT did not
become too large; this would happen when the user set the simulation to run
at 1,000,000 its normal rate. It broke down at this point because the time
step became to coarse for the above method to generate an accurate result.
It was decided to devise an algorithm that divided up large chunks of time
into many smaller chunks, processing a set of gravity calculations for each
one. The chunk size was known as the time integration threshold, because
the algorithm approximated the process of integrating deltaT down to an
infinitely small size for each set of calculations.
The algorithm ensured that no matter how high the user set the time
rate multiplier, the universe’s internal time step would never rise above the
value of the time integration threshold. The threshold was set to 12 hours by
default.
3. Perform the above gravity calculations, using deltaT as the time step.
28
4.2 Interaction
4.2.1 Making the display interesting
As explained in Section 3.3.3, if all the objects in a typical solar system were
drawn to scale, the scene would seem very empty. It was necessary to provide
visual aids so that the user would be able to see the planets, even while at a
zoom level at which they would normally be invisible.
Four methods were implemented:
Planet bounding box If exaggeration was disabled, a box was drawn sur-
rounding each planet as an indicator of the planet’s position. The box
1
remained at a constant on-screen size of 128 of the width of the window.
Velocity indicator A line was drawn extending from the centre of each
1
planet with a constant on-screen length of 16 of the window width.
This line pointed in the direction in which the planet was moving.
29
Buried deep in the bowls of GTK+ lies the event loop, which is run con-
tinuously whenever a GTK+ window is open. The event loop is responsible
for waiting on incoming events and dispatching messages that cause an ob-
ject’s signal to be fired. Glib provides an idle signal, which is fired whenever
the event loop has no other pending messages to deal with.
This signal was used to make the program appear perform several tasks at
once (updating user interface, running the simulation and redrawing scene),
without having to resort to using, thereby and dealing with the enormous
complexities of, multithreading. This is because methods connected to a
signal are called synchronously.
The think method of Universe and the on idle method of Scene were both
connected to the idle signal.
Define the ray as a starting point, and a unit vector to represent the
direction:
R0 = [X0 , Y0 , Z0 ] Rd = [Xd ,d
Yd , Z d ]
then we can work out all points in the ray as follows, where t > 0.
Rt = R 0 + R d × t
1
zoomW idth is the distance from the centre of the universe to the edges of the scene.
30
A sphere is defined by a centre point and radius.
Sc = [Xc , Yc , Zc ] Sr
[Xs , Xy , Xz ]
The following equation implicitly defines all points on the surface of the
sphere.
31
Chapter 5
Results
Clicking on the planet opens up a dialog box that allows the user to adjust
the planet’s name, mass and other properties (see Figure 5.2).
32
Figure 5.2: Editing the properties of the planet.
33
This planet is made into the system’s sun. The simulation does not
distinguish between suns, planets, moons and other heavenly bodies.
The velocity of the planet (24000m/s) q was calculated using the formula
for the velocity of a circular orbit: v = GM r
. The system is now ready to
be run! (Figure 5.5)
The simulation is set into motion upon the click of the Run button. The
time rate can be adjusted in factors of 2 or 10 by pressing the appropriate
toolbar buttons.
After a few years of simulation time, it looks like Figure 5.6. Note the
line sticking out of the planet. This indicates the direction it is heading in.
The Save item in the Universe menu allows the universe to be written to
a file. The universe is serialised to XML, like this:
<?xml version="1.0"?>
<solar>
<planets>
<planet name="THE BURNINATOR" radius="6.95e+08" mass="1.98e+30">
<colour x="0.991272" y="1" z="0"/>
<position x="0" y="0" z="0"/>
<velocity x="0" y="0" z="0"/>
</planet>
34
Figure 5.5: The system has been set up.
35
<planet name="Forbidden Planet" radius="3.43e+06" mass="6.42e+23">
<colour x="1" y="0.850828" z="0.850828"/>
<position x="-2.2794e+11" y="0" z="0"/>
<velocity x="0" y="23967.8" z="0"/>
</planet>
</planets>
</solar>
Figure 5.7: The four innermost planets of our own solar system.
Figure 5.8 shows a model of our entire solar system. The exaggeration
of planet sizes has been disabled from the View menu, so the boxes used to
indicate planet positions are visible.
36
Figure 5.8: Our complete solar system.
This output can easily be processed by a shell script and the results
plotted by Gnuplot[gnu].
37
Figure 5.9: Plot of the orbits of a binary star system.
38
Figure 5.10: A rogue planet with a large mass enters our solar system. The
extra velocity it gives to the planets allow them to escape the pull of the Sun’s
gravity. The interloper continues almost unaffected on its south-westerly
journey, whilst one of the planets in our solar system was accelerated to
escape velocity.
39
Figure 5.11: Three dimensional plot of a highly ornamental system. Three
sets of Earth-like masses orbit a sun on two planes.
40
Figure 5.12: A demonstration of elliptical, circular and parabolic orbits. The
outermost planet has attained escape velocity by a small margin.
41
Chapter 6
6.1 Strategy
The majority of the testing that the program underwent occurred during
development. The classes described in Chapter 3 were developed separate
from one another. A test harness was constructed for each class, which was
used to perform a number of test suites when implementing new features.
This methodology made it possible to be reasonably certain that the indi-
vidual components of the program were working correctly before they were
integrated together.
If a bug condition was discovered during integration, a new test was added
to the test suite for that class, so that any future regressions of the bug fix
would be detected and repaired quickly.
42
{8.66025, 0, 5}; psi = 60 degrees
{9.39693, 0, 3.4202}; psi = 70 degrees
{9.84808, 0, 1.73648}; psi = 80 degrees
{10, 0, 6.12303e-16}; psi = 90 degrees
...
Planet.
Sol {mass=1.99e+30, radius=7.1492e+07, position={0, 0, 0},
velocity={0, 0, 0}, colour={0.5, 0.5, 0.5}}
Jupiter {mass=1.9e+27, radius=7.15e+07, position={7.78e+11, 0, 0},
velocity={0, 0, 0}, colour={0.5, 0.5, 0.5}}
Earth {mass=5.98e+24, radius=6.38e+06, position={1.496e+11, 0, 0},
velocity={0, 0, 0}, colour={0.5, 0.5, 0.5}}
43
and comparing it observed astronomical data. In some cases this would not
be sufficient, however, as Newtonian Gravitation cannot account for some of
the phenomena in our solar system (eg, the precession of the perihelion of
Mercury on page 10).
44
Press Reverse button. Expected: planets reverse direction. Time in sta-
tus bar counts backwards. Pass.
45
Chapter 7
Conclusions
The final program fulfilled all the original high and medium priority re-
quirements. The two low priority requirements that were dropped were [R15]
46
and [R19]. Although the creating the facility to export animations would
have been an interesting challenge, it was not a core function of the program
and so it was thought that time would be better spent elsewhere. Making
the graphics pretty was not attempted for the same reason.
Although the progress of simulating gravity worked in three dimensions,
the Scene only presented a top-down, orthographic projection of the uni-
verse. If time had allowed it would have been interesting to switch to a 3d
perspective projection.
7.2 Learning
The process of designing and implementing the program was very informa-
tive. I have learned how to create GUI programs using the GTK+ toolkit
in combination with OpenGL, and how to simulate a physics system at a
speed independent from that of the computer it runs on. It was enjoyable
to develop the universe processing algorithm without going in to the messy
business of solving integrals and constructing differential equations.
47
about a selected planet; the data could be transformed from the saved
XML with an XSLT style sheet.
48
Bibliography
[ea98] W3C DOM Working Group et. al. Document object model (dom)
level 1 specification. 1998. http://www.w3.org/TR/1998/REC-
DOM-Level-1-19981001/.
49
[kde] Kde desktop environment. http://www.kde.org/.
50
Appendix A
Project plan
A.2 Features
A.2.1 Desired features
• A graphical program that simulates the interactions between many bod-
ies due to the effects of gravity.
51
simulation and alter parameters at any point, as well as adjusting the
rate at which time flows.
• The user should be able to save the state of the simulation to disk and
restore it later. This should allow for some interesting example star
systems to be distributed with the program, such as a realistic model
of our inner solar system, or a model of a planet orbited by a moon,
itself being orbited by another moon. Such examples could also be used
to demonstrate astronomical concepts such as a binary star system, the
path of a comet, or a slingshot manoeuvre.
A.2.2 Wishlist
• The user could be able to go back in time to adjust a parameter, then
continue the simulation from that point for the generation of “what
if?” cases.
Research Performed before and during the design and implementation stages
as required. Since it is easier to learn by doing rather than reading, I
hope to knock up a few prototypes as I work out how best to simulate
the interaction between planets.
Design I would like to have the overall system design finished by the 27th of
October. Details can be filled in as necessary after this date, but most
52
aspects of the operation of the system (as outlined under Features,
above) should be fixed by this date in a Specification document.
Poster This leaves two weeks to prepare materials for the project poster,
which is due in on November 14th. . .
Seminar . . . and the seminar, which will be between November 17th and
28th. It would be nice to have a working prototype of the simulation
to present at this time.
Report: first draft Should contain background information about the project,
my research, and be reasonably complete with respect to events occur-
ring in semester 1. Should be ready about the 7-15th of December.
Testing Coding will continue after the start of the second semester, which
is when I intend to start formal testing of the program. Testing and
coding will overlap to some extent. I will put a provisional date of
early February for the end of the major part of the implementation.
This leaves a month to hunt down the remaining bugs and polish the
program off.
Demonstration I can also use this time to prepare for the formal demon-
stration of the project, which will occur around the 10-24th of March.
Final report After the demonstration I will have about three weeks to com-
plete my report, including the analysis of how the system operates com-
pared to the original specification. The final report is due on the 5th
of May.
53
Appendix B
Planetary data
The following data were used to construct the example solar systems used to
demonstrate the project. They were sourced from [Ham].
54