0
$\begingroup$

So I'm developing this game with physics.

Every frame, the body accelerates at $+4\,\mathrm{m/s^2}$.

However, every frame, the body also sets its velocity to 90% of its original value, basically the game equalivalent of drag.

How would I determine the terminal velocity here, with math, and not guess and check?

$\endgroup$
4
  • $\begingroup$ First lets see if i understand what's happening. If a body is at rest, the next second he gains 4m/s of velocity, but the correction makes it so that he has only 90% of this value? So in that second he is actually at 3.6 m/s? $\endgroup$
    – Klaus3
    Commented Feb 13, 2022 at 17:02
  • $\begingroup$ Yes, but the next second he gets 4m/s more, which is 7.6 due to velocity portion which becomes 6.89 for the percentage portion and etc @Klaus3 $\endgroup$
    – Coder2195
    Commented Feb 13, 2022 at 17:07
  • $\begingroup$ 6.89 is not 90% of 7.6. How do you get this value? $\endgroup$
    – nasu
    Commented Feb 13, 2022 at 19:16
  • $\begingroup$ The correct value is 6.84, perhaps a mistype. $\endgroup$
    – Klaus3
    Commented Feb 13, 2022 at 19:24

1 Answer 1

2
$\begingroup$

So, your function is kinda odd, but idk if that's intended. Lets analyze it:

$$v(0)=v_0$$ $$v(1)= 0.9v_0 + 0.9*4$$ $$v(2)= 0.9(0.9v_0 + 0.9*4 + 4)$$ $$v(2)= 0.9^2v_0 + 4(0.9^2+0.9)$$ $$v(3)= 0.9*(0.9^2v_0 + 4(0.9^2+0.9)+4)$$ $$v(3)= 0.9^3v_0 + 4(0.9^3+0.9^2+0.9)$$

See the pattern?

$$v(t) = 0.9^tv_0 + 4\sum_{t=1}^{t}0.9^t$$

So far so good, but notice that the $0.9^tv_0$ will converge to zero as t increases no matter what and the sum $ 4\sum_{t=1}^{t}0.9^t$ will converge to $0.9/(1-0.9)=9$ as $x-> \infty $. So, the terminal velocity will be

$$v_{ter} = lim_{t->\infty} (0.9^tv_0 + 4\sum_{t=1}^{t}0.9^t)= 4*9 = 36m/s $$

So if you accel and the correction parameters are always these two, the terminal velocity will always be 36 m/s for everything. In a general sense, if you can change the parameters, the function will be:

$$v(t) = C^tv_0 + a\sum_{t=1}^{t}C^t$$ $$v_{ter} = a \frac{C}{1-C}$$

Where "a" is the acceleration and "C" is the correction factor and $0<C<1$

EDIT: Just as a clarification, one might point out that the equation for the velocity is dimensionally incorrect as $a$ has units $m/s^2$ and $C$ is dimensionless, but this is so because every point of the function is exactly multiplied by a $\Delta t$ of 1. For instance, for t=2

$$v(2)= 0.9(0.9v_0 + 0.9*4*(t-(t-1)) + 4*(t-(t-1))$$

The $(t-(t-1)$ will reduce to 1 at all times, but it has units of time, these units are incorporated in the acceleration of 4m/s²

$\endgroup$
1
  • $\begingroup$ Thanks, the v terminal formula was all I needed $\endgroup$
    – Coder2195
    Commented Feb 15, 2022 at 18:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.