[Physics] Time and distance where velocity is a function of time

accelerationkinematics

I'm creating a video game set in space in which spaceships travelling between places accelerate until they hit a maximum velocity. They then travel at that velocity until a time when they need to start decelerating so as to arrive at their destination and not overshoot. There is no relativity or friction or anything else 'fancy' involved

For the algorithm I'm writing to do this, I need to know

a) the time it will take a ship to reach the half way point in its journey (assuming it continues to accelerate forever), and

b) the time it will take to reach maximum velocity, and

c) the distance travelled at time t (assuming continuous acceleration).

I can then use that to tell the ship at what time to start decelerating, depending on how far the whole journey is.

However, to accelerate the ships, I multiply their current velocity by 1.5 every second (to decelerate, I divide by 1.5). i.e. v(t) = v(t-1) * 1.5

I can also assume Initial velocity (velocity at time 0) is a constant and always positive

If anyone can point me in the right direction as to what formula to use (or even better, the pseudo-code to do it), I'd be most appreciative

Best Answer

I multiply their current velocity by 1.5 every second

OK, sounds like a discrete time problem. For continuous acceleration:

$v[n] = v[0] \cdot (1.5)^n$

So, the answer to (c) is:

$x[n] = \sum \limits_{i=1}^{n}v[i-1] = \frac{2}{3} \cdot v[0] \cdot \sum \limits_{i=1}^{n}(1.5)^i = 2 \cdot v[0] \cdot [(1.5)^n - 1]$

For (b), if the maximum velocity is V > v[0], then the time required to reach V is:

$n =\dfrac{ln (\frac{V}{v[0]})}{ln(1.5)}$

For (a), if $x[N]$ is the distance traveled under continuous acceleration, then you're looking for the $n$ where $x[n] = x[N] / 2$

For N large enough, the solution is:

$n = \dfrac{ln(\frac{(1.5)^N}{2})}{ln(1.5)}$

Update: for emphasis and to simplify your code, for large n:

$x[n] \approx 2 \cdot v[n]$

Related Question