-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinclin_test.ks
51 lines (38 loc) · 1.23 KB
/
inclin_test.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//kOS Script: Neutralize relative inclination
//Author: Simon Lachaîne
FUNCTION PLANE_ANGLE {
set a1 to sin(ship:obt:inclination)*cos(ship:obt:LAN).
set a2 to sin(ship:obt:inclination)*sin(ship:obt:LAN).
set a3 to cos(ship:obt:inclination).
set b1 to sin(TARGET:obt:inclination)*cos(TARGET:obt:LAN).
set b2 to sin(TARGET:obt:inclination)*sin(TARGET:obt:LAN).
set b3 to cos(TARGET:obt:inclination).
RETURN arccos(a1*b1+a2*b2+a3*b3).
}
FUNCTION ORBIT_NORMAL {
PARAMETER OrbitIn.
RETURN VCRS(OrbitIn:body:position - OrbitIn:position,
OrbitIn:velocity:orbit):normalized.
}
FUNCTION SWAPYZ {
PARAMETER VecIn.
RETURN V(VecIn:X, VecIn:Z, VecIn:Y).
}
FUNCTION SWAPPED_ORBIT_NORMAL {
PARAMETER OrbitIn.
RETURN -SWAPYZ(ORBIT_NORMAL(OrbitIn)).
}
FUNCTION RELATIVEINC {
PARAMETER OrbiterA, OrbiterB.
RETURN ABS(VANG(SWAPPED_ORBIT_NORMAL(OrbiterA), SWAPPED_ORBIT_NORMAL(OrbiterB))).
}
FUNCTION MONITOR {
PRINT "Monitor" AT (0,30).
PRINT "-Relative inclination: " + ROUND(RELATIVEINC(SHIP,TARGET),2) + " degrees " AT (0,31).
PRINT "-Plane angle: " + ROUND(PLANE_ANGLE(),2) + " degrees " AT (0,32).
}
SET Stop TO False.
UNTIL Stop = True {
MONITOR().
WAIT 0.001.
}.