Calculate displacement from initial velocity, acceleration, and drag

335 Views Asked by At

I am creating a video game, where the drag force of an object is proportional to its velocity. Every object has a mass of $1$ so this is equivalent to a drag acceleration.

$$ a_{d} = \ln(1 - k) \times v $$

If the constant $k$ is $0.1$ then, after one second, there is a $10\%$ reduction in an object's velocity due to this force.

I have the following formula to calculate velocity from constant acceleration.

$$v = u + at$$

However, I need this to work with variable acceleration (including the drag force which depends on velocity, and a constant acceleration $a_{c}$):

$$ a = a_{c} + a_{d} $$

What changes should I make to the formula to allow this?

From there, I'm hoping to find out how to update the following formula as well, which should calculate displacement ($s$) from starting velocity ($u$), acceleration and time:

$$ s = ut + \frac{1}{2}at^2 $$

1

There are 1 best solutions below

1
On

If we take a friction which is proportional to the velocity, we have that the equation of motion is $$a=-\beta v$$ i.e. $$\dot{v}=-\beta v$$ Which has the solution $$v(t)=v_0e^{-\beta t}$$ Which means that $$v(1)=v_0e^{-\beta}$$ $$v(2)=v_0e^{-2\beta}=v_0e^{-\beta}e^{-\beta}=v(1)e^{-\beta}$$ And so on. So if we take $e^{-\beta}=0.9$, we get that $\beta=-\log(0.9)\approx 0.105361$.

If we also add an $F$ force, which results an acceleration $g$ (for example gravity), the differential equation becomes: $$a=g-\beta v$$ i.e. $$\ddot{x}+\beta \dot{x}=g$$ Which has the following solution: $$x(t)=\frac{g}{\beta}t+A+Be^{-\beta t}$$ To find the constants $A$ and $B$, we can use the initial velocity $v_0$ and initial position $x_0$, because: $$x(0)=A+B=x_0$$ and $$v(0)=\frac{g}{\beta}-\beta B=v_0$$ which you can solve for $A$ and $B$.