Time to reach maximum velocity

Discussion area for user-created Allegiance models, textures, voicechats, music, and other ingame content.
Post Reply
Compellor
Posts: 994
Joined: Fri Jul 06, 2007 12:56 am
Location: Columbus, OH

Post by Compellor »

In ICE we can define maximum thrust, mass, and maximum speed. Thrust and mass give us acceleration. However, in game the acceleration isn't constant - it seems to start at maximum and gradually decline. Thus, we might reach half speed in just a few seconds, but reaching max speed might take thirty or more.

I was wondering if there was some formula I could use to determine how long it takes for a ship to reach maximum velocity, rather than having to time the thing myself. I'm assuming your thrust (and thus acceleration) is proportional to your speed, but I simply don't know how to translate that into something useful. I imagine it involves calculus, and I never got very far studying that.

Sidenote: I think there are a few too many forums and subforums. I never know where to put my posts.
Last edited by Compellor on Wed Aug 06, 2008 12:16 pm, edited 1 time in total.
Any job worth doing with a laser is worth doing with many, many lasers. -Khrima
Beyond a shadow of a doubt if you don't watch them like a hawk they will stack their collective balls off - MrChaos on Alleg players
Andon
Posts: 5453
Joined: Sun Jun 03, 2007 8:29 pm
Location: Maryland, USA
Contact:

Post by Andon »

It's a standard accelleration curve, IIRC. Just like in any car - 0-60 might take 4 seconds, but 0 to 120 doesn't take 8
Image
ImageImage
KGJV
Posts: 1474
Joined: Tue Jul 01, 2003 7:00 am
Location: Transilvania

Post by KGJV »

Unless my maths are wrong I think it's very complex integral to solve ...

in pure vacuum you'll get:

T=thrust
V=top speed
M=mass

"time to reach V" = V M / T

but in alleg there is an artificial drag. The source code uses something like:

T=thrust
V=top speed
M=mass
dt = delta time
v = current speed

drag = v (1 - Exp(T dt V / M)) / ( dt / M)

dv = dt / M ( T - drag)

where dv is speed increase for dt time, (so v = v + dv every dt)

so you need to integrate this and reverse it to time to speed instead of speed to time... I'm not an integrals expert at all so this looks complicated to me /mrgreen.gif" style="vertical-align:middle" emoid=":D" border="0" alt="mrgreen.gif" />
Last edited by KGJV on Thu Aug 07, 2008 8:15 am, edited 1 time in total.
Image
Compellor
Posts: 994
Joined: Fri Jul 06, 2007 12:56 am
Location: Columbus, OH

Post by Compellor »

Well, at least I wasn't missing something obvious. I think I'll stick to trial and error.
Any job worth doing with a laser is worth doing with many, many lasers. -Khrima
Beyond a shadow of a doubt if you don't watch them like a hawk they will stack their collective balls off - MrChaos on Alleg players
TurkeyXIII
Posts: 1460
Joined: Thu Dec 06, 2007 3:18 am
Location: Melbourne, Aus

Post by TurkeyXIII »

I didn't quite follow KGJV's code, so I made an assumption about drag instead. It makes physical sense and conforms to tests, so I'm happy to go with it for now. I've also assumed you're stationary initially.

I'm not going to put my workings here, as text editors make a real mess of it.

The velocity as a function of time is given by:

v(t) = V * ( 1 - e- (T / (m*V)) * t )

Where:
v(t) velocity as a function of time
t = time elapsed
V = maximum velocity (from ICE)
T = thrust (from ICE. An approximation for boosters can be made by adding booster thrust to ship thrust, but it'll fall apart when you need to reload it)
m = mass of the ship (plus cargo)

There would be a small amount of rounding and quantization error due to the game's time and velocity increments being finite, but that would be negligible for the most part.

If you try to transpose that for t at v(t) = V, you'll get ln(0) which doesn't exist. Engineers measure rise time of exponentials either by time constant (which is fairly meaningless unless you're looking at the equation) or by the time taken to reach a specified fraction of the maximum. As you're interested in getting to maximum, I'd use the 90% rise time.

t90% = (2.3 * m * V) / T
Last edited by TurkeyXIII on Mon Aug 11, 2008 8:29 am, edited 1 time in total.
QUOTE (Randall Munroe)14.2: Turkey consumption rate of the average American in milligrams per minute[/quote]
Image
Compellor
Posts: 994
Joined: Fri Jul 06, 2007 12:56 am
Location: Columbus, OH

Post by Compellor »

TurkeyXIII wrote:QUOTE (TurkeyXIII @ Aug 11 2008, 04:28 AM) snip
That seems to work, thank you!
Last edited by Compellor on Mon Aug 11, 2008 1:18 pm, edited 1 time in total.
Any job worth doing with a laser is worth doing with many, many lasers. -Khrima
Beyond a shadow of a doubt if you don't watch them like a hawk they will stack their collective balls off - MrChaos on Alleg players
Post Reply