Lesson 2
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
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....
hope this answers your question.
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....
hope this answers your question.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement