|
Computer Graphics |
Fall 2000
|
Computer Graphics
Homework 11
6 hours
Copyright © 2000 David C. Banks
Read the OpenGL Programmer's Manual, chapter 3 (Viewing), especially the section at the end on Manipulating the Matrix Stacks.
The vertices of a planetary body can be transformed like this:
p = M*p
where M is the current transformation matrix that results from performing glRotate, glTranslate, glRotate corresponding to the planet's spin, orbital distance, and orbital velocity.
The Earth's moon would be transformed by
p = M1 * M2 * p
where M1 is the Earth's transformation and M2 is the moon's.
Make a diagram (preferably in hand-edited Postscript) of the transformation graph associated with the inner planets of the Solar System, including their moons. This should look like the graphs drawn in class on the chalkboard. The Earth has one moon; Mars has two. Put the graph on your Web page and in your notebook.
When you glPushMatrix(), OpenGL makes a copy of the current matrix and saves it for later popping. If the Earth had n moons, then for each moon you would push the transformation that operates on the earth, apply transforms for mooni, draw mooni, and then pop back to the previous state.
Put the inner planets in orbit using OpenGL. Here is some data for the size, orbit, and rotation of these planets. 1 AU = 149,597,870 km.
average body's orbit's body's
distance radius year rotation
Body (AU) (km) (days) (days)
------- ----------- ------ ------- ---------
Sun 0.0 695990 0.0 30
Mercury 0.38709893 2439 87.97 58.6
Venus 0.72333199 6052 224.7 -243
Earth 1.00000011 6378 365.26 0.997
Mars 1.52366231 3389 687 1.02
Here is data for the moons of the Earth and Mars. I couldn't find information for their spin velocities. Maybe you can.
average orbit moon
planet.moon distance period radius
(1000km) (days) (km)
----------- --------- ------- ------
Earth.Moon 384.40 27.322 1737
Mars.Phobos 9.38 0.319 11
Mars.Deimos 23.46 1.262 6
Write functions
void sun (float time) void mercury (float time) void venus (float time) void earth (float time) void earthMoon (float time) void mars (float time) void marsPhobos(float time) void marsDeimos(float time)
that produce the proper movements when they are invoked in the correct order. Or even better, create a class Body with member variables radius, orbitalDistance, orbitSpeed, rotationSpeed, diffuseColor, textureMap, etc. Apply rotations using an angle k*speed*(time-offset). Each body will have its own angular offset (starting them all at zero makes the planetary system line up in a straight line initially). Increasing the value of k makes the animation speed up.
Put images/animations on your Web page.
Because the sizes, distances, and speeds vary so much among the bodies in the solar system, you can't very easily see all the objects in a single image. "Improve" on reality by adjusting these parameters in a nonlinear fashion.
rotationSpeed = rotationSpeedexponent; orbitDistance = orbitDistanceexponent; orbitSpeed = orbitSpeedexponent; radius = radiusexponent;
If the exponent is nearly 0, all the values end up being identical. If the exponent is nearly 1, all the values end up being like reality. Experiment with values in between. Your exponent for rotationSpeed may be different than the exponent for radius, and so forth.
Put images/animations on your Web page showing the fake sizes. Link to your code.
Since the planets are satellites of the sun, and moons are satellites of the planets, you should make a recursive call in your code to capture this relationship.
Create a C++ class that stores the number of satellites a body has, pointers to the satellite objects, and member variables with the body's rotation rate, radius, distance from its parent, and orbit rate. You will use the orbit rates for the rotations, and the distance for a translation. A method like body.update(float time) will update the position of a body using the current time step, and then will call the body.satellite[i].update(time) method for each of the body.numSatellites satellites belonging to the body.
Put images/animations on your Web page. Link to your code and documentation (but not to your copy of the textures).
Use gluPickMatrix to allow a mouse click to select a body. When the body is selected, change its color. Then make the camera follow the body's motion so that it remains in the image rather than drifting out of it. Disable the automatic camera tracking when the mouse is pressed again.
Model the entire solar system.
Here are some links for
data. Search the Web for more.
Overview.
NASA.
Planets.
Satellites.
Texture maps.
More textures.
Data.
More data.
Put images/animations on your Web page. Link your code/documentation (but not your textures -- the README will describe where to fetch them and how to convert them for your program to use).
Model the entire solar system, but use Open Inventor rather than OpenGL. Use the SoWriteAction to generate a .iv file. Convert it to VRML. Put it on your Web page.