# How to calculate total distance and time a puck will move?

To simulate a puck's movement, I use the following model (please restrain from discussing the model, it makes the simulation look the way I want it to) and would like to know how to calculate the total way the puck will move and how long it will take to do so.

My setup is: Per second, the puck looses 20% (=1-k) of its previous speed, so after a time t the speed will be v(t) = v(0) * k^t.

• If I look now at time t(n), how far has to puck traveled?
• How long will it travel until its speed falls below a defined v(min)?
• How far will it go until its speed drops below v(min)?

I have tried all kinds of formulas I remember from my physics lessons but I'm really stuck :-(

-
Are you aware that the friction model you are using is incorrect? Solid friction is not by percentages, but every second the puck loses the same amount of speed. –  Ron Maimon Dec 9 '11 at 5:55
Yeah, but it does not look good :-) The model of liquid friction just makes the simulation more playable. I tried with constant acceleration but liked the other one better. –  Krumelur Dec 9 '11 at 9:26
@Krumelur--- when writing a game, you are free to invent the laws of physics for the universe. I find it disheartening that faced with this freedom, video game designers feel the need to reproduce the laws of our universe ever more precisely, when there are infinitely many pac-man universes to discover. If you are interested in something crazy--- you could make a quantum puck, where you simulate a wavefunction with certain measurements by the players, and you can only have an uncertain idea of where it is, and the wavefunction in the goal gives the probability of a goal in intervals. –  Ron Maimon Dec 9 '11 at 9:48
Well, in my case the issue was: I invented the movement behavior of the puck and was able to simulate it. But then I was faced with the fact that for the AI I needed to predict, where the puck will land and that's when the trouble started. :-) –  Krumelur Dec 9 '11 at 11:32

If I were you, I would use a different K, having units of 1/time. So I would first say velocity falls in a very simple way:

$$v(t) = v_0 exp(-Kt)$$

To see how much time $t_m$ it takes to reach a particular speed $v_m$, you can solve for it in the above equation

$$t_m = ln(v_0/v_m)/K$$

Integrate $v(t)$ to see how far the puck moves:

$$x(t) = (v_0/K)(1 - exp(-Kt))$$

To see how the far the puck moves before it stops, just plug in infinity for $t$. That gives you $(v_0/K)$.

To estimate $K$, just plot $x$ or $v$ against $t$. Draw a tangent to the curve at time 0. The time where it intersects the asymptote is $1/K$.

-
Isn't that exactly what I have? Velocity drops by factor per second? –  Krumelur Dec 9 '11 at 9:28
@Krumelur: It is, and what user1631 has as well, except for the $K$ that you use. Here the $K$ has pure rate units. You can easily estimate it from half-life (the time it takes for the puck to get half-way) as $K = ln(2)/t_h$ or conversely $t_h = ln(2)/K$. In pharma we deal with this all the time. It's much simpler than the $k$ you have. –  Mike Dunlavey Dec 9 '11 at 13:05
I get it. That's even simpler. Haven't thought of that at all. –  Krumelur Dec 9 '11 at 20:07

$$v(t) = v(0)*k^t = v(0)*e^{t*\log{k}}$$ $$x(t) = \int{dt v(t)} = v(0)*(e^{t*\log{k}}-1)/\log{k}=v(0)*(k^t -1)/\log{k}$$ $$T(v_{min}) = \log{(v_{min}/v(0))}/\log{k}$$

et cetera.

-