Simplify lots of code in the launch sequence.

This commit is contained in:
2021-07-19 21:29:27 -04:00
parent 401f51425f
commit 642e5b17c5
4 changed files with 33 additions and 47 deletions

View File

@ -6,6 +6,18 @@ function GetPitch {
return 90 - vectorangle(SHIP:UP:FOREVECTOR, v).
}
function GetAscentVector {
parameter minPitch.
// face prograde, but hold a solid eastern heading and don't
// rotate the ship
local newHeading is lookdirup(SHIP:SRFPROGRADE:FOREVECTOR,
heading(90, 0, 270):TOPVECTOR).
if GetPitch(newHeading:FOREVECTOR) < minPitch {
set newHeading to heading(90, minPitch, 270).
}
return newHeading.
}
function AddCircularizationNode {
parameter usePeriapsis is false.
local target is SHIP:ORBIT:APOAPSIS.

View File

@ -2,14 +2,7 @@
@lazyglobal off.
local G is 9.81.
lock G to GetGravAcc().
function GetGravAcc {
if HAS_GRAV_SENSOR = true {
return SHIP:SENSORS:GRAV:MAG.
}
return SHIP:BODY:MU / ((SHIP:BODY:RADIUS+SHIP:ALTITUDE)^2).
}
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)
@ -27,22 +20,6 @@ function TWR {
return t/(m*G).
}
// Check for various sensors and set appropriate global constants.
// Currently only checks for grav sensor, as that's the only one used by this library.
global HAS_GRAV_SENSOR is false.
function SensorCheck {
local SensorList is 0.
list SENSORS in SensorList.
for s in SensorList {
if s:type = "grav" {
print "Gravometric sensor detected".
set HAS_GRAV_SENSOR to true.
return.
}
}
set HAS_GRAV_SENSOR to false.
}
function BurnTime {
parameter dV.