-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaneuver.v0.1.0.ks
More file actions
executable file
·66 lines (51 loc) · 1.42 KB
/
maneuver.v0.1.0.ks
File metadata and controls
executable file
·66 lines (51 loc) · 1.42 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Maneuver Library v0.1.0
// Kevin Gisi
// http://youtube.com/gisikw
{
global maneuver is lex(
"version", "0.1.0",
"exec", mnv_exec@,
"burn_time", mnv_time@
).
function mnv_exec {
parameter autowarp is false.
if not hasnode return.
local n is nextnode.
local v is n:burnvector.
local starttime is time:seconds + n:eta - mnv_time(v:mag)/2.
if starttime < time:seconds return.
lock steering to v.
if autowarp { warpto(starttime - 30). }
wait until time:seconds >= starttime.
lock throttle to min(mnv_time(v:mag), 1).
until vdot(n:burnvector, v) < 0 {
wait 0.1.
}
lock throttle to 0.
unlock steering.
remove nextnode.
wait 0.01.
}
function mnv_time {
parameter dV.
local g is ship:orbit:body:mu/ship:obt:body:radius^2.
local m is ship:mass * 1000.
local e is constant():e.
local engine_count is 0.
local thrust is 0.
local isp is 0.
until ship:maxthrust > 0.1 {
stage.
wait 1.
}
list engines in all_engines.
for en in all_engines if en:ignition and not en:flameout {
set thrust to thrust + en:availablethrust.
set isp to isp + en:isp.
set engine_count to engine_count + 1.
}
set isp to isp / engine_count.
set thrust to thrust * 1000.
return g * m * isp * (1 - e^(-dV/(g*isp))) / thrust.
}
}