From 917d39d68db043efb53c550cc253af4ebc2e9f6c Mon Sep 17 00:00:00 2001 From: annabunches Date: Mon, 19 Jul 2021 05:09:17 -0400 Subject: [PATCH] Fix circularization code. --- boot/rocket.ks | 6 +++--- lib/navigation.ks | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/boot/rocket.ks b/boot/rocket.ks index c4f9b6d..e2e8afa 100644 --- a/boot/rocket.ks +++ b/boot/rocket.ks @@ -5,13 +5,13 @@ deletepath("/boot/rocket"). // Install software. -compile "0:/ui/rocket" to "1:/ui/rocket". +compile "0:/ui/rocket" to "1:/init". compile "0:/lib/navigation" to "1:/lib/navigation". compile "0:/lib/throttle" to "1:/lib/throttle". compile "0:/launch" to "1:/launch". -copypath("0:/execnode", "1:/execnode"). // smaller when compiled +copypath("0:/execnode", "1:/execnode"). // larger when compiled // Set OS to boot and restart. -set core:bootfilename to "/ui/rocket". +set core:bootfilename to "/init". reboot. diff --git a/lib/navigation.ks b/lib/navigation.ks index a154f11..ae70d11 100644 --- a/lib/navigation.ks +++ b/lib/navigation.ks @@ -17,13 +17,14 @@ function AddCircularizationNode { local n is Node(t, 0, 0, 0). add(n). - // 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. + local delta is 1. + local diff is n:ORBIT:APOAPSIS - n:ORBIT:PERIAPSIS. + until (diff < 1000) { + set n:PROGRADE to n:PROGRADE + delta. + local newDiff is n:ORBIT:APOAPSIS - n:ORBIT:PERIAPSIS. + if newDiff > diff { + set delta to (delta * -1) / 10. + } + set diff to newDiff. } }