Add node execution code.
This commit is contained in:
@ -1,6 +1,30 @@
|
||||
// functions for calculating steering values.
|
||||
@lazyglobal off.
|
||||
|
||||
function GetPitch {
|
||||
parameter v is SHIP:FACING:FOREVECTOR.
|
||||
return 90 - vectorangle(SHIP:UP:FOREVECTOR, v).
|
||||
}
|
||||
|
||||
function CreateCircularizationNode {
|
||||
parameter usePeriapsis is false.
|
||||
local target is SHIP:ORBIT:APOAPSIS.
|
||||
local t is 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).
|
||||
|
||||
// move fast until we pass our target.
|
||||
until (usePeriapsis and n:ORBIT:APOAPSIS < target) or n:ORBIT:PERIAPSIS > target {
|
||||
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.
|
||||
}
|
||||
|
||||
return n.
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Functions for calculating navigational and guidance values.
|
||||
// Functions for calculating thrust values.
|
||||
@lazyglobal off.
|
||||
|
||||
// Returns the throttle value you should use to achieve the
|
||||
@ -42,15 +42,16 @@ function SensorCheck {
|
||||
set HAS_GRAV_SENSOR to false.
|
||||
}
|
||||
|
||||
// adapted from https://github.com/sporadisk/KSP-KOS-scripts/blob/master/modules/GravityTurn.ks
|
||||
// todo: I don't think I actually like this code...
|
||||
function GravityTurn {
|
||||
parameter TargetDirection is 90.
|
||||
parameter TargetApoapsis is 80000.
|
||||
parameter Factor is 1.
|
||||
function BurnTime {
|
||||
parameter dV.
|
||||
|
||||
local remFactor is (2 / Factor).
|
||||
local remHeight is (SHIP:APOAPSIS/TargetApoapsis).
|
||||
local angle is (90 * (1 - (remHeight ^ remFactor))).
|
||||
return heading(TargetDirection, angle, 90).
|
||||
list ENGINES in en.
|
||||
|
||||
local f is en[0]:MAXTHRUST * 1000. // Engine Thrust (kg * m/s²)
|
||||
local m is SHIP:MASS * 1000. // Starting mass (kg)
|
||||
local e is CONSTANT():E. // Base of natural log
|
||||
local p is en[0]:ISP. // Engine ISP (s)
|
||||
local g is 9.80665. // Gravitational acceleration constant (m/s²)
|
||||
|
||||
return g * m * p * (1 - e^(-dV/(g*p))) / f.
|
||||
}
|
||||
|
Reference in New Issue
Block a user