-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapture.ks
31 lines (26 loc) · 932 Bytes
/
capture.ks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// this script creates a maneuver node to capture around a body
declare parameter opp is -1.
declare parameter conj is -1.
declare parameter patchNum is 1.
// find target orbit
local targetPatch is orbit.
FROM {local i is 0.} UNTIL i = patchNum STEP {set i to i+1.} DO {
if targetPatch:hasnextpatch {
set targetPatch to targetPatch:nextpatch.
}
}
// this script only works if the targeted patch has a non elliptical trajectory
if targetPatch:eccentricity >= 1 {
print "found valid patch for body: " + targetPatch:body:name.
// if opposition or conjuction altitude was not set, set to periapsis
if opp = -1 {
set opp to targetPatch:periapsis.
print "set opp to " + targetPatch:periapsis.
}
if conj = -1 {
set conj to targetPatch:periapsis.
print "set conj to " + targetPatch:periapsis.
}
// create nodes
run transfer(opp, conj, -1, 0, patchNum).
}