PDA

View Full Version : how to rotate like earth?



Hideki
07-05-2004, 10:08 AM
Hi,

Im trying to one thing thats too difficult ...
how to rotate like earth .. i dont want to know a rotate in axis ...
for example .. when we talk about graphs you can see what im talking about

imagine an axis x with minimum 0 and maximum 5 ... if we do a half-rotate 5 will become -5.
i dont want this, i want 0 in the position of 5 and 5 in the position of 0.

thanks

ZbuffeR
07-05-2004, 10:22 AM
I did not understood a word :p
Well I will try to be creative and interpret your title. Do you want something like :

glloadidentity;
rotate X axis (an horizotal one) to 23.45 to reflect the earth axial tilt;
rotate Y axis (the vertical one) to a value depenting on the time linearly (ie 24 hours for 360);
draw earth;

Hideki
07-05-2004, 10:38 AM
hrrmm . not that ..

look this image i did .. there is a diff between both when you rotate 180 degrees.

I know how to do the first .. but i want the second.

thanks

http://www.emorock.net/outros/untitled.gif

ZbuffeR
07-05-2004, 11:02 AM
Ahhhh much clearer !

So the initial triangle has its bottom left vertex aligned on yx (0;0). You just have to shift it a bit.

1) may be done like this :
glPushMatrix();
<draw triangle>
glRotate(180, 0,0,1);
<draw triangle>
glPopMatrix();

2) may be done like this :
glPushMatrix();
glTranslate2f(-1.0f,0.0f); // if the triangle is about 2 in width. Else adjust for your setup.
<draw triangle>
glPopMatrix();
glPushMatrix();
glRotate(180, 0,0,1);
glTranslate2f(-1.0f,0.0f); // if the triangle is about 2 in width. Else adjust for your setup.
<draw triangle>
glPopMatrix();

Untested, but should not be too far from the truth.