forked from Matway/mpl-sl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pose.mpl
executable file
·80 lines (70 loc) · 1.36 KB
/
Pose.mpl
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
"Pose" module
"control" includeModule
"algebra" includeModule
"Quaternion" includeModule
pose: [
position0: orientation0: ;;
position0 Real32 3 Vector same not [0 .POSITION_TYPE_MISMATCH] when
orientation0 Real32 Quaternion same not [0 .ORIENTATION_TYPE_MISMATCH] when
{
virtual POSE: ();
position: position0 copy;
orientation: orientation0 copy;
getMatrix: [orientation matrix];
translate: [position + !position];
}
];
Pose: [
Real32 3 Vector Real32 Quaternion pose
];
identityPose: [
(0.0r32 0.0r32 0.0r32) Real32 identityQuaternion pose
];
*: [
p0:p1:;;
p0 "POSE" has
p1 "POSE" has and
] [
p0:p1:;;
p0.position p1.getMatrix * p1.position +
p0.orientation p1.orientation * pose
] pfunc;
*: [
v:p:;;
v vector?
p "POSE" has and
] [
v:p:;;
v p.getMatrix * p.position +
] pfunc;
inverse: ["POSE" has] [
p:;
p.position neg p.getMatrix trans *
p.orientation conj pose
] pfunc;
interpolate: [
p0:p1:f:;;;
p0 "POSE" has
p1 "POSE" has and
] [
p0:p1:f:;;;
p0.position p1.position f lerp
p0.orientation p1.orientation f nlerp pose
] pfunc;
mirrorVertically: [
p:m:;;
p "POSE" has
] [
p:m:;;
(
0 p.position @ copy
1 p.position @ copy
m 2 p.position @ -
)
(
0 p.orientation @ neg
1 p.orientation @ neg
2 p.orientation @ copy
3 p.orientation @ copy
) quatertion pose
] pfunc;