Question

I want an object to smoothly stop at a specified point. I have the initial velocity, V0, of the object, the end velocity (which is set to 0), V1, and the distance, d, required to reach the destination. V1 and V0 are measured in radians per frame, and d is also measured in radians.

I've tried using the following formula:

a = (V0*V0 - V1*V1) / (2.0 * d);

But it always seems to overshoot its target.

Edit: Essentially, I have a wheel that starts spinning at an initial velocity of V0. The wheel has to do a certain number of spins before stopping at a specified location. The distance, d is the amount of radians required to do the specified amount of spins and stop at a specified location. The velocity is number of radians per frame.

Was it helpful?

Solution

We have enough information now for an educated guess.

The formula is correct, but only in the ideal case, where the length of an iteration time is very small. My guess is that in your loop you are updating position before velocity, so that for that time period the wheel can advance with undiminished velocity, and you overshoot. (If you updated velocity before position, you would undershoot.)

You can either make your frames shorter, which will make the overshoot less severe, or you can modify the formula to eliminate it:

a = (V0*V0) / (2.0 * d - V0*tdelta);

where tdelta is the length of time of a single frame. (I've assumed V1=0.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top