I am rotating an object with constant deceleration. I want the object to stop at a predetermined location at given time t. The object stops at the correct location when I do not take time in consideration using the equation acceleration = -(velocity * velocity)/(2 * spinTo) or a = (v22 – v12) / (2 ?s)
However this equation does not allow me to incorporate the amount of time I want the deceleration to take. To incorporate time I am using the equation
acceleration = (2 * spinTo - (2 * velocity() * time))/(time * time) or a = (2 ?s – 2 v1 ?t) / (?t)2
This produces inconsistent results and my object does not rotate to the correct location. I'm fairly confident my math is correct. What could be causing the inaccuracies when time is taken into consideration? My rotation code looks like this
void WheelSpinEffect::HandleRotation(float degree, float velocity, float accel)
{
float oldVel = velocity;
float dt = 1.0f/GraphicsDevice::GetRefreshRate();
velocity += (accel * dt);
degree += (oldVel + velocity) * 0.5f * dt;
Rotate(degree);
SetVelocity( velocity );
}
Any help is greatly appreciated.