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.
|
2021-07-20 01:29:27 +00:00
|
|
|
lock G to SHIP:BODY:MU / ((SHIP:BODY:RADIUS+SHIP:ALTITUDE)^2).
|
2021-07-20 00:06:38 +00:00
|
|
|
|
2021-07-18 19:05:26 +00:00
|
|
|
// 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 {
|
2021-07-18 20:06:38 +00:00
|
|
|
parameter targetTWR is 1.5.
|
2021-07-18 19:05:26 +00:00
|
|
|
|
|
|
|
local m is SHIP:MASS.
|
2021-07-20 00:06:38 +00:00
|
|
|
return min((targetTWR*m*G)/SHIP:AVAILABLETHRUST, 1.0).
|
2021-07-18 19:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Calculates the ship's current TWR.
|
|
|
|
function TWR {
|
|
|
|
local m is ship:mass.
|
|
|
|
local t is THROTTLE * SHIP:AVAILABLETHRUST.
|
2021-07-20 00:06:38 +00:00
|
|
|
return t/(m*G).
|
2021-07-18 19:05:26 +00:00
|
|
|
}
|