34 lines
972 B
Plaintext
34 lines
972 B
Plaintext
// functions for calculating steering values.
|
|
@lazyglobal off.
|
|
|
|
function GetPitch {
|
|
parameter v is SHIP:FACING:FOREVECTOR.
|
|
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 CreateCircularizationNode {
|
|
parameter nodeAtPeriapsis is false.
|
|
|
|
local dt is choose SHIP:ORBIT:ETA:PERIAPSIS if nodeAtPeriapsis else SHIP:ORBIT:ETA:APOAPSIS.
|
|
local a is choose SHIP:ORBIT:PERIAPSIS if nodeAtPeriapsis else SHIP:ORBIT:APOAPSIS.
|
|
local t is TIME + dt.
|
|
|
|
local Vc is sqrt(SHIP:BODY:MU/(SHIP:BODY:RADIUS + a)).
|
|
local dV is Vc - VelocityAt(SHIP, t):ORBIT:MAG.
|
|
local n is Node(t, 0, 0, dV).
|
|
|
|
return n.
|
|
}
|