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-19 08:46:05 +00:00
|
|
|
function AddCircularizationNode {
|
2021-07-19 07:43:07 +00:00
|
|
|
parameter usePeriapsis is false.
|
|
|
|
local target is SHIP:ORBIT:APOAPSIS.
|
2021-07-19 08:46:05 +00:00
|
|
|
local t is TIME + SHIP:ORBIT:ETA:APOAPSIS.
|
2021-07-19 07:43:07 +00:00
|
|
|
if usePeriapsis {
|
|
|
|
set target to SHIP:ORBIT:PERIAPSIS.
|
|
|
|
set t to SHIP:ORBIT:ETA:PERIAPSIS.
|
|
|
|
}
|
|
|
|
local n is Node(t, 0, 0, 0).
|
2021-07-19 08:46:05 +00:00
|
|
|
add(n).
|
2021-07-19 07:43:07 +00:00
|
|
|
|
|
|
|
// move fast until we pass our target.
|
2021-07-19 08:46:05 +00:00
|
|
|
until (usePeriapsis and n:ORBIT:APOAPSIS <= target) or n:ORBIT:PERIAPSIS >= target {
|
2021-07-19 07:43:07 +00:00
|
|
|
set n:PROGRADE to n:PROGRADE + 1.
|
|
|
|
}
|
|
|
|
|
|
|
|
// now bring it back in real slow until we come back.
|
|
|
|
until (usePeriapsis and n:ORBIT:APOAPSIS > target) or n:ORBIT:PERIAPSIS < target {
|
|
|
|
set n:PROGRADE to n:PROGRADE - 0.01.
|
|
|
|
}
|
|
|
|
}
|