Question please: Inclined orbit rotations
Ok, so I am trying to rotate Pluto around the Sun (Pluto has a highly inclined orbit). However, when I do any combination of X and Y rotations (glRotatef(r,0.1,0.5,0)), the planet does an inclined rotation around the Sun, BUT then it switches and does some sort of figure-8 pattern and reverses its slope, instead of looking something like this: http://www.wcsscience.com/pluto/plutoorbit.gif How can I rotate the object so it looks like the path shown in the above image? I'd like to make a tilted orbital rotation. Apparently if I use some sort of ratio like the above (0.1, 0.5, etc), it does that weird pattern around the Sun. Thanks!
Let's discuss a circular orbit in the equatorial plane first. This is an orbit about a vertical axis through the sun with some radius R. So if the Y-axis is up you can rotate an angle A about R each frame (either adding it each time or caculating the current R from the simulation time). However, you need to do a translation over R first such that the planet rotates about the sun and not about its own axis. So:
- translate over (0,0,R)
- rotate about Y over A
Now this trajectory can be tilted altogether. If the Z-axis points into your screen, we can tilt about this axis. The angle will be fixed with the inclination angle of Pluto; say P. So:
- translate over (0,0,R)
- rotate about Y over A
- rotate about Z over P
That should work. An ellipsoidal orbit would require two referential axis points whereas a circular orbit requires only one. If that is what you meant please state so; we'll go into that.
Greetz,
Illco
- translate over (0,0,R)
- rotate about Y over A
Now this trajectory can be tilted altogether. If the Z-axis points into your screen, we can tilt about this axis. The angle will be fixed with the inclination angle of Pluto; say P. So:
- translate over (0,0,R)
- rotate about Y over A
- rotate about Z over P
That should work. An ellipsoidal orbit would require two referential axis points whereas a circular orbit requires only one. If that is what you meant please state so; we'll go into that.
Greetz,
Illco
Thanks Illco! With your help, I figured it out....however, something is strange. For me to get it to work I had to place all the code in exact REVERSE order! hmm....here is what I am talking about:
glLoadIdentity(); //reset
glTranslatef(0.0f, 0.0f, -10.0f); //zoom 10 units out of the screen
while(i<numSpheres) //draw all planets
{
glPushMatrix(); //save Sun position
glRotatef(spheres.angle,0,0,1); //tilt the axis
glRotatef(spheres.speedY,0,1,0); //planet rotates around the Sun (like a year)
glTranslatef(spheres.distFromSun, 0.0f, 0.0f); //translate planet away from the Sun
glRotatef(spheres.speedD,0,1,0); //planet rotates in place (like a day)
gluSphere(sphere, spheres.radius, 32, 32); //draw planet
glPopMatrix(); //restore Sun position
spheres.speedY++; //increase 'year' angle
spheres.speedD++; //increase 'day' angle
}
Shouldn't all this be the other way around....where the Day rotation comes first, then the translate, followed by the orbit-around-the-Sun rotations? I'm confused.....but it works :=)
Thanks!
glLoadIdentity(); //reset
glTranslatef(0.0f, 0.0f, -10.0f); //zoom 10 units out of the screen
while(i<numSpheres) //draw all planets
{
glPushMatrix(); //save Sun position
glRotatef(spheres.angle,0,0,1); //tilt the axis
glRotatef(spheres.speedY,0,1,0); //planet rotates around the Sun (like a year)
glTranslatef(spheres.distFromSun, 0.0f, 0.0f); //translate planet away from the Sun
glRotatef(spheres.speedD,0,1,0); //planet rotates in place (like a day)
gluSphere(sphere, spheres.radius, 32, 32); //draw planet
glPopMatrix(); //restore Sun position
spheres.speedY++; //increase 'year' angle
spheres.speedD++; //increase 'day' angle
}
Shouldn't all this be the other way around....where the Day rotation comes first, then the translate, followed by the orbit-around-the-Sun rotations? I'm confused.....but it works :=)
Thanks!
Translations,Rotations,and so on....
Yeah thats how it works... From the Parent First ie
Every thing is a child to the sun....
Every moon is a child to the planet
So we
Transform by Sun Matrix
Transform By Planet Matrix
Transform By Moon Matrix
--->
Rotate Sun
-->
Translate Plantet Distance (Now the Planets Position is the New Rotation Axis)
Rotate Planet (Day)
Yeah thats how it works... From the Parent First ie
Every thing is a child to the sun....
Every moon is a child to the planet
So we
Transform by Sun Matrix
Transform By Planet Matrix
Transform By Moon Matrix
--->
Rotate Sun
-->
Translate Plantet Distance (Now the Planets Position is the New Rotation Axis)
Rotate Planet (Day)
----------------------------http://djoubert.co.uk
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement