space and time
In the lessons with spinning cubes or flags...we kinda increment the rotation angle at every run of the program, then redraw the frame...okay...fine...but I realized that the speed which the cube spin in my Pentium 400 Celeron (ATI 3D Card) is obviously slower than in my AMD 1.4 GHZ (GForce)...sure that''s to be expected...but how can we go about setting a constant angular velocity for every system (of course, I am not talking about achieving it with a slow system...liek a p1 with cheap-ass graphic board...)
but since some computer execute more instruction per unit time...I don''t think that just doing xrot += inc; is a good way to go...say I want the cube to spin 360 degress in half a minute...what would I do?
well it's pretty easy if you know the speed at which you want to rotate.
for instance if you want 360 / minute just break it down to degrees / milisecond.
then on each compute cycle get the system time and compare it with system time of the same point in the program on the last compute cycle. Then multiply the difference between those times in miliseconds with your degrees/milisecond ratio to get the nuber of degrees to rotate your object.
i think
-me
Edited by - Palidine on January 17, 2002 7:56:47 PM
for instance if you want 360 / minute just break it down to degrees / milisecond.
then on each compute cycle get the system time and compare it with system time of the same point in the program on the last compute cycle. Then multiply the difference between those times in miliseconds with your degrees/milisecond ratio to get the nuber of degrees to rotate your object.
i think

-me
Edited by - Palidine on January 17, 2002 7:56:47 PM
Timing functions :
Windows- clock() or timeGetTime() or QueryPerformanceCounter()
Unix- gettimeofday()
Windows- clock() or timeGetTime() or QueryPerformanceCounter()
Unix- gettimeofday()
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement