@pawells/math-extended 1.0.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/build/angles.d.ts +43 -3
- package/build/angles.d.ts.map +1 -1
- package/build/angles.js +61 -34
- package/build/angles.js.map +1 -1
- package/build/clamp.d.ts +5 -3
- package/build/clamp.d.ts.map +1 -1
- package/build/clamp.js +5 -3
- package/build/clamp.js.map +1 -1
- package/build/interpolation.d.ts +444 -67
- package/build/interpolation.d.ts.map +1 -1
- package/build/interpolation.js +444 -67
- package/build/interpolation.js.map +1 -1
- package/build/matrices/_exports.d.ts +13 -0
- package/build/matrices/_exports.d.ts.map +1 -0
- package/build/matrices/_exports.js +13 -0
- package/build/matrices/_exports.js.map +1 -0
- package/build/matrices/arithmetic.d.ts +170 -181
- package/build/matrices/arithmetic.d.ts.map +1 -1
- package/build/matrices/arithmetic.js +192 -202
- package/build/matrices/arithmetic.js.map +1 -1
- package/build/matrices/asserts.d.ts +244 -116
- package/build/matrices/asserts.d.ts.map +1 -1
- package/build/matrices/asserts.js +291 -94
- package/build/matrices/asserts.js.map +1 -1
- package/build/matrices/core.d.ts +40 -41
- package/build/matrices/core.d.ts.map +1 -1
- package/build/matrices/core.js +12 -13
- package/build/matrices/core.js.map +1 -1
- package/build/matrices/decompositions.d.ts +121 -124
- package/build/matrices/decompositions.d.ts.map +1 -1
- package/build/matrices/decompositions.js +168 -226
- package/build/matrices/decompositions.js.map +1 -1
- package/build/matrices/index.d.ts +3 -2
- package/build/matrices/index.d.ts.map +1 -1
- package/build/matrices/index.js +5 -2
- package/build/matrices/index.js.map +1 -1
- package/build/matrices/linear-algebra.d.ts +18 -13
- package/build/matrices/linear-algebra.d.ts.map +1 -1
- package/build/matrices/linear-algebra.js +58 -23
- package/build/matrices/linear-algebra.js.map +1 -1
- package/build/matrices/normalization.d.ts +8 -8
- package/build/matrices/transformations.d.ts +184 -168
- package/build/matrices/transformations.d.ts.map +1 -1
- package/build/matrices/transformations.js +99 -83
- package/build/matrices/transformations.js.map +1 -1
- package/build/matrices/types.d.ts +12 -12
- package/build/matrices/types.d.ts.map +1 -1
- package/build/quaternions/_exports.d.ts +11 -0
- package/build/quaternions/_exports.d.ts.map +1 -0
- package/build/quaternions/_exports.js +11 -0
- package/build/quaternions/_exports.js.map +1 -0
- package/build/quaternions/asserts.d.ts +115 -7
- package/build/quaternions/asserts.d.ts.map +1 -1
- package/build/quaternions/asserts.js +162 -8
- package/build/quaternions/asserts.js.map +1 -1
- package/build/quaternions/conversions.d.ts +31 -21
- package/build/quaternions/conversions.d.ts.map +1 -1
- package/build/quaternions/conversions.js +28 -18
- package/build/quaternions/conversions.js.map +1 -1
- package/build/quaternions/core.d.ts +73 -41
- package/build/quaternions/core.d.ts.map +1 -1
- package/build/quaternions/core.js +84 -49
- package/build/quaternions/core.js.map +1 -1
- package/build/quaternions/index.d.ts +3 -2
- package/build/quaternions/index.d.ts.map +1 -1
- package/build/quaternions/index.js +5 -2
- package/build/quaternions/index.js.map +1 -1
- package/build/quaternions/interpolation.d.ts +15 -9
- package/build/quaternions/interpolation.d.ts.map +1 -1
- package/build/quaternions/interpolation.js +15 -9
- package/build/quaternions/interpolation.js.map +1 -1
- package/build/quaternions/predefined.d.ts +9 -3
- package/build/quaternions/predefined.d.ts.map +1 -1
- package/build/quaternions/predefined.js +9 -3
- package/build/quaternions/predefined.js.map +1 -1
- package/build/quaternions/types.d.ts +3 -3
- package/build/random.d.ts +5 -2
- package/build/random.d.ts.map +1 -1
- package/build/random.js +20 -17
- package/build/random.js.map +1 -1
- package/build/vectors/_exports.d.ts +10 -0
- package/build/vectors/_exports.d.ts.map +1 -0
- package/build/vectors/_exports.js +10 -0
- package/build/vectors/_exports.js.map +1 -0
- package/build/vectors/asserts.d.ts +153 -49
- package/build/vectors/asserts.d.ts.map +1 -1
- package/build/vectors/asserts.js +202 -52
- package/build/vectors/asserts.js.map +1 -1
- package/build/vectors/core.d.ts +216 -137
- package/build/vectors/core.d.ts.map +1 -1
- package/build/vectors/core.js +217 -158
- package/build/vectors/core.js.map +1 -1
- package/build/vectors/index.d.ts +1 -0
- package/build/vectors/index.d.ts.map +1 -1
- package/build/vectors/index.js +3 -0
- package/build/vectors/index.js.map +1 -1
- package/build/vectors/interpolation.d.ts +39 -27
- package/build/vectors/interpolation.d.ts.map +1 -1
- package/build/vectors/interpolation.js +39 -27
- package/build/vectors/interpolation.js.map +1 -1
- package/build/vectors/predefined.d.ts +48 -24
- package/build/vectors/predefined.d.ts.map +1 -1
- package/build/vectors/predefined.js +38 -18
- package/build/vectors/predefined.js.map +1 -1
- package/package.json +12 -15
|
@@ -11,8 +11,10 @@ import { TQuaternion, TEulerAngles, TAxisAngle } from './types.js';
|
|
|
11
11
|
* @returns Identity quaternion [0, 0, 0, 1]
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const identity = QuaternionIdentity();
|
|
16
|
+
* console.log(identity); // [0, 0, 0, 1]
|
|
17
|
+
* ```
|
|
16
18
|
*/
|
|
17
19
|
export declare function QuaternionIdentity(): TQuaternion;
|
|
18
20
|
/**
|
|
@@ -23,9 +25,11 @@ export declare function QuaternionIdentity(): TQuaternion;
|
|
|
23
25
|
* @returns A new quaternion with identical components
|
|
24
26
|
*
|
|
25
27
|
* @example
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const original = [0, 0, 0.707, 0.707];
|
|
30
|
+
* const copy = QuaternionClone(original);
|
|
31
|
+
* copy[0] = 1; // original remains unchanged
|
|
32
|
+
* ```
|
|
29
33
|
*/
|
|
30
34
|
export declare function QuaternionClone(quaternion: TQuaternion): TQuaternion;
|
|
31
35
|
/**
|
|
@@ -40,10 +44,12 @@ export declare function QuaternionClone(quaternion: TQuaternion): TQuaternion;
|
|
|
40
44
|
* @returns True if quaternions are equal within tolerance
|
|
41
45
|
*
|
|
42
46
|
* @example
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const q1 = [0, 0, 0, 1];
|
|
49
|
+
* const q2 = [0, 0, 0, -1];
|
|
50
|
+
* console.log(QuaternionEquals(q1, q2)); // false (different components)
|
|
51
|
+
* console.log(QuaternionEquals(q1, q2, 1e-6, true)); // true (same rotation)
|
|
52
|
+
* ```
|
|
47
53
|
*/
|
|
48
54
|
export declare function QuaternionEquals(a: TQuaternion, b: TQuaternion, tolerance?: number, checkEquivalence?: boolean): boolean;
|
|
49
55
|
/**
|
|
@@ -54,8 +60,10 @@ export declare function QuaternionEquals(a: TQuaternion, b: TQuaternion, toleran
|
|
|
54
60
|
* @returns The magnitude of the quaternion
|
|
55
61
|
*
|
|
56
62
|
* @example
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const q = [0, 0, 0, 1];
|
|
65
|
+
* console.log(QuaternionMagnitude(q)); // 1
|
|
66
|
+
* ```
|
|
59
67
|
*/
|
|
60
68
|
export declare function QuaternionMagnitude(quaternion: TQuaternion): number;
|
|
61
69
|
/**
|
|
@@ -66,9 +74,11 @@ export declare function QuaternionMagnitude(quaternion: TQuaternion): number;
|
|
|
66
74
|
* @returns A normalized quaternion with magnitude 1
|
|
67
75
|
*
|
|
68
76
|
* @example
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const q = [1, 1, 1, 1];
|
|
79
|
+
* const normalized = QuaternionNormalize(q);
|
|
80
|
+
* console.log(QuaternionMagnitude(normalized)); // 1
|
|
81
|
+
* ```
|
|
72
82
|
*/
|
|
73
83
|
export declare function QuaternionNormalize(quaternion: TQuaternion): TQuaternion;
|
|
74
84
|
/**
|
|
@@ -80,9 +90,11 @@ export declare function QuaternionNormalize(quaternion: TQuaternion): TQuaternio
|
|
|
80
90
|
* @returns The conjugate quaternion
|
|
81
91
|
*
|
|
82
92
|
* @example
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const q = [0.5, 0.5, 0.5, 0.5];
|
|
95
|
+
* const conjugate = QuaternionConjugate(q);
|
|
96
|
+
* console.log(conjugate); // [-0.5, -0.5, -0.5, 0.5]
|
|
97
|
+
* ```
|
|
86
98
|
*/
|
|
87
99
|
export declare function QuaternionConjugate(quaternion: TQuaternion): TQuaternion;
|
|
88
100
|
/**
|
|
@@ -94,8 +106,10 @@ export declare function QuaternionConjugate(quaternion: TQuaternion): TQuaternio
|
|
|
94
106
|
* @returns The inverse quaternion
|
|
95
107
|
*
|
|
96
108
|
* @example
|
|
97
|
-
|
|
98
|
-
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z
|
|
111
|
+
* const inverse = QuaternionInverse(q); // -90° rotation around Z
|
|
112
|
+
* ```
|
|
99
113
|
*/
|
|
100
114
|
export declare function QuaternionInverse(quaternion: TQuaternion): TQuaternion;
|
|
101
115
|
/**
|
|
@@ -108,9 +122,11 @@ export declare function QuaternionInverse(quaternion: TQuaternion): TQuaternion;
|
|
|
108
122
|
* @returns The product quaternion representing the combined rotation
|
|
109
123
|
*
|
|
110
124
|
* @example
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const rotX = QuaternionFromAxisAngle([1, 0, 0], Math.PI/2); // 90° around X
|
|
127
|
+
* const rotY = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2); // 90° around Y
|
|
128
|
+
* const combined = QuaternionMultiply(rotX, rotY); // Y rotation then X rotation
|
|
129
|
+
* ```
|
|
114
130
|
*/
|
|
115
131
|
export declare function QuaternionMultiply(a: TQuaternion, b: TQuaternion): TQuaternion;
|
|
116
132
|
/**
|
|
@@ -122,9 +138,11 @@ export declare function QuaternionMultiply(a: TQuaternion, b: TQuaternion): TQua
|
|
|
122
138
|
* @returns A quaternion representing the rotation
|
|
123
139
|
*
|
|
124
140
|
* @example
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const axis = [0, 1, 0]; // Y-axis
|
|
143
|
+
* const angle = Math.PI / 2; // 90 degrees
|
|
144
|
+
* const q = QuaternionFromAxisAngle(axis, angle);
|
|
145
|
+
* ```
|
|
128
146
|
*/
|
|
129
147
|
export declare function QuaternionFromAxisAngle(axis: TVector3, angle: number): TQuaternion;
|
|
130
148
|
/**
|
|
@@ -137,13 +155,19 @@ export declare function QuaternionFromAxisAngleVector(axisAngle: TAxisAngle): TQ
|
|
|
137
155
|
/**
|
|
138
156
|
* Converts a quaternion to axis-angle representation.
|
|
139
157
|
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
158
|
+
* The quaternion is first normalized to canonical form (w ≥ 0) so that q and -q,
|
|
159
|
+
* which represent the same rotation, always produce the same axis-angle result.
|
|
160
|
+
*
|
|
161
|
+
* @param quaternion - The quaternion to convert (must be normalized)
|
|
162
|
+
* @returns The axis-angle representation as [x, y, z, angle] where angle ∈ [0, π]
|
|
163
|
+
* @throws {Error} If the quaternion is not normalized
|
|
142
164
|
*
|
|
143
165
|
* @example
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const q = [0, 0.707, 0, 0.707]; // 90° around Y-axis
|
|
168
|
+
* const axisAngle = QuaternionToAxisAngle(q);
|
|
169
|
+
* console.log(axisAngle); // [0, 1, 0, π/2]
|
|
170
|
+
* ```
|
|
147
171
|
*/
|
|
148
172
|
export declare function QuaternionToAxisAngle(quaternion: TQuaternion): TAxisAngle;
|
|
149
173
|
/**
|
|
@@ -154,8 +178,10 @@ export declare function QuaternionToAxisAngle(quaternion: TQuaternion): TAxisAng
|
|
|
154
178
|
* @returns A quaternion representing the rotation
|
|
155
179
|
*
|
|
156
180
|
* @example
|
|
157
|
-
|
|
158
|
-
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const euler = [0, Math.PI/4, 0]; // 45° pitch
|
|
183
|
+
* const q = QuaternionFromEuler(euler);
|
|
184
|
+
* ```
|
|
159
185
|
*/
|
|
160
186
|
export declare function QuaternionFromEuler(euler: TEulerAngles): TQuaternion;
|
|
161
187
|
/**
|
|
@@ -166,9 +192,11 @@ export declare function QuaternionFromEuler(euler: TEulerAngles): TQuaternion;
|
|
|
166
192
|
* @returns Euler angles as [x, y, z] in radians
|
|
167
193
|
*
|
|
168
194
|
* @example
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const q = [0, 0.383, 0, 0.924]; // ~45° around Y-axis
|
|
197
|
+
* const euler = QuaternionToEuler(q);
|
|
198
|
+
* console.log(euler); // [0, π/4, 0]
|
|
199
|
+
* ```
|
|
172
200
|
*/
|
|
173
201
|
export declare function QuaternionToEuler(quaternion: TQuaternion): TEulerAngles;
|
|
174
202
|
/**
|
|
@@ -180,9 +208,11 @@ export declare function QuaternionToEuler(quaternion: TQuaternion): TEulerAngles
|
|
|
180
208
|
* @returns The rotated vector
|
|
181
209
|
*
|
|
182
210
|
* @example
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
211
|
+
* ```typescript
|
|
212
|
+
* const q = QuaternionFromAxisAngle([0, 0, 1], Math.PI/2); // 90° around Z
|
|
213
|
+
* const v = [1, 0, 0]; // Point along X-axis
|
|
214
|
+
* const rotated = QuaternionRotateVector(q, v); // Should point along Y-axis
|
|
215
|
+
* ```
|
|
186
216
|
*/
|
|
187
217
|
export declare function QuaternionRotateVector(quaternion: TQuaternion, vector: TVector3): TVector3;
|
|
188
218
|
/**
|
|
@@ -195,9 +225,11 @@ export declare function QuaternionRotateVector(quaternion: TQuaternion, vector:
|
|
|
195
225
|
* @returns Interpolated quaternion
|
|
196
226
|
*
|
|
197
227
|
* @example
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
228
|
+
* ```typescript
|
|
229
|
+
* const q1 = QuaternionIdentity();
|
|
230
|
+
* const q2 = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2);
|
|
231
|
+
* const halfway = QuaternionSLERP(q1, q2, 0.5); // 45° rotation
|
|
232
|
+
* ```
|
|
201
233
|
*/
|
|
202
234
|
export declare function QuaternionSLERP(a: TQuaternion, b: TQuaternion, t: number): TQuaternion;
|
|
203
235
|
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/quaternions/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAMnE
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/quaternions/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAMnE;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,CAEhD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW,CAGpE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,SAAS,GAAE,MAAa,EAAE,gBAAgB,GAAE,OAAe,GAAG,OAAO,CAcrI;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,WAAW,GAAG,MAAM,CAGnE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,UA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
+
* ```typescript
|
|
18
|
+
* const identity = QuaternionIdentity();
|
|
19
|
+
* console.log(identity); // [0, 0, 0, 1]
|
|
20
|
+
* ```
|
|
19
21
|
*/
|
|
20
22
|
export function QuaternionIdentity() {
|
|
21
23
|
return [0, 0, 0, 1];
|
|
@@ -28,9 +30,11 @@ export function QuaternionIdentity() {
|
|
|
28
30
|
* @returns A new quaternion with identical components
|
|
29
31
|
*
|
|
30
32
|
* @example
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const original = [0, 0, 0.707, 0.707];
|
|
35
|
+
* const copy = QuaternionClone(original);
|
|
36
|
+
* copy[0] = 1; // original remains unchanged
|
|
37
|
+
* ```
|
|
34
38
|
*/
|
|
35
39
|
export function QuaternionClone(quaternion) {
|
|
36
40
|
AssertQuaternion(quaternion);
|
|
@@ -48,10 +52,12 @@ export function QuaternionClone(quaternion) {
|
|
|
48
52
|
* @returns True if quaternions are equal within tolerance
|
|
49
53
|
*
|
|
50
54
|
* @example
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const q1 = [0, 0, 0, 1];
|
|
57
|
+
* const q2 = [0, 0, 0, -1];
|
|
58
|
+
* console.log(QuaternionEquals(q1, q2)); // false (different components)
|
|
59
|
+
* console.log(QuaternionEquals(q1, q2, 1e-6, true)); // true (same rotation)
|
|
60
|
+
* ```
|
|
55
61
|
*/
|
|
56
62
|
export function QuaternionEquals(a, b, tolerance = 1e-6, checkEquivalence = false) {
|
|
57
63
|
AssertQuaternion(a);
|
|
@@ -73,8 +79,10 @@ export function QuaternionEquals(a, b, tolerance = 1e-6, checkEquivalence = fals
|
|
|
73
79
|
* @returns The magnitude of the quaternion
|
|
74
80
|
*
|
|
75
81
|
* @example
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const q = [0, 0, 0, 1];
|
|
84
|
+
* console.log(QuaternionMagnitude(q)); // 1
|
|
85
|
+
* ```
|
|
78
86
|
*/
|
|
79
87
|
export function QuaternionMagnitude(quaternion) {
|
|
80
88
|
AssertQuaternion(quaternion);
|
|
@@ -88,9 +96,11 @@ export function QuaternionMagnitude(quaternion) {
|
|
|
88
96
|
* @returns A normalized quaternion with magnitude 1
|
|
89
97
|
*
|
|
90
98
|
* @example
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const q = [1, 1, 1, 1];
|
|
101
|
+
* const normalized = QuaternionNormalize(q);
|
|
102
|
+
* console.log(QuaternionMagnitude(normalized)); // 1
|
|
103
|
+
* ```
|
|
94
104
|
*/
|
|
95
105
|
export function QuaternionNormalize(quaternion) {
|
|
96
106
|
AssertQuaternion(quaternion);
|
|
@@ -105,9 +115,11 @@ export function QuaternionNormalize(quaternion) {
|
|
|
105
115
|
* @returns The conjugate quaternion
|
|
106
116
|
*
|
|
107
117
|
* @example
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const q = [0.5, 0.5, 0.5, 0.5];
|
|
120
|
+
* const conjugate = QuaternionConjugate(q);
|
|
121
|
+
* console.log(conjugate); // [-0.5, -0.5, -0.5, 0.5]
|
|
122
|
+
* ```
|
|
111
123
|
*/
|
|
112
124
|
export function QuaternionConjugate(quaternion) {
|
|
113
125
|
AssertQuaternion(quaternion);
|
|
@@ -123,8 +135,10 @@ export function QuaternionConjugate(quaternion) {
|
|
|
123
135
|
* @returns The inverse quaternion
|
|
124
136
|
*
|
|
125
137
|
* @example
|
|
126
|
-
|
|
127
|
-
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z
|
|
140
|
+
* const inverse = QuaternionInverse(q); // -90° rotation around Z
|
|
141
|
+
* ```
|
|
128
142
|
*/
|
|
129
143
|
export function QuaternionInverse(quaternion) {
|
|
130
144
|
AssertQuaternion(quaternion);
|
|
@@ -151,9 +165,11 @@ export function QuaternionInverse(quaternion) {
|
|
|
151
165
|
* @returns The product quaternion representing the combined rotation
|
|
152
166
|
*
|
|
153
167
|
* @example
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const rotX = QuaternionFromAxisAngle([1, 0, 0], Math.PI/2); // 90° around X
|
|
170
|
+
* const rotY = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2); // 90° around Y
|
|
171
|
+
* const combined = QuaternionMultiply(rotX, rotY); // Y rotation then X rotation
|
|
172
|
+
* ```
|
|
157
173
|
*/
|
|
158
174
|
export function QuaternionMultiply(a, b) {
|
|
159
175
|
AssertQuaternion(a);
|
|
@@ -176,9 +192,11 @@ export function QuaternionMultiply(a, b) {
|
|
|
176
192
|
* @returns A quaternion representing the rotation
|
|
177
193
|
*
|
|
178
194
|
* @example
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const axis = [0, 1, 0]; // Y-axis
|
|
197
|
+
* const angle = Math.PI / 2; // 90 degrees
|
|
198
|
+
* const q = QuaternionFromAxisAngle(axis, angle);
|
|
199
|
+
* ```
|
|
182
200
|
*/
|
|
183
201
|
export function QuaternionFromAxisAngle(axis, angle) {
|
|
184
202
|
const normalizedAxis = VectorNormalize(axis);
|
|
@@ -206,31 +224,40 @@ export function QuaternionFromAxisAngleVector(axisAngle) {
|
|
|
206
224
|
/**
|
|
207
225
|
* Converts a quaternion to axis-angle representation.
|
|
208
226
|
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
227
|
+
* The quaternion is first normalized to canonical form (w ≥ 0) so that q and -q,
|
|
228
|
+
* which represent the same rotation, always produce the same axis-angle result.
|
|
229
|
+
*
|
|
230
|
+
* @param quaternion - The quaternion to convert (must be normalized)
|
|
231
|
+
* @returns The axis-angle representation as [x, y, z, angle] where angle ∈ [0, π]
|
|
232
|
+
* @throws {Error} If the quaternion is not normalized
|
|
211
233
|
*
|
|
212
234
|
* @example
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
235
|
+
* ```typescript
|
|
236
|
+
* const q = [0, 0.707, 0, 0.707]; // 90° around Y-axis
|
|
237
|
+
* const axisAngle = QuaternionToAxisAngle(q);
|
|
238
|
+
* console.log(axisAngle); // [0, 1, 0, π/2]
|
|
239
|
+
* ```
|
|
216
240
|
*/
|
|
217
241
|
export function QuaternionToAxisAngle(quaternion) {
|
|
218
242
|
AssertNormalizedQuaternion(quaternion);
|
|
219
243
|
const [x, y, z, w] = quaternion;
|
|
244
|
+
// Normalize to canonical form with w >= 0 (q and -q represent the same rotation).
|
|
245
|
+
// Without this, a quaternion with w < 0 would pair the wrong axis with the wrong angle.
|
|
246
|
+
const [qx, qy, qz, qw] = w < 0 ? [-x, -y, -z, -w] : [x, y, z, w];
|
|
220
247
|
// Handle identity quaternion
|
|
221
|
-
if (
|
|
248
|
+
if (qw >= 1) {
|
|
222
249
|
return [1, 0, 0, 0]; // Arbitrary axis, zero angle
|
|
223
250
|
}
|
|
224
|
-
const angle = 2 * Math.acos(Math.min(1,
|
|
225
|
-
const sinHalfAngle = Math.sqrt(1 - (
|
|
251
|
+
const angle = 2 * Math.acos(Math.min(1, qw));
|
|
252
|
+
const sinHalfAngle = Math.sqrt(1 - (qw * qw));
|
|
226
253
|
if (sinHalfAngle < QUATERNION_ANGLE_TOLERANCE) {
|
|
227
254
|
// Avoid division by zero for small angles
|
|
228
255
|
return [1, 0, 0, 0];
|
|
229
256
|
}
|
|
230
257
|
return [
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
258
|
+
qx / sinHalfAngle,
|
|
259
|
+
qy / sinHalfAngle,
|
|
260
|
+
qz / sinHalfAngle,
|
|
234
261
|
angle,
|
|
235
262
|
];
|
|
236
263
|
}
|
|
@@ -242,8 +269,10 @@ export function QuaternionToAxisAngle(quaternion) {
|
|
|
242
269
|
* @returns A quaternion representing the rotation
|
|
243
270
|
*
|
|
244
271
|
* @example
|
|
245
|
-
|
|
246
|
-
|
|
272
|
+
* ```typescript
|
|
273
|
+
* const euler = [0, Math.PI/4, 0]; // 45° pitch
|
|
274
|
+
* const q = QuaternionFromEuler(euler);
|
|
275
|
+
* ```
|
|
247
276
|
*/
|
|
248
277
|
export function QuaternionFromEuler(euler) {
|
|
249
278
|
AssertEulerAngles(euler);
|
|
@@ -269,9 +298,11 @@ export function QuaternionFromEuler(euler) {
|
|
|
269
298
|
* @returns Euler angles as [x, y, z] in radians
|
|
270
299
|
*
|
|
271
300
|
* @example
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
301
|
+
* ```typescript
|
|
302
|
+
* const q = [0, 0.383, 0, 0.924]; // ~45° around Y-axis
|
|
303
|
+
* const euler = QuaternionToEuler(q);
|
|
304
|
+
* console.log(euler); // [0, π/4, 0]
|
|
305
|
+
* ```
|
|
275
306
|
*/
|
|
276
307
|
export function QuaternionToEuler(quaternion) {
|
|
277
308
|
AssertNormalizedQuaternion(quaternion);
|
|
@@ -298,9 +329,11 @@ export function QuaternionToEuler(quaternion) {
|
|
|
298
329
|
* @returns The rotated vector
|
|
299
330
|
*
|
|
300
331
|
* @example
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
332
|
+
* ```typescript
|
|
333
|
+
* const q = QuaternionFromAxisAngle([0, 0, 1], Math.PI/2); // 90° around Z
|
|
334
|
+
* const v = [1, 0, 0]; // Point along X-axis
|
|
335
|
+
* const rotated = QuaternionRotateVector(q, v); // Should point along Y-axis
|
|
336
|
+
* ```
|
|
304
337
|
*/
|
|
305
338
|
export function QuaternionRotateVector(quaternion, vector) {
|
|
306
339
|
AssertNormalizedQuaternion(quaternion);
|
|
@@ -332,9 +365,11 @@ export function QuaternionRotateVector(quaternion, vector) {
|
|
|
332
365
|
* @returns Interpolated quaternion
|
|
333
366
|
*
|
|
334
367
|
* @example
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
368
|
+
* ```typescript
|
|
369
|
+
* const q1 = QuaternionIdentity();
|
|
370
|
+
* const q2 = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2);
|
|
371
|
+
* const halfway = QuaternionSLERP(q1, q2, 0.5); // 45° rotation
|
|
372
|
+
* ```
|
|
338
373
|
*/
|
|
339
374
|
export function QuaternionSLERP(a, b, t) {
|
|
340
375
|
AssertNormalizedQuaternion(a);
|
|
@@ -359,8 +394,8 @@ export function QuaternionSLERP(a, b, t) {
|
|
|
359
394
|
];
|
|
360
395
|
return QuaternionNormalize(result);
|
|
361
396
|
}
|
|
362
|
-
// Calculate interpolation factors
|
|
363
|
-
const theta = Math.acos(Math.
|
|
397
|
+
// Calculate interpolation factors (dot is guaranteed >= 0 from the sign-flip above)
|
|
398
|
+
const theta = Math.acos(Math.min(1, dot));
|
|
364
399
|
const sinTheta = Math.sin(theta);
|
|
365
400
|
const factor1 = Math.sin((1 - clampedT) * theta) / sinTheta;
|
|
366
401
|
const factor2 = Math.sin(clampedT * theta) / sinTheta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/quaternions/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE1H,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGhH,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAC7C,MAAM,0BAA0B,GAAG,IAAI,CAAC;AACxC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/quaternions/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,Y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|
+
export * from './core.js';
|
|
1
3
|
export * from './asserts.js';
|
|
2
4
|
export * from './conversions.js';
|
|
3
|
-
export * from './core.js';
|
|
4
5
|
export * from './interpolation.js';
|
|
5
6
|
export * from './predefined.js';
|
|
6
|
-
export * from './
|
|
7
|
+
export * as QuaternionNamespace from './_exports.js';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/quaternions/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/quaternions/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAGhC,OAAO,KAAK,mBAAmB,MAAM,eAAe,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
// Named re-exports for direct access
|
|
2
|
+
export * from './types.js';
|
|
3
|
+
export * from './core.js';
|
|
1
4
|
export * from './asserts.js';
|
|
2
5
|
export * from './conversions.js';
|
|
3
|
-
export * from './core.js';
|
|
4
6
|
export * from './interpolation.js';
|
|
5
7
|
export * from './predefined.js';
|
|
6
|
-
|
|
8
|
+
// Namespace re-exports for grouped access
|
|
9
|
+
export * as QuaternionNamespace from './_exports.js';
|
|
7
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/quaternions/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/quaternions/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAEhC,0CAA0C;AAC1C,OAAO,KAAK,mBAAmB,MAAM,eAAe,CAAC"}
|
|
@@ -14,9 +14,11 @@ import { TQuaternion } from './types.js';
|
|
|
14
14
|
* @returns Interpolated and normalized quaternion
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const q1 = [0, 0, 0, 1];
|
|
19
|
+
* const q2 = [0, 0, 0.707, 0.707];
|
|
20
|
+
* const interpolated = QuaternionNLERP(q1, q2, 0.5);
|
|
21
|
+
* ```
|
|
20
22
|
*/
|
|
21
23
|
export declare function QuaternionNLERP(a: TQuaternion, b: TQuaternion, t: number): TQuaternion;
|
|
22
24
|
/**
|
|
@@ -31,9 +33,11 @@ export declare function QuaternionNLERP(a: TQuaternion, b: TQuaternion, t: numbe
|
|
|
31
33
|
* @returns Smoothly interpolated quaternion
|
|
32
34
|
*
|
|
33
35
|
* @example
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Create a smooth path through multiple rotations
|
|
38
|
+
* const path = [q0, q1, q2, q3]; // Array of quaternions
|
|
39
|
+
* const smooth = QuaternionSQUAD(path[0], path[1], path[2], path[3], 0.5);
|
|
40
|
+
* ```
|
|
37
41
|
*/
|
|
38
42
|
export declare function QuaternionSQUAD(q0: TQuaternion, q1: TQuaternion, q2: TQuaternion, q3: TQuaternion, t: number): TQuaternion;
|
|
39
43
|
/**
|
|
@@ -46,9 +50,11 @@ export declare function QuaternionSQUAD(q0: TQuaternion, q1: TQuaternion, q2: TQ
|
|
|
46
50
|
* @returns Function that takes t ∈ [0, 1] and returns interpolated quaternion
|
|
47
51
|
*
|
|
48
52
|
* @example
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const path = [q1, q2, q3, q4];
|
|
55
|
+
* const interpolator = QuaternionCreatePath(path, 'slerp');
|
|
56
|
+
* const halfway = interpolator(0.5); // Interpolated quaternion at 50% along path
|
|
57
|
+
* ```
|
|
52
58
|
*/
|
|
53
59
|
export declare function QuaternionCreatePath(quaternions: TQuaternion[], method?: 'slerp' | 'nlerp' | 'squad'): (t: number) => TQuaternion;
|
|
54
60
|
//# sourceMappingURL=interpolation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../src/quaternions/interpolation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAMzC
|
|
1
|
+
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../src/quaternions/interpolation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAMzC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAoBtF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAiB1H;AAkFD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,WAAW,EAAE,EAC1B,MAAM,GAAE,OAAO,GAAG,OAAO,GAAG,OAAiB,GAC3C,CAAC,CAAC,EAAE,MAAM,KAAK,WAAW,CAkD5B"}
|