@pawells/math-extended 2.0.0 → 3.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 +15 -21
- package/build/clamp.d.ts +5 -5
- package/build/clamp.js +5 -5
- package/build/core.d.ts +23 -0
- package/build/core.d.ts.map +1 -0
- package/build/core.js +25 -0
- package/build/core.js.map +1 -0
- package/build/index.d.ts +1 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -6
- package/build/index.js.map +1 -1
- package/build/interpolation.d.ts +158 -171
- package/build/interpolation.d.ts.map +1 -1
- package/build/interpolation.js +162 -181
- package/build/interpolation.js.map +1 -1
- package/build/matrices/arithmetic.d.ts +132 -132
- package/build/matrices/arithmetic.d.ts.map +1 -1
- package/build/matrices/arithmetic.js +194 -226
- package/build/matrices/arithmetic.js.map +1 -1
- package/build/matrices/asserts.d.ts +30 -408
- package/build/matrices/asserts.d.ts.map +1 -1
- package/build/matrices/asserts.js +98 -542
- package/build/matrices/asserts.js.map +1 -1
- package/build/matrices/core.d.ts +117 -46
- package/build/matrices/core.d.ts.map +1 -1
- package/build/matrices/core.js +127 -103
- package/build/matrices/core.js.map +1 -1
- package/build/matrices/decompositions.d.ts +95 -96
- package/build/matrices/decompositions.d.ts.map +1 -1
- package/build/matrices/decompositions.js +119 -160
- package/build/matrices/decompositions.js.map +1 -1
- package/build/matrices/index.d.ts +0 -1
- package/build/matrices/index.d.ts.map +1 -1
- package/build/matrices/index.js +0 -3
- package/build/matrices/index.js.map +1 -1
- package/build/matrices/linear-algebra.d.ts +45 -8
- package/build/matrices/linear-algebra.d.ts.map +1 -1
- package/build/matrices/linear-algebra.js +76 -32
- package/build/matrices/linear-algebra.js.map +1 -1
- package/build/matrices/normalization.d.ts +29 -8
- package/build/matrices/normalization.d.ts.map +1 -1
- package/build/matrices/normalization.js +32 -23
- package/build/matrices/normalization.js.map +1 -1
- package/build/matrices/transformations.d.ts +116 -148
- package/build/matrices/transformations.d.ts.map +1 -1
- package/build/matrices/transformations.js +69 -91
- package/build/matrices/transformations.js.map +1 -1
- package/build/matrices/types.d.ts +32 -60
- package/build/matrices/types.d.ts.map +1 -1
- package/build/matrices/types.js +63 -1
- package/build/matrices/types.js.map +1 -1
- package/build/quaternions/asserts.d.ts +29 -38
- package/build/quaternions/asserts.d.ts.map +1 -1
- package/build/quaternions/asserts.js +61 -77
- package/build/quaternions/asserts.js.map +1 -1
- package/build/quaternions/conversions.d.ts +26 -26
- package/build/quaternions/conversions.d.ts.map +1 -1
- package/build/quaternions/conversions.js +24 -24
- package/build/quaternions/core.d.ts +70 -69
- package/build/quaternions/core.d.ts.map +1 -1
- package/build/quaternions/core.js +71 -71
- package/build/quaternions/core.js.map +1 -1
- package/build/quaternions/index.d.ts +0 -1
- package/build/quaternions/index.d.ts.map +1 -1
- package/build/quaternions/index.js +0 -2
- package/build/quaternions/index.js.map +1 -1
- package/build/quaternions/interpolation.d.ts +16 -16
- package/build/quaternions/interpolation.d.ts.map +1 -1
- package/build/quaternions/interpolation.js +21 -21
- package/build/quaternions/interpolation.js.map +1 -1
- package/build/quaternions/predefined.d.ts +10 -10
- package/build/quaternions/predefined.d.ts.map +1 -1
- package/build/quaternions/predefined.js +9 -9
- package/build/quaternions/types.d.ts +23 -12
- package/build/quaternions/types.d.ts.map +1 -1
- package/build/quaternions/types.js +51 -1
- package/build/quaternions/types.js.map +1 -1
- package/build/random.d.ts +66 -20
- package/build/random.d.ts.map +1 -1
- package/build/random.js +73 -20
- package/build/random.js.map +1 -1
- package/build/vectors/asserts.d.ts +50 -220
- package/build/vectors/asserts.d.ts.map +1 -1
- package/build/vectors/asserts.js +141 -327
- package/build/vectors/asserts.js.map +1 -1
- package/build/vectors/core.d.ts +182 -229
- package/build/vectors/core.d.ts.map +1 -1
- package/build/vectors/core.js +234 -288
- package/build/vectors/core.js.map +1 -1
- package/build/vectors/index.d.ts +0 -1
- package/build/vectors/index.d.ts.map +1 -1
- package/build/vectors/index.js +0 -2
- package/build/vectors/index.js.map +1 -1
- package/build/vectors/interpolation.d.ts +40 -40
- package/build/vectors/interpolation.d.ts.map +1 -1
- package/build/vectors/interpolation.js +75 -86
- package/build/vectors/interpolation.js.map +1 -1
- package/build/vectors/predefined.d.ts +31 -7
- package/build/vectors/predefined.d.ts.map +1 -1
- package/build/vectors/predefined.js +30 -6
- package/build/vectors/predefined.js.map +1 -1
- package/build/vectors/types.d.ts +26 -4
- package/build/vectors/types.d.ts.map +1 -1
- package/build/vectors/types.js +50 -1
- package/build/vectors/types.js.map +1 -1
- package/package.json +3 -2
- package/build/matrices/_exports.d.ts +0 -13
- package/build/matrices/_exports.d.ts.map +0 -1
- package/build/matrices/_exports.js +0 -13
- package/build/matrices/_exports.js.map +0 -1
- package/build/quaternions/_exports.d.ts +0 -11
- package/build/quaternions/_exports.d.ts.map +0 -1
- package/build/quaternions/_exports.js +0 -11
- package/build/quaternions/_exports.js.map +0 -1
- package/build/vectors/_exports.d.ts +0 -10
- package/build/vectors/_exports.d.ts.map +0 -1
- package/build/vectors/_exports.js +0 -10
- package/build/vectors/_exports.js.map +0 -1
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Core quaternion mathematics operations for rotation and orientation calculations.
|
|
3
3
|
* Provides comprehensive quaternion operations with conversion utilities and interpolation.
|
|
4
4
|
*/
|
|
5
|
-
import { TVector3 } from '../vectors/types.js';
|
|
6
|
-
import { TQuaternion, TEulerAngles, TAxisAngle } from './types.js';
|
|
5
|
+
import type { TVector3 } from '../vectors/types.js';
|
|
6
|
+
import type { TQuaternion, TEulerAngles, TAxisAngle } from './types.js';
|
|
7
|
+
export declare const QUATERNION_TOLERANCE = 0.000001;
|
|
7
8
|
/**
|
|
8
9
|
* Creates an identity quaternion representing no rotation.
|
|
9
10
|
* The identity quaternion is [0, 0, 0, 1] (x, y, z, w).
|
|
@@ -11,10 +12,10 @@ import { TQuaternion, TEulerAngles, TAxisAngle } from './types.js';
|
|
|
11
12
|
* @returns Identity quaternion [0, 0, 0, 1]
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const identity = QuaternionIdentity();
|
|
17
|
+
* console.log(identity); // [0, 0, 0, 1]
|
|
18
|
+
* ```
|
|
18
19
|
*/
|
|
19
20
|
export declare function QuaternionIdentity(): TQuaternion;
|
|
20
21
|
/**
|
|
@@ -25,11 +26,11 @@ export declare function QuaternionIdentity(): TQuaternion;
|
|
|
25
26
|
* @returns A new quaternion with identical components
|
|
26
27
|
*
|
|
27
28
|
* @example
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const original = [0, 0, 0.707, 0.707];
|
|
31
|
+
* const copy = QuaternionClone(original);
|
|
32
|
+
* copy[0] = 1; // original remains unchanged
|
|
33
|
+
* ```
|
|
33
34
|
*/
|
|
34
35
|
export declare function QuaternionClone(quaternion: TQuaternion): TQuaternion;
|
|
35
36
|
/**
|
|
@@ -44,12 +45,12 @@ export declare function QuaternionClone(quaternion: TQuaternion): TQuaternion;
|
|
|
44
45
|
* @returns True if quaternions are equal within tolerance
|
|
45
46
|
*
|
|
46
47
|
* @example
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const q1 = [0, 0, 0, 1];
|
|
50
|
+
* const q2 = [0, 0, 0, -1];
|
|
51
|
+
* console.log(QuaternionEquals(q1, q2)); // false (different components)
|
|
52
|
+
* console.log(QuaternionEquals(q1, q2, 1e-6, true)); // true (same rotation)
|
|
53
|
+
* ```
|
|
53
54
|
*/
|
|
54
55
|
export declare function QuaternionEquals(a: TQuaternion, b: TQuaternion, tolerance?: number, checkEquivalence?: boolean): boolean;
|
|
55
56
|
/**
|
|
@@ -60,10 +61,10 @@ export declare function QuaternionEquals(a: TQuaternion, b: TQuaternion, toleran
|
|
|
60
61
|
* @returns The magnitude of the quaternion
|
|
61
62
|
*
|
|
62
63
|
* @example
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const q = [0, 0, 0, 1];
|
|
66
|
+
* console.log(QuaternionMagnitude(q)); // 1
|
|
67
|
+
* ```
|
|
67
68
|
*/
|
|
68
69
|
export declare function QuaternionMagnitude(quaternion: TQuaternion): number;
|
|
69
70
|
/**
|
|
@@ -74,11 +75,11 @@ export declare function QuaternionMagnitude(quaternion: TQuaternion): number;
|
|
|
74
75
|
* @returns A normalized quaternion with magnitude 1
|
|
75
76
|
*
|
|
76
77
|
* @example
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const q = [1, 1, 1, 1];
|
|
80
|
+
* const normalized = QuaternionNormalize(q);
|
|
81
|
+
* console.log(QuaternionMagnitude(normalized)); // 1
|
|
82
|
+
* ```
|
|
82
83
|
*/
|
|
83
84
|
export declare function QuaternionNormalize(quaternion: TQuaternion): TQuaternion;
|
|
84
85
|
/**
|
|
@@ -90,11 +91,11 @@ export declare function QuaternionNormalize(quaternion: TQuaternion): TQuaternio
|
|
|
90
91
|
* @returns The conjugate quaternion
|
|
91
92
|
*
|
|
92
93
|
* @example
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const q = [0.5, 0.5, 0.5, 0.5];
|
|
96
|
+
* const conjugate = QuaternionConjugate(q);
|
|
97
|
+
* console.log(conjugate); // [-0.5, -0.5, -0.5, 0.5]
|
|
98
|
+
* ```
|
|
98
99
|
*/
|
|
99
100
|
export declare function QuaternionConjugate(quaternion: TQuaternion): TQuaternion;
|
|
100
101
|
/**
|
|
@@ -106,10 +107,10 @@ export declare function QuaternionConjugate(quaternion: TQuaternion): TQuaternio
|
|
|
106
107
|
* @returns The inverse quaternion
|
|
107
108
|
*
|
|
108
109
|
* @example
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z
|
|
112
|
+
* const inverse = QuaternionInverse(q); // -90° rotation around Z
|
|
113
|
+
* ```
|
|
113
114
|
*/
|
|
114
115
|
export declare function QuaternionInverse(quaternion: TQuaternion): TQuaternion;
|
|
115
116
|
/**
|
|
@@ -122,11 +123,11 @@ export declare function QuaternionInverse(quaternion: TQuaternion): TQuaternion;
|
|
|
122
123
|
* @returns The product quaternion representing the combined rotation
|
|
123
124
|
*
|
|
124
125
|
* @example
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const rotX = QuaternionFromAxisAngle([1, 0, 0], Math.PI/2); // 90° around X
|
|
128
|
+
* const rotY = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2); // 90° around Y
|
|
129
|
+
* const combined = QuaternionMultiply(rotX, rotY); // Y rotation then X rotation
|
|
130
|
+
* ```
|
|
130
131
|
*/
|
|
131
132
|
export declare function QuaternionMultiply(a: TQuaternion, b: TQuaternion): TQuaternion;
|
|
132
133
|
/**
|
|
@@ -138,11 +139,11 @@ export declare function QuaternionMultiply(a: TQuaternion, b: TQuaternion): TQua
|
|
|
138
139
|
* @returns A quaternion representing the rotation
|
|
139
140
|
*
|
|
140
141
|
* @example
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const axis = [0, 1, 0]; // Y-axis
|
|
144
|
+
* const angle = Math.PI / 2; // 90 degrees
|
|
145
|
+
* const q = QuaternionFromAxisAngle(axis, angle);
|
|
146
|
+
* ```
|
|
146
147
|
*/
|
|
147
148
|
export declare function QuaternionFromAxisAngle(axis: TVector3, angle: number): TQuaternion;
|
|
148
149
|
/**
|
|
@@ -163,11 +164,11 @@ export declare function QuaternionFromAxisAngleVector(axisAngle: TAxisAngle): TQ
|
|
|
163
164
|
* @throws {Error} If the quaternion is not normalized
|
|
164
165
|
*
|
|
165
166
|
* @example
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const q = [0, 0.707, 0, 0.707]; // 90° around Y-axis
|
|
169
|
+
* const axisAngle = QuaternionToAxisAngle(q);
|
|
170
|
+
* console.log(axisAngle); // [0, 1, 0, π/2]
|
|
171
|
+
* ```
|
|
171
172
|
*/
|
|
172
173
|
export declare function QuaternionToAxisAngle(quaternion: TQuaternion): TAxisAngle;
|
|
173
174
|
/**
|
|
@@ -178,10 +179,10 @@ export declare function QuaternionToAxisAngle(quaternion: TQuaternion): TAxisAng
|
|
|
178
179
|
* @returns A quaternion representing the rotation
|
|
179
180
|
*
|
|
180
181
|
* @example
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const euler = [0, Math.PI/4, 0]; // 45° pitch
|
|
184
|
+
* const q = QuaternionFromEuler(euler);
|
|
185
|
+
* ```
|
|
185
186
|
*/
|
|
186
187
|
export declare function QuaternionFromEuler(euler: TEulerAngles): TQuaternion;
|
|
187
188
|
/**
|
|
@@ -192,11 +193,11 @@ export declare function QuaternionFromEuler(euler: TEulerAngles): TQuaternion;
|
|
|
192
193
|
* @returns Euler angles as [x, y, z] in radians
|
|
193
194
|
*
|
|
194
195
|
* @example
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const q = [0, 0.383, 0, 0.924]; // ~45° around Y-axis
|
|
198
|
+
* const euler = QuaternionToEuler(q);
|
|
199
|
+
* console.log(euler); // [0, π/4, 0]
|
|
200
|
+
* ```
|
|
200
201
|
*/
|
|
201
202
|
export declare function QuaternionToEuler(quaternion: TQuaternion): TEulerAngles;
|
|
202
203
|
/**
|
|
@@ -208,11 +209,11 @@ export declare function QuaternionToEuler(quaternion: TQuaternion): TEulerAngles
|
|
|
208
209
|
* @returns The rotated vector
|
|
209
210
|
*
|
|
210
211
|
* @example
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const q = QuaternionFromAxisAngle([0, 0, 1], Math.PI/2); // 90° around Z
|
|
214
|
+
* const v = [1, 0, 0]; // Point along X-axis
|
|
215
|
+
* const rotated = QuaternionRotateVector(q, v); // Should point along Y-axis
|
|
216
|
+
* ```
|
|
216
217
|
*/
|
|
217
218
|
export declare function QuaternionRotateVector(quaternion: TQuaternion, vector: TVector3): TVector3;
|
|
218
219
|
/**
|
|
@@ -225,11 +226,11 @@ export declare function QuaternionRotateVector(quaternion: TQuaternion, vector:
|
|
|
225
226
|
* @returns Interpolated quaternion
|
|
226
227
|
*
|
|
227
228
|
* @example
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
* ```typescript
|
|
230
|
+
* const q1 = QuaternionIdentity();
|
|
231
|
+
* const q2 = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2);
|
|
232
|
+
* const halfway = QuaternionSLERP(q1, q2, 0.5); // 45° rotation
|
|
233
|
+
* ```
|
|
233
234
|
*/
|
|
234
235
|
export declare function QuaternionSLERP(a: TQuaternion, b: TQuaternion, t: number): TQuaternion;
|
|
235
236
|
//# 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;
|
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,SAAS,EAAE,UAAU,GAAG,WAAW,CAKhF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,WAAW,GAAG,UAAU,CA4BzE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,CAiBpE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,WAAW,GAAG,YAAY,CAoBvE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAsB1F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAwCtF"}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Provides comprehensive quaternion operations with conversion utilities and interpolation.
|
|
4
4
|
*/
|
|
5
5
|
import { VectorClone, VectorDot, VectorMagnitude, VectorNormalize, VectorEquals, Vector3Cross } from '../vectors/core.js';
|
|
6
|
-
import { AssertQuaternion, AssertNormalizedQuaternion, AssertEulerAngles, AssertAxisAngle } from './asserts.js';
|
|
6
|
+
import { AssertQuaternion, AssertNormalizedQuaternion, AssertEulerAngles, AssertAxisAngle, QuaternionError } from './asserts.js';
|
|
7
7
|
const QUATERNION_MAGNITUDE_TOLERANCE = 1e-10;
|
|
8
|
-
const
|
|
8
|
+
export const QUATERNION_TOLERANCE = 1e-6;
|
|
9
9
|
const SLERP_DOT_THRESHOLD = 0.9995;
|
|
10
10
|
/**
|
|
11
11
|
* Creates an identity quaternion representing no rotation.
|
|
@@ -14,10 +14,10 @@ const SLERP_DOT_THRESHOLD = 0.9995;
|
|
|
14
14
|
* @returns Identity quaternion [0, 0, 0, 1]
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const identity = QuaternionIdentity();
|
|
19
|
+
* console.log(identity); // [0, 0, 0, 1]
|
|
20
|
+
* ```
|
|
21
21
|
*/
|
|
22
22
|
export function QuaternionIdentity() {
|
|
23
23
|
return [0, 0, 0, 1];
|
|
@@ -30,11 +30,11 @@ export function QuaternionIdentity() {
|
|
|
30
30
|
* @returns A new quaternion with identical components
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const original = [0, 0, 0.707, 0.707];
|
|
35
|
+
* const copy = QuaternionClone(original);
|
|
36
|
+
* copy[0] = 1; // original remains unchanged
|
|
37
|
+
* ```
|
|
38
38
|
*/
|
|
39
39
|
export function QuaternionClone(quaternion) {
|
|
40
40
|
AssertQuaternion(quaternion);
|
|
@@ -52,12 +52,12 @@ export function QuaternionClone(quaternion) {
|
|
|
52
52
|
* @returns True if quaternions are equal within tolerance
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
+
* ```
|
|
61
61
|
*/
|
|
62
62
|
export function QuaternionEquals(a, b, tolerance = 1e-6, checkEquivalence = false) {
|
|
63
63
|
AssertQuaternion(a);
|
|
@@ -79,10 +79,10 @@ export function QuaternionEquals(a, b, tolerance = 1e-6, checkEquivalence = fals
|
|
|
79
79
|
* @returns The magnitude of the quaternion
|
|
80
80
|
*
|
|
81
81
|
* @example
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const q = [0, 0, 0, 1];
|
|
84
|
+
* console.log(QuaternionMagnitude(q)); // 1
|
|
85
|
+
* ```
|
|
86
86
|
*/
|
|
87
87
|
export function QuaternionMagnitude(quaternion) {
|
|
88
88
|
AssertQuaternion(quaternion);
|
|
@@ -96,11 +96,11 @@ export function QuaternionMagnitude(quaternion) {
|
|
|
96
96
|
* @returns A normalized quaternion with magnitude 1
|
|
97
97
|
*
|
|
98
98
|
* @example
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const q = [1, 1, 1, 1];
|
|
101
|
+
* const normalized = QuaternionNormalize(q);
|
|
102
|
+
* console.log(QuaternionMagnitude(normalized)); // 1
|
|
103
|
+
* ```
|
|
104
104
|
*/
|
|
105
105
|
export function QuaternionNormalize(quaternion) {
|
|
106
106
|
AssertQuaternion(quaternion);
|
|
@@ -115,11 +115,11 @@ export function QuaternionNormalize(quaternion) {
|
|
|
115
115
|
* @returns The conjugate quaternion
|
|
116
116
|
*
|
|
117
117
|
* @example
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
+
* ```
|
|
123
123
|
*/
|
|
124
124
|
export function QuaternionConjugate(quaternion) {
|
|
125
125
|
AssertQuaternion(quaternion);
|
|
@@ -135,17 +135,17 @@ export function QuaternionConjugate(quaternion) {
|
|
|
135
135
|
* @returns The inverse quaternion
|
|
136
136
|
*
|
|
137
137
|
* @example
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
+
* ```
|
|
142
142
|
*/
|
|
143
143
|
export function QuaternionInverse(quaternion) {
|
|
144
144
|
AssertQuaternion(quaternion);
|
|
145
145
|
const conjugate = QuaternionConjugate(quaternion);
|
|
146
146
|
const magnitudeSquared = VectorDot(quaternion, quaternion);
|
|
147
147
|
if (Math.abs(magnitudeSquared) < QUATERNION_MAGNITUDE_TOLERANCE) {
|
|
148
|
-
throw new
|
|
148
|
+
throw new QuaternionError('Cannot invert quaternion with zero magnitude');
|
|
149
149
|
}
|
|
150
150
|
// For unit quaternions, magnitude squared is 1, so this is just the conjugate
|
|
151
151
|
return [
|
|
@@ -165,11 +165,11 @@ export function QuaternionInverse(quaternion) {
|
|
|
165
165
|
* @returns The product quaternion representing the combined rotation
|
|
166
166
|
*
|
|
167
167
|
* @example
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
+
* ```
|
|
173
173
|
*/
|
|
174
174
|
export function QuaternionMultiply(a, b) {
|
|
175
175
|
AssertQuaternion(a);
|
|
@@ -192,11 +192,11 @@ export function QuaternionMultiply(a, b) {
|
|
|
192
192
|
* @returns A quaternion representing the rotation
|
|
193
193
|
*
|
|
194
194
|
* @example
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
+
* ```
|
|
200
200
|
*/
|
|
201
201
|
export function QuaternionFromAxisAngle(axis, angle) {
|
|
202
202
|
const normalizedAxis = VectorNormalize(axis);
|
|
@@ -232,11 +232,11 @@ export function QuaternionFromAxisAngleVector(axisAngle) {
|
|
|
232
232
|
* @throws {Error} If the quaternion is not normalized
|
|
233
233
|
*
|
|
234
234
|
* @example
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
+
* ```
|
|
240
240
|
*/
|
|
241
241
|
export function QuaternionToAxisAngle(quaternion) {
|
|
242
242
|
AssertNormalizedQuaternion(quaternion);
|
|
@@ -250,7 +250,7 @@ export function QuaternionToAxisAngle(quaternion) {
|
|
|
250
250
|
}
|
|
251
251
|
const angle = 2 * Math.acos(Math.min(1, qw));
|
|
252
252
|
const sinHalfAngle = Math.sqrt(1 - (qw * qw));
|
|
253
|
-
if (sinHalfAngle <
|
|
253
|
+
if (sinHalfAngle < QUATERNION_TOLERANCE) {
|
|
254
254
|
// Avoid division by zero for small angles
|
|
255
255
|
return [1, 0, 0, 0];
|
|
256
256
|
}
|
|
@@ -269,10 +269,10 @@ export function QuaternionToAxisAngle(quaternion) {
|
|
|
269
269
|
* @returns A quaternion representing the rotation
|
|
270
270
|
*
|
|
271
271
|
* @example
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
272
|
+
* ```typescript
|
|
273
|
+
* const euler = [0, Math.PI/4, 0]; // 45° pitch
|
|
274
|
+
* const q = QuaternionFromEuler(euler);
|
|
275
|
+
* ```
|
|
276
276
|
*/
|
|
277
277
|
export function QuaternionFromEuler(euler) {
|
|
278
278
|
AssertEulerAngles(euler);
|
|
@@ -298,11 +298,11 @@ export function QuaternionFromEuler(euler) {
|
|
|
298
298
|
* @returns Euler angles as [x, y, z] in radians
|
|
299
299
|
*
|
|
300
300
|
* @example
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
+
* ```
|
|
306
306
|
*/
|
|
307
307
|
export function QuaternionToEuler(quaternion) {
|
|
308
308
|
AssertNormalizedQuaternion(quaternion);
|
|
@@ -329,11 +329,11 @@ export function QuaternionToEuler(quaternion) {
|
|
|
329
329
|
* @returns The rotated vector
|
|
330
330
|
*
|
|
331
331
|
* @example
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
+
* ```
|
|
337
337
|
*/
|
|
338
338
|
export function QuaternionRotateVector(quaternion, vector) {
|
|
339
339
|
AssertNormalizedQuaternion(quaternion);
|
|
@@ -365,11 +365,11 @@ export function QuaternionRotateVector(quaternion, vector) {
|
|
|
365
365
|
* @returns Interpolated quaternion
|
|
366
366
|
*
|
|
367
367
|
* @example
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
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
|
+
* ```
|
|
373
373
|
*/
|
|
374
374
|
export function QuaternionSLERP(a, b, t) {
|
|
375
375
|
AssertNormalizedQuaternion(a);
|
|
@@ -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;
|
|
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,eAAe,EAAE,MAAM,cAAc,CAAC;AAGjI,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAC7C,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AACzC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB;IACjC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAAC,UAAuB;IACtD,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC7B,OAAO,WAAW,CAAC,UAAU,CAAgB,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAc,E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,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,GAAG,QAAQ,CAAC;IAEtD,OAAO;QACN,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;KACxC,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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"}
|
|
@@ -5,6 +5,4 @@ export * from './asserts.js';
|
|
|
5
5
|
export * from './conversions.js';
|
|
6
6
|
export * from './interpolation.js';
|
|
7
7
|
export * from './predefined.js';
|
|
8
|
-
// Namespace re-exports for grouped access
|
|
9
|
-
export * as QuaternionNamespace from './_exports.js';
|
|
10
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Advanced interpolation utilities for quaternions.
|
|
3
3
|
* Provides specialized interpolation methods for smooth rotation animations.
|
|
4
4
|
*/
|
|
5
|
-
import { TQuaternion } from './types.js';
|
|
5
|
+
import type { TQuaternion } from './types.js';
|
|
6
6
|
/**
|
|
7
7
|
* Performs normalized linear interpolation (NLERP) between two quaternions.
|
|
8
8
|
* NLERP is faster than SLERP but doesn't maintain constant angular velocity.
|
|
@@ -14,11 +14,11 @@ import { TQuaternion } from './types.js';
|
|
|
14
14
|
* @returns Interpolated and normalized quaternion
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
* ```
|
|
22
22
|
*/
|
|
23
23
|
export declare function QuaternionNLERP(a: TQuaternion, b: TQuaternion, t: number): TQuaternion;
|
|
24
24
|
/**
|
|
@@ -33,11 +33,11 @@ export declare function QuaternionNLERP(a: TQuaternion, b: TQuaternion, t: numbe
|
|
|
33
33
|
* @returns Smoothly interpolated quaternion
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
* ```
|
|
41
41
|
*/
|
|
42
42
|
export declare function QuaternionSQUAD(q0: TQuaternion, q1: TQuaternion, q2: TQuaternion, q3: TQuaternion, t: number): TQuaternion;
|
|
43
43
|
/**
|
|
@@ -50,11 +50,11 @@ export declare function QuaternionSQUAD(q0: TQuaternion, q1: TQuaternion, q2: TQ
|
|
|
50
50
|
* @returns Function that takes t ∈ [0, 1] and returns interpolated quaternion
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
+
* ```
|
|
58
58
|
*/
|
|
59
59
|
export declare function QuaternionCreatePath(quaternions: TQuaternion[], method?: 'slerp' | 'nlerp' | 'squad'): (t: number) => TQuaternion;
|
|
60
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;
|
|
1
|
+
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../src/quaternions/interpolation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAK9C;;;;;;;;;;;;;;;;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"}
|