kOS/lib/throttle.ks

22 lines
599 B
Plaintext
Raw Permalink Normal View History

2021-08-01 05:23:39 +00:00
// Functions for calculating values related to throttle and thrust.
2021-07-21 09:24:46 +00:00
// point gravity for TWR calculations.
local G is 0.
lock G to SHIP:BODY:MU / ((SHIP:BODY:RADIUS+SHIP:ALTITUDE)^2).
// Returns the throttle value you should use to achieve the
// target TWR. If TWR can't be achieved, returns 1.0. (full throttle)
function ThrottleToTWR {
parameter targetTWR is 1.5.
local m is SHIP:MASS.
return min((targetTWR*m*G)/SHIP:AVAILABLETHRUST, 1.0).
}
// Calculates the ship's current TWR.
function TWR {
local m is ship:mass.
local t is THROTTLE * SHIP:AVAILABLETHRUST.
return t/(m*G).
}