Archived

This topic is now archived and is closed to further replies.

Lesson 2

This topic is 6002 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Well.... we use variable rtri for rotation. We increase it by .2f to make the thing rotate. Why it works when we never make the variable smaller? Isnt there a upper bound to that variable? Has that something to do with the object making a full circle? does it get automatically back to zero whan it reaches 1.0f??? Thanks, Xewren

Share on other sites
I think all opengl do is generate a rotation matrix...which is basically a result of whole bunch of Cosins and Sines of the rotation angle...as you know, those funciton are periodic..
so rotating 60degree is the same as rotation 60 degree + n * 360 degree....where n is any integer...so it doesn''t matter what the value of the rotation angle is. I am new to opengl, like you...and here''s an interesting implication...if you let the program runs forever (and I mean very long long time), the it will eventually reach the upper bound for a floating point (which is a HUGE number indeed...but finite)...I think the program would start to behave weird after that...but that''s not really the concern...

in fact, for that program, I made a little improvement, I made an BOOL btriright variable...and
instead of rtri += 0.2f, I did:

btriright = (!btriright) ^ ((rtri >= 0.0) rtri <=180.0);
if (btriight)
rtri += 0.2f;
else
rtri -= 0.2f;

this makes the object rotate 180 degrees, the goes back and the roate back again when it''s back to 0 degree....

Share on other sites
correction:

btriright = (!btriright) ^ ((rtri >= 0.0) rtri <=180.0);

btriright = (!btriright) ^ ((rtri >= 0.0) & (rtri <=180.0));

• 14
• 10
• 9
• 49
• 12
• Forum Statistics

• Total Topics
631389
• Total Posts
2999724
×