PDA

View Full Version : Rotating an object x revs per second.

Robbo
01-09-2002, 08:19 AM
Hi people,

This is a question based on the fact that I am a mathematical genius who has no time for trivial problems http://www.opengl.org/discussion_boards/ubb/wink.gif

I have a frame-rate (in seconds) m_FPS. I have a target of rotating my object m_RPM times every minute. I also know the current angle of the object m_Angle.

How can I combine these such that I can calculate m_Inc on each iterate of my object and have it rotate m_RPM times a minute?

I'm not going to use WM_TIMER messages to help with this because there is a slight danger they will get queued up somewhere when the system is loaded.

Bob
01-09-2002, 10:29 AM
If you have the speed and timedelta, then just multiply them.

m_Inc = m_RPM * m_FPS / 60

You need to divide by 60 to conver M_RPM from per minute to per second.

Robbo
01-09-2002, 10:37 AM
Originally posted by Bob:
If you have the speed and timedelta, then just multiply them.

m_Inc = m_RPM * m_FPS / 60

You need to divide by 60 to conver M_RPM from per minute to per second.

Erm, let me see - that has nothing to do with 360 degrees. So if RPM is 4 and my fps is 60, we have an increment of 4.

What I want to do is find Theta, where Theta is the angle I need to rotate the object by in order that the object rotates m_RPM times per minute ( or _RPM / 60 seconds of course).

I'm too tired today to get my head around this problem! http://www.opengl.org/discussion_boards/ubb/wink.gif

Thanks anyway.

Robbo
01-10-2002, 01:34 AM
I've been at work 30 seconds and cracked it - its too easy:

lastframetime * ( m_RPM / 60 ) * 360.

if ( g_Persist.m_bPaused )
{
return;
}

float TimeTakenInSeconds = m_Timer.GetTime ();
m_Timer.Reset ();
float RevolutionsPerSecond = ( m_RPM / 60.0f );
float AngleInc = ( 360.0f * TimeTakenInSeconds * RevolutionsPerSecond );
Orientation ( GetAngle () + AngleInc, VECTOR3D ( 1.0f, 0.0f, 0.0f ) );

billy
01-10-2002, 02:55 AM
As you said: you are a genius! http://www.opengl.org/discussion_boards/ubb/biggrin.gif