We start with x_start (and t = 0) at a speed of v_start, and we want to end with x_end at zero speed.
Since we have constant acceleration, the average speed will be v_start/2 , which means that we will reach x_end at t_end = (x_end - x_start) / (v_start / 2) .
Ok, then we can use x(t) = x_start + v_start * t + at^2/2 . As a validation check, connect t = 0 and make sure you get x = x_start.
Then connect t_end and you can decide for a. I get -v^2/(2D) , where D is x_end - x_start . A negative sign means that you are slowing down, not accelerating.
If you connect this to the original function, you will get:
x(t) = x_start + v_start * t - (v^2/4D) * t^2
If you have a counter that tells you the value of t (which will range from 0 to t_end), you can simply move the object to the desired position at every moment.
Or (and this may make more sense, depending on the language, environment, etc.), you can calculate the instantaneous speed of each time, and then the instantaneous position, following the answer of CoderTao.
source share