title: How to calculate deceleration needed to reach a certain speed over a certain distance?
body: <p>I've tried the typical physics equations for this but none of them really work because the equations deal with constant acceleration and mine will need to change to work correctly. Basically I have a car that can be going at a large range of speeds and needs to slow down and stop over a given distance and time as it reaches the end of its path.</p>
  
  <p>So, I have:<br>
      <code>V0</code>, or the current speed<br>
      <code>Vf</code>, or the speed I want to reach (typically 0)<br>
      <code>t</code>, or the amount of time I want to take to reach the end of my path<br>
      <code>d</code>, or the distance I want to go as I change from V0 to Vf  </p>
  
  <p>I want to calculate<br>
      <code>a</code>, or the acceleration needed to go from V0 to Vf  </p>
  
  <p>The reason this becomes a programming-specific question is because <code>a</code> needs to be recalculated every single timestep as the car keeps stopping. So, <code>V0</code> constantly is changed to be <code>V0</code> from last timestep <code>plus</code> the <code>a</code> that was calculated last timestep. So essentially it will start stopping slowly then will eventually stop more abruptly, sort of like a car in real life.</p>
  
  <p>EDITS:<br>
  All right, thanks for the great responses. A lot of what I needed was just some help thinking about this. Let me be more specific now that I've got some more ideas from you all:  </p>
  
  <p>I have a car <code>c</code> that is <code>64 pixels</code> from its destination, so <code>d=64</code>. It is driving at <code>2 pixels per timestep</code>, where a <code>timestep is 1/60 of a second</code>. I want to find the acceleration <code>a</code> that will bring it to a speed of <code>0.2 pixels per timestep</code> by the time it has traveled <code>d</code>.<br>
  <code>d = 64 //distance</code><br>
  <code>V0 = 2 //initial velocity (in ppt)</code><br>
  <code>Vf = 0.2 //final velocity (in ppt)</code>  </p>
  
  <p>Also because this happens in a game loop, a variable <code>delta</code> is passed through to each action, which is the <code>multiple of 1/60s that the last timestep took</code>. In other words, if it took 1/60s, then <code>delta</code> is 1.0, if it took 1/30s, then <code>delta</code> is 0.5. Before acceleration is actually applied, it is multiplied by this delta value. Similarly, before the car moves again its velocity is multiplied by the delta value. This is pretty standard stuff, but it might be what is causing problems with my calculations.</p>