Pages: [1]
|
|
|
Author
|
Topic: Acceleration Governance (Read 2632 times)
|
Smaug
Zebranky food
Offline
Posts: 23
I love YaBB 1G - SP1!
|
I have a pretty good understanding of how actual physics works, and I know a lot about how to implement it in a computer simulation. But there is a question that has boggled my mind for some time, and I'd rather not have to run through UQM's codebase to find it.
How do they make it so that the player's acceleration stops at the ships maximum velocity? See, I know enough to know it isn't a simple matter of simply capping the ship's max velocity; otherwise, gravity whips wouldn't work. And we all know that accelerating once past max velocity will accelerate the ship back towards that velocity, which likewise goes against physics.
So does anyone know what bizarre equations governs StarControl-style physics? I know it's mostly Newtonian, but I just can't seem to figure out how they governed the ship's acceleration.
|
|
|
Logged
|
|
|
|
|
Smaug
Zebranky food
Offline
Posts: 23
I love YaBB 1G - SP1!
|
I'm aware of all of that. I'm asking about the specific mechanism that governs thrust-based acceleration.
In regular physics, if you have acceleration X over time duration Y, you know that the velocity you get is X*Y + Z, where Z is the initial velocity. But in SC physics, acceleration is somehow based on both the current speed (or the ratio of the speed relative to the maximum thrust speed) and the applied acceleration. What exactly is the nature of that relationship, and what are the equations that govern it.
|
|
|
Logged
|
|
|
|
|
|
Smaug
Zebranky food
Offline
Posts: 23
I love YaBB 1G - SP1!
|
UQM uses Newtonian physics, but caps the maximum speed. This statement, when translated to mathematics, is:
V1 = MAX(Vmax, (Athrust * t + V0) );
However, playing the game does not entirely bear this out. If this were the case, then if your velocity is over Vmax, and you press thrust at all, then your velocity will immediately drop to Vmax (or less, depending on where you're thrusting). However, if you play the game, you discover that it takes continued thrusting to go from a super-Vmax velocity to a sub-Vmax velocity. Make a gravity whip with the Umgah (high acceleration, low max-speed), and you will see how long it takes for it to slow down back to Vmax if you thrust in the direction of motion.
I could be convinced that this is how it works when the current speed is below Vmax. But not when it is above it.
|
|
|
Logged
|
|
|
|
Novus
Enlightened
Offline
Gender:
Posts: 1938
Fot or not?
|
For non-Skiff vessels, src/sc2code/ship.c specifies (as far as I can tell) the following thrust behaviour (simplifying away what looks like optimisations and/or improvements to precision):
Every timestep when thrust is active, calculate a desired velocity that is the current velocity + acceleration/timestep. If the desired velocity is less than the (normal) maximum for the ship, change the current velocity to it. Simple so far.
Otherwise, check whether the ship is within range of a gravity well (i.e. planet). If it is, set the current velocity to the desired velocity if the desired velocity has smaller magnitude than the current velocity or is less than the gravity well-area maximum. In all remaining cases (including decelerating after leaving a gravity well), things get a bit complicated. The desired speed is set to the current velocity - acceleration/timestep in the reverse direction of travel (!) + half acceleration/timestep in the direction of the ship. This new velocity is applied if it decreases the speed of the ship or is below the maximum.
This seems to fit; even if thrusting in the direction of travel, the ship is slowed down.
Incidentally, the optimisations I mentioned have some interesting side effects with ships that change their maximum velocity (Torch, at least): if the ship is pointing in the same direction as it's moving at max speed, thrust has no effect. To check this out, burn the Torch afterburner in a straight line for a while, then apply normal thrust. You will find that, unexpectedly, the Torch doesn't lose speed (until you turn slightly).
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
|
|