2021-07-19 07:43:07 +00:00
|
|
|
// functions for calculating steering values.
|
2021-07-19 04:54:32 +00:00
|
|
|
@lazyglobal off.
|
|
|
|
|
|
|
|
function GetPitch {
|
|
|
|
parameter v is SHIP:FACING:FOREVECTOR.
|
|
|
|
return 90 - vectorangle(SHIP:UP:FOREVECTOR, v).
|
|
|
|
}
|
2021-07-19 07:43:07 +00:00
|
|
|
|
2021-07-20 01:29:27 +00:00
|
|
|
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.
|
|
|
|
}
|
|
|
|
|
2021-07-20 08:18:16 +00:00
|
|
|
function CreateCircularizationNode {
|
|
|
|
parameter nodeAtPeriapsis is false.
|
|
|
|
|
|
|
|
local dt is choose SHIP:ORBIT:ETA:PERIAPSIS if nodeAtPeriapsis else SHIP:ORBIT:ETA:APOAPSIS.
|
|
|
|
local t is TIME + dt.
|
|
|
|
|
|
|
|
local Vc is sqrt(SHIP:BODY:MU/(SHIP:BODY:RADIUS + SHIP:ORBIT:APOAPSIS)).
|
|
|
|
local dV is Vc - VelocityAt(SHIP, t):ORBIT:MAG.
|
|
|
|
local n is Node(t, 0, 0, dV).
|
|
|
|
|
|
|
|
return n.
|
2021-07-19 07:43:07 +00:00
|
|
|
}
|