# Stopping distance

## Recommended Posts

Spidyy    185

Hello there.

Something that surely will be quite simple for some of you, but just impossible to solve for me.

I have moving vehicles. The advance at a certain speed, accelerate at a certain rate and deccelerate at another rate.

My problem is to find a formula to get the stopping distance of such vehicles from its max speed and decceleration.

The speed "s" is given in world unit per seconds (us).

The decceleration "d" is given in "us" lost each second while deccelerating.

For example, a vehicle moving at 6us and deccelerating by 2us per seconds will take... 3 seconds to fully stop.

What would be the formula to give me the number of world unit needed to fully stop from full speed to 0, in function of "s" and "d"?

Spidyy

##### Share on other sites
Nypyren    12074
Distance is the integral of speed. Have you done integrals yet?

##### Share on other sites
HappyCoder    5053
Newtonian physics equations should do the trick
// change of position over time
newPosition = position + velocity * time + 0.5 * acceleration * time^2
// change in velocity over time
newVelocity = velocity + acceleration * time

You already used the second equation to solve for time to stop by setting newVelocity to 0 and solving for time

time = -velocity / acceleration

Now just plug time into the first equation to solve for change in position
stoppingDistance = (newPosition - position) = velocity * time + 0.5 * acceleration * time^2

As a game dev, you should have these basic newtonian equations memorized and understand how they work.

##### Share on other sites
Spidyy    185

I get this:

stopping_distance = starting_velocity^2 / (2 * deceleration)

And that's it. :) Thanks a lot!