Use orbital math to simplify circ node.

This commit is contained in:
2021-07-20 04:18:16 -04:00
parent ec9568b24a
commit d27d63fb80
4 changed files with 17 additions and 27 deletions

View File

@ -18,26 +18,15 @@ function GetAscentVector {
return newHeading.
}
function AddCircularizationNode {
parameter usePeriapsis is false.
local target is SHIP:ORBIT:APOAPSIS.
local t is TIME + SHIP:ORBIT:ETA:APOAPSIS.
if usePeriapsis {
set target to SHIP:ORBIT:PERIAPSIS.
set t to SHIP:ORBIT:ETA:PERIAPSIS.
}
local n is Node(t, 0, 0, 0).
add(n).
local epsilon is 100.
lock diff to n:ORBIT:APOAPSIS - n:ORBIT:PERIAPSIS.
local pid is PIDLoop(0.05, 0.006, 0.006).
set pid:EPSILON to epsilon.
set pid:SETPOINT to n:ORBIT:APOAPSIS.
until abs(diff) < epsilon {
set n:PROGRADE to pid:Update(TIME:SECONDS, n:ORBIT:PERIAPSIS).
wait 0.001.
}
print "Circularization node created."
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.
}