• Advertisement
Sign in to follow this  

calculate the time... traslation of object 5mm in 1 sec..

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys..

I am stuck at this point... I couldn't figure it out how to calculate the feedrate and how can I impliment. I have tried alot but now don't know what to do..

Actually the problem is .. I want to translate one object that will cover 5.555 mm in 1 sec.. so it means that 100mm in 18 sec..
I have obtained the results that is 100mm in 18sec but when the fps is 59...

but when I start my simulation, the fps goes to 14... then the object moves very slowly, it does not covers 100mm in 18 sec.. it takes too much time..

my code is..






void ModelRotation_IdleFunc(void)
{
CurrentTime = clock();
float timeInterval = CurrentTime - PreviousTime;

C_TOOL_X += (5.5555f/(1000.0*3.24*timeInterval*0.001f));

if(C_TOOL_X > 100.0)
C_TOOL_X = C_TOOL_X - 100.0;

PreviousTime = CurrentTime;

glutPostRedisplay();
}



kindly guide me how can i do this... I think fps must be considered in my code.. but how ?

Share this post


Link to post
Share on other sites
Advertisement
A basic fps independent movementspeed example:
float stepsize = elapsedTimeSinceLastFrame * speed;
position += stepsize;

This example does work, just try to adjust it so it fits your x meter / second.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement