-
Notifications
You must be signed in to change notification settings - Fork 2
/
Math.kc
92 lines (82 loc) · 2.32 KB
/
Math.kc
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
module KOS::Math;
import KOS::Builtin unqualified;
builtin structure Vector : Structure {
Scalar X;
Scalar Y;
Scalar Z;
Scalar Mag;
Vector Normalized get;
Scalar SqrMagnitude get;
Direction Direction;
Vector Vec get;
}
builtin Vector V(Scalar x, Scalar y, Scalar z);
builtin Scalar vdot(Vector v1, Vector v2);
builtin Vector vcrs(Vector v1, Vector v2);
builtin Scalar vang(Vector v1, Vector v2);
builtin Vector vxcl(Vector v1, Vector v2);
builtin structure Direction : Structure {
Scalar Pitch get;
Scalar Yaw get;
Scalar Roll get;
Vector ForeVector get;
Vector TopVector get;
Vector StarVector get;
Direction Inverse get;
}
builtin Direction R(Scalar pitch, Scalar yaw, Scalar roll);
builtin Direction Q(Scalar x, Scalar y, Scalar z, Scalar rot);
builtin Direction Heading(Scalar dir, Scalar pitch);
builtin Direction LookDirUp(Vector lookAt, Vector lookUp);
builtin Direction AngleAxis(Scalar degrees, Vector axis);
builtin Direction RotateFromTo(Vector from, Vector to);
builtin structure Constant {
Scalar G get;
Scalar E get;
Scalar Pi get;
Scalar c get;
Scalar AtmToKPa get;
Scalar KPaToAtm get;
Scalar DegToRad get;
Scalar RadToDeg get;
}
builtin Constant Constant get;
builtin structure PIDLoop {
Scalar LastSampleTime get;
Scalar KP;
Scalar KI;
Scalar KD;
Scalar Input get;
Scalar Setpoint;
Scalar Error get;
Scalar Output get;
Scalar MaxOutput;
Scalar MinOutput;
Scalar ErrorSum get;
Scalar PTerm get;
Scalar ITerm get;
Scalar DTerm get;
Scalar ChangeRate get;
Void Reset();
Scalar Update(Scalar time, Scalar input);
}
builtin PIDLoop PIDLoop(Scalar kp = ?, Scalar ki = ?, Scalar kd = ?, Scalar minOut = ?, Scalar maxOut = ?);
builtin Scalar Min(Scalar a, Scalar b);
builtin Scalar Max(Scalar a, Scalar b);
builtin Scalar Abs(Scalar a);
builtin Scalar Ceiling(Scalar a);
builtin Scalar Floor(Scalar a);
builtin Scalar Ln(Scalar a);
builtin Scalar Log10(Scalar a);
builtin Scalar Mod(Scalar a, Scalar b);
builtin Scalar Round(Scalar a, Scalar b = ?);
builtin Scalar Sqrt(Scalar a);
builtin String Char(Scalar a);
builtin Scalar UnChar(String a);
builtin Scalar Sin(Scalar a);
builtin Scalar Cos(Scalar a);
builtin Scalar Tan(Scalar a);
builtin Scalar ArcSin(Scalar a);
builtin Scalar ArcCos(Scalar a);
builtin Scalar ArcTan(Scalar a);
builtin Scalar ArcTan2(Scalar a, Scalar b);