Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is a simple kinematics problem.</p> <p>At some time t, the velocity (v) of an object under constant acceleration is described by:</p> <pre><code>v = v0 + at </code></pre> <p>Where v0 is the initial velocity and a is the acceleration. In your case, the final velocity is zero (the object is stopped) so we can solve for t:</p> <pre><code>t = -v0/a </code></pre> <p>To find the total difference traveled, we take the integral of the velocity (the first equation) over time. I haven't done an integral in years, but I'm pretty sure this one works out to:</p> <pre><code>d = v0t + 1/2 * at^2 </code></pre> <p>We can substitute in the equation for t we developed ealier:</p> <pre><code>d = v0^2/a + 1/2 * v0^2 / a </code></pre> <p>And the solve for v0:</p> <pre><code>v0 = sqrt(-2ad) </code></pre> <p>Or, in a more programming-language format:</p> <pre><code>initialVelocity = sqrt( -2 * acceleration * distance ); </code></pre> <p>The acceleration in this case is negative (the object is slowing down), and I'm assuming that it's constant, otherwise this gets more complicated.</p> <p>If you want to use this inside a loop with a finite number of steps, you'll need to be a little careful. Each iteration of the loop represents a period of time. The object will move an amount equal to the <em>average</em> velocity times the length of time. A sample loop with the length of time of an iteration equal to 1 would look something like this:</p> <pre><code>position = 0; currentVelocity = initialVelocity; while( currentVelocity &gt; 0 ) { averageVelocity = currentVelocity + (acceleration / 2); position = position + averageVelocity; currentVelocity += acceleration; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload