forked from Matway/mpl-sl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPose.mpl
108 lines (95 loc) · 3.17 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Copyright (C) Matway Burkow
#
# This repository and all its contents belong to Matway Burkow (referred here and below as "the owner").
# The content is for demonstration purposes only.
# It is forbidden to use the content or any part of it for any purpose without explicit permission from the owner.
# By contributing to the repository, contributors acknowledge that ownership of their work transfers to the owner.
"Quaternion.*" use
"Quaternion.@" use
"Quaternion.Quaternion" use
"Quaternion.conj" use
"Quaternion.identityQuaternion" use
"Quaternion.matrix" use
"Quaternion.nlerp" use
"Quaternion.quaternion" use
"Quaternion.quaternionCast" use
"algebra.*" use
"algebra.+" use
"algebra.Vector" use
"algebra.cast" use
"algebra.lerp" use
"algebra.neg" use
"algebra.trans" use
"algebra.vector?" use
"control.&&" use
"control.Real32" use
"control.Ref" use
"control.dup" use
"control.hasSchemaName" use
"control.pfunc" use
Pose: [
Real32 3 Vector Real32 Quaternion pose
];
*: [
pose0: pose1:;;
pose0 "Pose" hasSchemaName [pose1 "Pose" hasSchemaName] &&
] [
pose0: pose1:;;
pose0.position pose1.orientation 0 pose0.position @ quaternionCast matrix * pose1.position pose0.position cast +
pose0.orientation pose1.orientation 0 pose0.orientation @ quaternionCast * pose
] pfunc;
*: [
vector: pose:;;
vector vector? [pose "Pose" hasSchemaName] &&
] [
vector: pose:;;
vector pose.orientation 0 vector @ quaternionCast matrix * pose.position vector cast +
] pfunc;
identityPose: [
(0.0r32 0.0r32 0.0r32) Real32 identityQuaternion pose
];
interpolate: [
pose0: pose1: blend:;;;
pose0 "Pose" hasSchemaName [pose1 "Pose" hasSchemaName] &&
] [
pose0: pose1: blend:;;;
pose0.position pose1.position pose0.position cast blend 0 pose0.position @ cast lerp
pose0.orientation pose1.orientation 0 pose0.orientation @ quaternionCast blend 0 pose0.orientation @ cast nlerp pose
] pfunc;
inverse: ["Pose" hasSchemaName] [
pose0:;
pose0.position neg pose0.orientation 0 pose0.position @ quaternionCast matrix trans *
pose0.orientation conj pose
] pfunc;
mirrorVertically: [
pose: z:;;
pose "Pose" hasSchemaName
] [
pose0: z:;;
(
0 pose0.position @ new
1 pose0.position @ new
z 0 pose0.position @ cast dup 2 pose0.position @ - +
)
(
0 pose0.orientation @ neg
1 pose0.orientation @ neg
2 pose0.orientation @ new
3 pose0.orientation @ new
) quaternion pose
] pfunc;
pose: [
position0: orientation0:;;
{
position: position0 new;
orientation: orientation0 new;
getMatrix: [orientation matrix];
scale: [0 position @ cast position * !position];
translate: [ position cast position + !position];
SCHEMA_NAME: "Pose" virtual;
}
];
poseCast: [
pose0: Schema: Ref virtual;;
pose0.position @Schema newVarOfTheSameType 3 Vector cast pose0.orientation @Schema quaternionCast pose
];