Formula for predicting next position does not include maximum velocity. Is there a formula that does?

68 Views Asked by At

I have this formula for predicting where an entity will be (np) in some amount of time (t), if I know its position (p), velocity (v) and acceleration (a): np = p + vt + (1/2)at²

It works well, but it faults when the velocity is close to the maximum speed that the entity can have, since it predicts it will be further than the entity can physically move.

What I need is a version of this formula that can predict where the entity will be, but also accounts for maximum velocity, so it does not overshoot.

I have not found a formula that does this and while I can make an algorithm instead, I think a formula would just be better for my use case, is there one which does this?

edit: If the entity reaches maximum velocity then it just stops accelerating further.

1

There are 1 best solutions below

0
On BEST ANSWER

The original formula you gave is obtained by integrating the velocity: $x(t) = x_0 + \int_{0}^{t} v(t) dt = x_0 + \int_{0}^{t} (v_0 + at) dt = x_0 + v_0 t + \frac{1}{2} at^2$

Where we computed $v(t)$ by assuming constant acceleration, i.e. $v(t) = v_0 + at$.

In your case, you also want to integrate the velocity to obtain the formula for the position, but you're assuming constant acceleration up until a bound, so the formula for $v(t)$ should express this.

Assuming that the maximum velocity is $v_{max}$, the initial velocity is $v_0< v_{max}$, the acceleration is $a$, and let's also assume that $a>0$ for simplicity, we have:

$x(t) = x_0 + \int_{0}^{t} v(t) dt = x_0 + \int_{0}^{t} min(v_0 + at, v_{max}) dt$

Up to $t_0 = \frac{(v_{max}-v_0)}{a}$, you get the same formula as you stated, i.e. $x_0 + v_0 t + \frac{1}{2} at^2$, because that's before the velocity hits the bound.

For $t>t_0$, you get:

$x(t) = x_0 + \int_{0}^{t} min(v_0 + at, v_{max}) dt = x_0 + \int_{0}^{t_0} (v_0 + at) dt + \int_{t_0}^{t} v_{max} dt = x_0 + \frac{v_0(v_{max}-v_0)}{a} + \frac{(v_{max}-v_0)^2}{2a} + v_{max}(t-\frac{(v_{max}-v_0)}{a}) = x_0 + v_{max}t - \frac{(v_{max} - v_0)^2}{2a} $

So all in all you get:

$ x(t) = \begin{cases} x_0 + v_0 t + \frac{1}{2} at^2 & \text{if }\ t < \frac{(v_{max}-v_0)}{a}\\ x_0 + v_{max}t - \frac{(v_{max} - v_0)^2}{2a} & \text{if }\ t \ge \frac{(v_{max}-v_0)}{a} \end{cases}$

You can do a similar calculation for negative accelerations as well, or really for any formula for the velocity which you know how to integrate.