This week was the deadline I had set myself to complete the program, so - have I managed it?
Just about! I still have a couple of tweaks I want to make, and clean up some code, but effectively the program is now fully functional and as advanced as I am going to make it.
I've changed quite a bit this week, cleaning a few things up - I've implemented arrays in several places where I had lists of variables for each planet, and completely reworked my planet rotation method to fix an error where the planet would stop if the speed became too great. The main addition this week though is the implementation of "planet views", an option on the menu which allows the user to focus the camera on one planet, and the camera will follow along as the planet orbits the Sun.
Firstly, the arrays I've implemented. I've replaced four variable lists with arrays:
Previously there was a model variable for each planet, a size variable for each planet etc, but using an array instead cleans things up greatly, and hopefully improves the program speed a little as well. Example: mercSize is now size[0], venSize is now size[1] etc.
Now, onto the planet rotation. The problem was that the rotation value is given by the rotation amount times the speed factor. When that equals 360, the planet stops spinning. Example: Earths rotation amount is 18 degrees. When the speed factor is increased to 20, the rotation amount is 18x20 = 360, so the planet appears to be still when the speed of the program is at 20 times. Since each planet reaches it's fastest speed when the rotation amount = 180 degrees, I simply worked out when this was for each planet and stopped increasing the rotation amount at that point. It's all explained in the method comments, here it is:
Finally, the planet views. To implement these I had to create 8 new methods in the DrawSolarSystem class - one for each planet, called mercuryView(), venusView etc. I also had to modify the camera controls to use gluLookAt, so I could focus the camera on a position.
So, in each view method I set the camera's position, and the camera's focus, using the X,Y,Z coordinates of each planet. For the cameras position, I had to move it slightly off the X,Y,Z of the planet so you could see it - I perfected each position by assigning a 'test' variable to be added or subtracted to the Y or Z, and controlled the increments with the keyboard. These keyboard controls are now commented out, and I replaced the test variables with an actual number once I'd gotten the best camera position. I also had to set certain booleans to false so they did not affect the camera. Here is an example of the mercuryView method:
The next step was to add this method into the DrawGLScene method. Since i wanted this view to be activated when a menu option is selected, a boolean trigger is required to be set to 'true' in order for the view to be shown.
Finally, in the menu responder I simply set the boolean for the planet view I want implemented to true (in this case Mercury), and all the rest to false.
I've also included an option to return to the default view, which simply resets the camera and loops through the planetView array, setting all the booleans to false.
I'm going to post a blog following this one, with screenshots of all the planet views.
Save for some minor tweaks, thats the program pretty much finished. I'm really pleased with the end result, and delighted I've been able to implement all the features I wanted to in the desired timeframe. Onto the report!
Showing posts with label orbits. Show all posts
Showing posts with label orbits. Show all posts
Wednesday, 2 March 2011
Friday, 15 October 2010
Blog Week 2 - Orbits
This week I'm focusing on finding out more information about planetary orbits. Firstly I'd like to recap on some of the thoughts in the previous blog following this weeks meeting with Rob Lothian (my project supervisor);
Now, on to this weeks work. Following the honours project talk we had midweek, I've starting producing a Mind Map. Hopefully mainting this and the blog will prove extremely useful when it comes to writing up the final report for this project.
For this weeks research on orbits, I have been using a variety of websites - applet-magic states that a planets orbit is calculated by the balance between the gravitational attraction between the planet and the Sun, and the centrefugal force from it's movement in a approximately circular orbit.
The site details that in order to calculate a planets orbit, five main points - called Lagrangian points - are needed. It goes on to explain the math behind this, although it doesn't appear to be finished. To be honest, the math goes right over my head, and it's very difficult to understand.
On the same website - http://www.applet-magic.com/orbital.htm - they have a table of orbital velocities which also includes information on the length of a year and the orbital radii of the planets, in relation to the Earth.
One important point to note about orbits is that they are not circular, they are elliptical, and each planet has an eccentricity value between 0 and 1 - the close to 0, the more circular the orbit, the closer to 1, the more flat.
I found a useful table documenting these values for 6 of the 8 planets:
Upon further study, perhaps a better way to calculate the orbit of the planets would be to use Kepler's Law's of Planetary Motion. These are (from istp.gsfc website):
The astro-tom website explains how Kepler's third law can be used to calculate the orbits of other planets, given certain data. The equation used is;
Where P is the period of the planets (measured in Earth years), and R is the length of the semi major axis of the planet's orbit (measured in an astronomical unit, the average seperation of the Earth from the Sun).
The website demonstrates how the semi-major axis length of Mars can be calculated given it's orbital period.
On the istp.gsfc website, an alternate equation is given:
Where a is the length of the planet's semi major axis, e is the eccentricity value and the polar coordinates are (r,f).
Overall, I'm pretty confused about which equations I should be using, and even how to implement them, so this is definately something I will need to discuss with Rob.
Interesting links
http://dunnbypaul.net/ssdisckit/ - a complex digital orrery. Contains useful references.
http://cfa165.harvard.edu/software/catalogs/sao.html - Star catalog, lots of information on many stars.
http://www.exploratorium.edu/ronh/solar_system/ - Scaling calculator - calculates planet sizes and orbits given a scaled size of Sun. Contains a link to given scaled sizes of moons and various other satellites too.
http://www.burtleburtle.net/bob/physics/solar.html#ref - small digital orrery, lots of useful references
- Planetary bodies - due to the complex nature of getting the actual planets to orbit, creating different orbits for moons may be too much for this project. I think I'd like to include moons - at the very least for the Earth - but this is something that will need to be considered later in the project.
- A third scale may be required for the Sun (the first being distance between the planets, and the second the size of the planets in relation to each other). This is however something that can be looked at and played around with once the basic orbital coding is done.
- Selecting a starting date for the program will just be done using accurate data, not using any "planetary alignments", so to speak.
Now, on to this weeks work. Following the honours project talk we had midweek, I've starting producing a Mind Map. Hopefully mainting this and the blog will prove extremely useful when it comes to writing up the final report for this project.
For this weeks research on orbits, I have been using a variety of websites - applet-magic states that a planets orbit is calculated by the balance between the gravitational attraction between the planet and the Sun, and the centrefugal force from it's movement in a approximately circular orbit.
The site details that in order to calculate a planets orbit, five main points - called Lagrangian points - are needed. It goes on to explain the math behind this, although it doesn't appear to be finished. To be honest, the math goes right over my head, and it's very difficult to understand.
On the same website - http://www.applet-magic.com/orbital.htm - they have a table of orbital velocities which also includes information on the length of a year and the orbital radii of the planets, in relation to the Earth.
One important point to note about orbits is that they are not circular, they are elliptical, and each planet has an eccentricity value between 0 and 1 - the close to 0, the more circular the orbit, the closer to 1, the more flat.
I found a useful table documenting these values for 6 of the 8 planets:
| Planet | |
| Mercury | 0.206 |
| Venus | 0.007 |
| Earth | 0.017 |
| Mars | 0.093 |
| Jupiter | 0.048 |
| Saturn | 0.056 |
- Planets move around the Sun in ellipses, with the Sun at one focus
- The line connecting the Sun to a planet sweeps equal areas in equal times.
- The square of the orbital period of a planet is proportional to the cube (3rd power) of the mean distance from the Sun (or in other words--of the"semi-major axis" of the ellipse, half the sum of smallest and greatest distance from the Sun). Shown below (from this website):
The astro-tom website explains how Kepler's third law can be used to calculate the orbits of other planets, given certain data. The equation used is;
P (years)2 = R (A.U.s)3
Where P is the period of the planets (measured in Earth years), and R is the length of the semi major axis of the planet's orbit (measured in an astronomical unit, the average seperation of the Earth from the Sun).
The website demonstrates how the semi-major axis length of Mars can be calculated given it's orbital period.
On the istp.gsfc website, an alternate equation is given:
r = a(1 – e2)/(1 + e cos f)
Where a is the length of the planet's semi major axis, e is the eccentricity value and the polar coordinates are (r,f).
Overall, I'm pretty confused about which equations I should be using, and even how to implement them, so this is definately something I will need to discuss with Rob.
Interesting links
http://dunnbypaul.net/ssdisckit/ - a complex digital orrery. Contains useful references.
http://cfa165.harvard.edu/software/catalogs/sao.html - Star catalog, lots of information on many stars.
http://www.exploratorium.edu/ronh/solar_system/ - Scaling calculator - calculates planet sizes and orbits given a scaled size of Sun. Contains a link to given scaled sizes of moons and various other satellites too.
http://www.burtleburtle.net/bob/physics/solar.html#ref - small digital orrery, lots of useful references
Subscribe to:
Comments (Atom)







