@pawells/math-extended 1.0.1
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/LICENSE +21 -0
- package/README.md +319 -0
- package/build/angles.d.ts +31 -0
- package/build/angles.d.ts.map +1 -0
- package/build/angles.js +85 -0
- package/build/angles.js.map +1 -0
- package/build/angles.spec.d.ts +2 -0
- package/build/angles.spec.d.ts.map +1 -0
- package/build/angles.spec.js +147 -0
- package/build/angles.spec.js.map +1 -0
- package/build/clamp.d.ts +17 -0
- package/build/clamp.d.ts.map +1 -0
- package/build/clamp.js +19 -0
- package/build/clamp.js.map +1 -0
- package/build/clamp.spec.d.ts +2 -0
- package/build/clamp.spec.d.ts.map +1 -0
- package/build/clamp.spec.js +19 -0
- package/build/clamp.spec.js.map +1 -0
- package/build/documentation-validation.spec.d.ts +11 -0
- package/build/documentation-validation.spec.d.ts.map +1 -0
- package/build/documentation-validation.spec.js +401 -0
- package/build/documentation-validation.spec.js.map +1 -0
- package/build/index.d.ts +8 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +8 -0
- package/build/index.js.map +1 -0
- package/build/interpolation.d.ts +175 -0
- package/build/interpolation.d.ts.map +1 -0
- package/build/interpolation.js +369 -0
- package/build/interpolation.js.map +1 -0
- package/build/interpolation.spec.d.ts +2 -0
- package/build/interpolation.spec.d.ts.map +1 -0
- package/build/interpolation.spec.js +480 -0
- package/build/interpolation.spec.js.map +1 -0
- package/build/matrices/arithmetic.d.ts +411 -0
- package/build/matrices/arithmetic.d.ts.map +1 -0
- package/build/matrices/arithmetic.js +954 -0
- package/build/matrices/arithmetic.js.map +1 -0
- package/build/matrices/arithmetic.spec.d.ts +2 -0
- package/build/matrices/arithmetic.spec.d.ts.map +1 -0
- package/build/matrices/arithmetic.spec.js +915 -0
- package/build/matrices/arithmetic.spec.js.map +1 -0
- package/build/matrices/asserts.d.ts +306 -0
- package/build/matrices/asserts.d.ts.map +1 -0
- package/build/matrices/asserts.js +396 -0
- package/build/matrices/asserts.js.map +1 -0
- package/build/matrices/asserts.spec.d.ts +2 -0
- package/build/matrices/asserts.spec.d.ts.map +1 -0
- package/build/matrices/asserts.spec.js +565 -0
- package/build/matrices/asserts.spec.js.map +1 -0
- package/build/matrices/core.d.ts +168 -0
- package/build/matrices/core.d.ts.map +1 -0
- package/build/matrices/core.js +457 -0
- package/build/matrices/core.js.map +1 -0
- package/build/matrices/core.spec.d.ts +2 -0
- package/build/matrices/core.spec.d.ts.map +1 -0
- package/build/matrices/core.spec.js +634 -0
- package/build/matrices/core.spec.js.map +1 -0
- package/build/matrices/decompositions.d.ts +326 -0
- package/build/matrices/decompositions.d.ts.map +1 -0
- package/build/matrices/decompositions.js +816 -0
- package/build/matrices/decompositions.js.map +1 -0
- package/build/matrices/decompositions.spec.d.ts +2 -0
- package/build/matrices/decompositions.spec.d.ts.map +1 -0
- package/build/matrices/decompositions.spec.js +195 -0
- package/build/matrices/decompositions.spec.js.map +1 -0
- package/build/matrices/index.d.ts +9 -0
- package/build/matrices/index.d.ts.map +1 -0
- package/build/matrices/index.js +9 -0
- package/build/matrices/index.js.map +1 -0
- package/build/matrices/linear-algebra.d.ts +64 -0
- package/build/matrices/linear-algebra.d.ts.map +1 -0
- package/build/matrices/linear-algebra.js +253 -0
- package/build/matrices/linear-algebra.js.map +1 -0
- package/build/matrices/linear-algebra.spec.d.ts +2 -0
- package/build/matrices/linear-algebra.spec.d.ts.map +1 -0
- package/build/matrices/linear-algebra.spec.js +355 -0
- package/build/matrices/linear-algebra.spec.js.map +1 -0
- package/build/matrices/normalization.d.ts +62 -0
- package/build/matrices/normalization.d.ts.map +1 -0
- package/build/matrices/normalization.js +167 -0
- package/build/matrices/normalization.js.map +1 -0
- package/build/matrices/normalization.spec.d.ts +2 -0
- package/build/matrices/normalization.spec.d.ts.map +1 -0
- package/build/matrices/normalization.spec.js +335 -0
- package/build/matrices/normalization.spec.js.map +1 -0
- package/build/matrices/transformations.d.ts +484 -0
- package/build/matrices/transformations.d.ts.map +1 -0
- package/build/matrices/transformations.js +592 -0
- package/build/matrices/transformations.js.map +1 -0
- package/build/matrices/transformations.spec.d.ts +2 -0
- package/build/matrices/transformations.spec.d.ts.map +1 -0
- package/build/matrices/transformations.spec.js +755 -0
- package/build/matrices/transformations.spec.js.map +1 -0
- package/build/matrices/types.d.ts +134 -0
- package/build/matrices/types.d.ts.map +1 -0
- package/build/matrices/types.js +6 -0
- package/build/matrices/types.js.map +1 -0
- package/build/quaternions/asserts.d.ts +77 -0
- package/build/quaternions/asserts.d.ts.map +1 -0
- package/build/quaternions/asserts.js +175 -0
- package/build/quaternions/asserts.js.map +1 -0
- package/build/quaternions/asserts.spec.d.ts +2 -0
- package/build/quaternions/asserts.spec.d.ts.map +1 -0
- package/build/quaternions/asserts.spec.js +320 -0
- package/build/quaternions/asserts.spec.js.map +1 -0
- package/build/quaternions/conversions.d.ts +73 -0
- package/build/quaternions/conversions.d.ts.map +1 -0
- package/build/quaternions/conversions.js +179 -0
- package/build/quaternions/conversions.js.map +1 -0
- package/build/quaternions/conversions.spec.d.ts +2 -0
- package/build/quaternions/conversions.spec.d.ts.map +1 -0
- package/build/quaternions/conversions.spec.js +344 -0
- package/build/quaternions/conversions.spec.js.map +1 -0
- package/build/quaternions/core.d.ts +203 -0
- package/build/quaternions/core.d.ts.map +1 -0
- package/build/quaternions/core.js +374 -0
- package/build/quaternions/core.js.map +1 -0
- package/build/quaternions/core.spec.d.ts +2 -0
- package/build/quaternions/core.spec.d.ts.map +1 -0
- package/build/quaternions/core.spec.js +294 -0
- package/build/quaternions/core.spec.js.map +1 -0
- package/build/quaternions/index.d.ts +7 -0
- package/build/quaternions/index.d.ts.map +1 -0
- package/build/quaternions/index.js +7 -0
- package/build/quaternions/index.js.map +1 -0
- package/build/quaternions/interpolation.d.ts +54 -0
- package/build/quaternions/interpolation.d.ts.map +1 -0
- package/build/quaternions/interpolation.js +201 -0
- package/build/quaternions/interpolation.js.map +1 -0
- package/build/quaternions/interpolation.spec.d.ts +2 -0
- package/build/quaternions/interpolation.spec.d.ts.map +1 -0
- package/build/quaternions/interpolation.spec.js +64 -0
- package/build/quaternions/interpolation.spec.js.map +1 -0
- package/build/quaternions/predefined.d.ts +36 -0
- package/build/quaternions/predefined.d.ts.map +1 -0
- package/build/quaternions/predefined.js +42 -0
- package/build/quaternions/predefined.js.map +1 -0
- package/build/quaternions/predefined.spec.d.ts +2 -0
- package/build/quaternions/predefined.spec.d.ts.map +1 -0
- package/build/quaternions/predefined.spec.js +35 -0
- package/build/quaternions/predefined.spec.js.map +1 -0
- package/build/quaternions/types.d.ts +55 -0
- package/build/quaternions/types.d.ts.map +1 -0
- package/build/quaternions/types.js +7 -0
- package/build/quaternions/types.js.map +1 -0
- package/build/random.d.ts +66 -0
- package/build/random.d.ts.map +1 -0
- package/build/random.js +115 -0
- package/build/random.js.map +1 -0
- package/build/random.spec.d.ts +2 -0
- package/build/random.spec.d.ts.map +1 -0
- package/build/random.spec.js +267 -0
- package/build/random.spec.js.map +1 -0
- package/build/vectors/asserts.d.ts +182 -0
- package/build/vectors/asserts.d.ts.map +1 -0
- package/build/vectors/asserts.js +285 -0
- package/build/vectors/asserts.js.map +1 -0
- package/build/vectors/asserts.spec.d.ts +2 -0
- package/build/vectors/asserts.spec.d.ts.map +1 -0
- package/build/vectors/asserts.spec.js +260 -0
- package/build/vectors/asserts.spec.js.map +1 -0
- package/build/vectors/core.d.ts +507 -0
- package/build/vectors/core.d.ts.map +1 -0
- package/build/vectors/core.js +825 -0
- package/build/vectors/core.js.map +1 -0
- package/build/vectors/core.spec.d.ts +2 -0
- package/build/vectors/core.spec.d.ts.map +1 -0
- package/build/vectors/core.spec.js +343 -0
- package/build/vectors/core.spec.js.map +1 -0
- package/build/vectors/index.d.ts +6 -0
- package/build/vectors/index.d.ts.map +1 -0
- package/build/vectors/index.js +6 -0
- package/build/vectors/index.js.map +1 -0
- package/build/vectors/interpolation.d.ts +404 -0
- package/build/vectors/interpolation.d.ts.map +1 -0
- package/build/vectors/interpolation.js +585 -0
- package/build/vectors/interpolation.js.map +1 -0
- package/build/vectors/interpolation.spec.d.ts +2 -0
- package/build/vectors/interpolation.spec.d.ts.map +1 -0
- package/build/vectors/interpolation.spec.js +378 -0
- package/build/vectors/interpolation.spec.js.map +1 -0
- package/build/vectors/predefined.d.ts +191 -0
- package/build/vectors/predefined.d.ts.map +1 -0
- package/build/vectors/predefined.js +191 -0
- package/build/vectors/predefined.js.map +1 -0
- package/build/vectors/predefined.spec.d.ts +2 -0
- package/build/vectors/predefined.spec.d.ts.map +1 -0
- package/build/vectors/predefined.spec.js +333 -0
- package/build/vectors/predefined.spec.js.map +1 -0
- package/build/vectors/types.d.ts +62 -0
- package/build/vectors/types.d.ts.map +1 -0
- package/build/vectors/types.js +6 -0
- package/build/vectors/types.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core quaternion mathematics operations for rotation and orientation calculations.
|
|
3
|
+
* Provides comprehensive quaternion operations with conversion utilities and interpolation.
|
|
4
|
+
*/
|
|
5
|
+
import { VectorClone, VectorDot, VectorMagnitude, VectorNormalize, VectorEquals, Vector3Cross } from '../vectors/core.js';
|
|
6
|
+
import { AssertQuaternion, AssertNormalizedQuaternion, AssertEulerAngles, AssertAxisAngle } from './asserts.js';
|
|
7
|
+
const QUATERNION_MAGNITUDE_TOLERANCE = 1e-10;
|
|
8
|
+
const QUATERNION_ANGLE_TOLERANCE = 1e-6;
|
|
9
|
+
const SLERP_DOT_THRESHOLD = 0.9995;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an identity quaternion representing no rotation.
|
|
12
|
+
* The identity quaternion is [0, 0, 0, 1] (x, y, z, w).
|
|
13
|
+
*
|
|
14
|
+
* @returns Identity quaternion [0, 0, 0, 1]
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const identity = QuaternionIdentity();
|
|
18
|
+
* console.log(identity); // [0, 0, 0, 1]
|
|
19
|
+
*/
|
|
20
|
+
export function QuaternionIdentity() {
|
|
21
|
+
return [0, 0, 0, 1];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates a deep copy of a quaternion.
|
|
25
|
+
* Essential for avoiding mutations during operations.
|
|
26
|
+
*
|
|
27
|
+
* @param quaternion - The quaternion to clone
|
|
28
|
+
* @returns A new quaternion with identical components
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const original = [0, 0, 0.707, 0.707];
|
|
32
|
+
* const copy = QuaternionClone(original);
|
|
33
|
+
* copy[0] = 1; // original remains unchanged
|
|
34
|
+
*/
|
|
35
|
+
export function QuaternionClone(quaternion) {
|
|
36
|
+
AssertQuaternion(quaternion);
|
|
37
|
+
return VectorClone(quaternion);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Compares two quaternions for equality with optional tolerance.
|
|
41
|
+
* Note: Quaternions q and -q represent the same rotation, but this function
|
|
42
|
+
* checks for exact component equality unless checkEquivalence is true.
|
|
43
|
+
*
|
|
44
|
+
* @param a - First quaternion to compare
|
|
45
|
+
* @param b - Second quaternion to compare
|
|
46
|
+
* @param tolerance - Maximum allowed difference between components (default: 1e-6)
|
|
47
|
+
* @param checkEquivalence - If true, also check if quaternions represent the same rotation (default: false)
|
|
48
|
+
* @returns True if quaternions are equal within tolerance
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* const q1 = [0, 0, 0, 1];
|
|
52
|
+
* const q2 = [0, 0, 0, -1];
|
|
53
|
+
* console.log(QuaternionEquals(q1, q2)); // false (different components)
|
|
54
|
+
* console.log(QuaternionEquals(q1, q2, 1e-6, true)); // true (same rotation)
|
|
55
|
+
*/
|
|
56
|
+
export function QuaternionEquals(a, b, tolerance = 1e-6, checkEquivalence = false) {
|
|
57
|
+
AssertQuaternion(a);
|
|
58
|
+
AssertQuaternion(b);
|
|
59
|
+
// Check direct equality using vector comparison
|
|
60
|
+
const directEqual = VectorEquals(a, b, tolerance);
|
|
61
|
+
if (directEqual || !checkEquivalence) {
|
|
62
|
+
return directEqual;
|
|
63
|
+
}
|
|
64
|
+
// Check if they represent the same rotation (q and -q are equivalent)
|
|
65
|
+
const negated = [-a[0], -a[1], -a[2], -a[3]];
|
|
66
|
+
return VectorEquals(negated, b, tolerance);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Calculates the magnitude (length) of a quaternion.
|
|
70
|
+
* For unit quaternions (valid rotations), this should be 1.
|
|
71
|
+
*
|
|
72
|
+
* @param quaternion - The quaternion to measure
|
|
73
|
+
* @returns The magnitude of the quaternion
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const q = [0, 0, 0, 1];
|
|
77
|
+
* console.log(QuaternionMagnitude(q)); // 1
|
|
78
|
+
*/
|
|
79
|
+
export function QuaternionMagnitude(quaternion) {
|
|
80
|
+
AssertQuaternion(quaternion);
|
|
81
|
+
return VectorMagnitude(quaternion);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Normalizes a quaternion to unit length.
|
|
85
|
+
* Essential for ensuring quaternions represent valid rotations.
|
|
86
|
+
*
|
|
87
|
+
* @param quaternion - The quaternion to normalize
|
|
88
|
+
* @returns A normalized quaternion with magnitude 1
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const q = [1, 1, 1, 1];
|
|
92
|
+
* const normalized = QuaternionNormalize(q);
|
|
93
|
+
* console.log(QuaternionMagnitude(normalized)); // 1
|
|
94
|
+
*/
|
|
95
|
+
export function QuaternionNormalize(quaternion) {
|
|
96
|
+
AssertQuaternion(quaternion);
|
|
97
|
+
return VectorNormalize(quaternion);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Calculates the conjugate of a quaternion.
|
|
101
|
+
* The conjugate of [x, y, z, w] is [-x, -y, -z, w].
|
|
102
|
+
* For unit quaternions, the conjugate represents the inverse rotation.
|
|
103
|
+
*
|
|
104
|
+
* @param quaternion - The quaternion to conjugate
|
|
105
|
+
* @returns The conjugate quaternion
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* const q = [0.5, 0.5, 0.5, 0.5];
|
|
109
|
+
* const conjugate = QuaternionConjugate(q);
|
|
110
|
+
* console.log(conjugate); // [-0.5, -0.5, -0.5, 0.5]
|
|
111
|
+
*/
|
|
112
|
+
export function QuaternionConjugate(quaternion) {
|
|
113
|
+
AssertQuaternion(quaternion);
|
|
114
|
+
const [x, y, z, w] = quaternion;
|
|
115
|
+
return [-x, -y, -z, w];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Calculates the inverse of a quaternion.
|
|
119
|
+
* For unit quaternions, the inverse equals the conjugate.
|
|
120
|
+
* For non-unit quaternions, the inverse is conjugate divided by magnitude squared.
|
|
121
|
+
*
|
|
122
|
+
* @param quaternion - The quaternion to invert
|
|
123
|
+
* @returns The inverse quaternion
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z
|
|
127
|
+
* const inverse = QuaternionInverse(q); // -90° rotation around Z
|
|
128
|
+
*/
|
|
129
|
+
export function QuaternionInverse(quaternion) {
|
|
130
|
+
AssertQuaternion(quaternion);
|
|
131
|
+
const conjugate = QuaternionConjugate(quaternion);
|
|
132
|
+
const magnitudeSquared = VectorDot(quaternion, quaternion);
|
|
133
|
+
if (Math.abs(magnitudeSquared) < QUATERNION_MAGNITUDE_TOLERANCE) {
|
|
134
|
+
throw new Error('Cannot invert quaternion with zero magnitude');
|
|
135
|
+
}
|
|
136
|
+
// For unit quaternions, magnitude squared is 1, so this is just the conjugate
|
|
137
|
+
return [
|
|
138
|
+
conjugate[0] / magnitudeSquared,
|
|
139
|
+
conjugate[1] / magnitudeSquared,
|
|
140
|
+
conjugate[2] / magnitudeSquared,
|
|
141
|
+
conjugate[3] / magnitudeSquared,
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Multiplies two quaternions.
|
|
146
|
+
* Quaternion multiplication represents composition of rotations.
|
|
147
|
+
* Note: Quaternion multiplication is not commutative (order matters).
|
|
148
|
+
*
|
|
149
|
+
* @param a - First quaternion (applied second in rotation order)
|
|
150
|
+
* @param b - Second quaternion (applied first in rotation order)
|
|
151
|
+
* @returns The product quaternion representing the combined rotation
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* const rotX = QuaternionFromAxisAngle([1, 0, 0], Math.PI/2); // 90° around X
|
|
155
|
+
* const rotY = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2); // 90° around Y
|
|
156
|
+
* const combined = QuaternionMultiply(rotX, rotY); // Y rotation then X rotation
|
|
157
|
+
*/
|
|
158
|
+
export function QuaternionMultiply(a, b) {
|
|
159
|
+
AssertQuaternion(a);
|
|
160
|
+
AssertQuaternion(b);
|
|
161
|
+
const [ax, ay, az, aw] = a;
|
|
162
|
+
const [bx, by, bz, bw] = b;
|
|
163
|
+
return [
|
|
164
|
+
(aw * bx) + (ax * bw) + (ay * bz) - (az * by),
|
|
165
|
+
(aw * by) - (ax * bz) + (ay * bw) + (az * bx),
|
|
166
|
+
(aw * bz) + (ax * by) - (ay * bx) + (az * bw),
|
|
167
|
+
(aw * bw) - (ax * bx) - (ay * by) - (az * bz),
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Creates a quaternion from an axis-angle representation.
|
|
172
|
+
* The axis should be normalized, and the angle is in radians.
|
|
173
|
+
*
|
|
174
|
+
* @param axis - The rotation axis as a normalized 3D vector
|
|
175
|
+
* @param angle - The rotation angle in radians
|
|
176
|
+
* @returns A quaternion representing the rotation
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* const axis = [0, 1, 0]; // Y-axis
|
|
180
|
+
* const angle = Math.PI / 2; // 90 degrees
|
|
181
|
+
* const q = QuaternionFromAxisAngle(axis, angle);
|
|
182
|
+
*/
|
|
183
|
+
export function QuaternionFromAxisAngle(axis, angle) {
|
|
184
|
+
const normalizedAxis = VectorNormalize(axis);
|
|
185
|
+
const halfAngle = angle * 0.5;
|
|
186
|
+
const sinHalf = Math.sin(halfAngle);
|
|
187
|
+
const cosHalf = Math.cos(halfAngle);
|
|
188
|
+
return [
|
|
189
|
+
normalizedAxis[0] * sinHalf,
|
|
190
|
+
normalizedAxis[1] * sinHalf,
|
|
191
|
+
normalizedAxis[2] * sinHalf,
|
|
192
|
+
cosHalf,
|
|
193
|
+
];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Creates a quaternion from an axis-angle representation (4-component version).
|
|
197
|
+
*
|
|
198
|
+
* @param axisAngle - The axis-angle as [x, y, z, angle] where xyz is the axis and angle is in radians
|
|
199
|
+
* @returns A quaternion representing the rotation
|
|
200
|
+
*/
|
|
201
|
+
export function QuaternionFromAxisAngleVector(axisAngle) {
|
|
202
|
+
AssertAxisAngle(axisAngle);
|
|
203
|
+
const [x, y, z, angle] = axisAngle;
|
|
204
|
+
return QuaternionFromAxisAngle([x, y, z], angle);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Converts a quaternion to axis-angle representation.
|
|
208
|
+
*
|
|
209
|
+
* @param quaternion - The quaternion to convert
|
|
210
|
+
* @returns The axis-angle representation as [x, y, z, angle]
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* const q = [0, 0.707, 0, 0.707]; // 90° around Y-axis
|
|
214
|
+
* const axisAngle = QuaternionToAxisAngle(q);
|
|
215
|
+
* console.log(axisAngle); // [0, 1, 0, π/2]
|
|
216
|
+
*/
|
|
217
|
+
export function QuaternionToAxisAngle(quaternion) {
|
|
218
|
+
AssertNormalizedQuaternion(quaternion);
|
|
219
|
+
const [x, y, z, w] = quaternion;
|
|
220
|
+
// Handle identity quaternion
|
|
221
|
+
if (Math.abs(w) >= 1) {
|
|
222
|
+
return [1, 0, 0, 0]; // Arbitrary axis, zero angle
|
|
223
|
+
}
|
|
224
|
+
const angle = 2 * Math.acos(Math.min(1, Math.abs(w)));
|
|
225
|
+
const sinHalfAngle = Math.sqrt(1 - (w * w));
|
|
226
|
+
if (sinHalfAngle < QUATERNION_ANGLE_TOLERANCE) {
|
|
227
|
+
// Avoid division by zero for small angles
|
|
228
|
+
return [1, 0, 0, 0];
|
|
229
|
+
}
|
|
230
|
+
return [
|
|
231
|
+
x / sinHalfAngle,
|
|
232
|
+
y / sinHalfAngle,
|
|
233
|
+
z / sinHalfAngle,
|
|
234
|
+
angle,
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Creates a quaternion from Euler angles (in radians).
|
|
239
|
+
* Uses the ZYX rotation order (yaw-pitch-roll).
|
|
240
|
+
*
|
|
241
|
+
* @param euler - Euler angles as [x, y, z] in radians
|
|
242
|
+
* @returns A quaternion representing the rotation
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* const euler = [0, Math.PI/4, 0]; // 45° pitch
|
|
246
|
+
* const q = QuaternionFromEuler(euler);
|
|
247
|
+
*/
|
|
248
|
+
export function QuaternionFromEuler(euler) {
|
|
249
|
+
AssertEulerAngles(euler);
|
|
250
|
+
const [x, y, z] = euler;
|
|
251
|
+
const cx = Math.cos(x * 0.5);
|
|
252
|
+
const sx = Math.sin(x * 0.5);
|
|
253
|
+
const cy = Math.cos(y * 0.5);
|
|
254
|
+
const sy = Math.sin(y * 0.5);
|
|
255
|
+
const cz = Math.cos(z * 0.5);
|
|
256
|
+
const sz = Math.sin(z * 0.5);
|
|
257
|
+
return [
|
|
258
|
+
(sx * cy * cz) - (cx * sy * sz),
|
|
259
|
+
(cx * sy * cz) + (sx * cy * sz),
|
|
260
|
+
(cx * cy * sz) - (sx * sy * cz),
|
|
261
|
+
(cx * cy * cz) + (sx * sy * sz),
|
|
262
|
+
];
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Converts a quaternion to Euler angles (in radians).
|
|
266
|
+
* Uses the ZYX rotation order (yaw-pitch-roll).
|
|
267
|
+
*
|
|
268
|
+
* @param quaternion - The quaternion to convert
|
|
269
|
+
* @returns Euler angles as [x, y, z] in radians
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* const q = [0, 0.383, 0, 0.924]; // ~45° around Y-axis
|
|
273
|
+
* const euler = QuaternionToEuler(q);
|
|
274
|
+
* console.log(euler); // [0, π/4, 0]
|
|
275
|
+
*/
|
|
276
|
+
export function QuaternionToEuler(quaternion) {
|
|
277
|
+
AssertNormalizedQuaternion(quaternion);
|
|
278
|
+
const [x, y, z, w] = quaternion;
|
|
279
|
+
// Roll (x-axis rotation)
|
|
280
|
+
const sinRoll = 2 * ((w * x) + (y * z));
|
|
281
|
+
const cosRoll = 1 - (2 * ((x * x) + (y * y)));
|
|
282
|
+
const roll = Math.atan2(sinRoll, cosRoll);
|
|
283
|
+
// Pitch (y-axis rotation)
|
|
284
|
+
const sinPitch = 2 * ((w * y) - (z * x));
|
|
285
|
+
const pitch = Math.abs(sinPitch) >= 1 ? Math.sign(sinPitch) * (Math.PI / 2) : Math.asin(sinPitch);
|
|
286
|
+
// Yaw (z-axis rotation)
|
|
287
|
+
const sinYaw = 2 * ((w * z) + (x * y));
|
|
288
|
+
const cosYaw = 1 - (2 * ((y * y) + (z * z)));
|
|
289
|
+
const yaw = Math.atan2(sinYaw, cosYaw);
|
|
290
|
+
return [roll, pitch, yaw];
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Rotates a 3D vector by a quaternion.
|
|
294
|
+
* This is equivalent to converting the quaternion to a rotation matrix and multiplying.
|
|
295
|
+
*
|
|
296
|
+
* @param quaternion - The rotation quaternion (must be normalized)
|
|
297
|
+
* @param vector - The 3D vector to rotate
|
|
298
|
+
* @returns The rotated vector
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* const q = QuaternionFromAxisAngle([0, 0, 1], Math.PI/2); // 90° around Z
|
|
302
|
+
* const v = [1, 0, 0]; // Point along X-axis
|
|
303
|
+
* const rotated = QuaternionRotateVector(q, v); // Should point along Y-axis
|
|
304
|
+
*/
|
|
305
|
+
export function QuaternionRotateVector(quaternion, vector) {
|
|
306
|
+
AssertNormalizedQuaternion(quaternion);
|
|
307
|
+
const [qx, qy, qz, qw] = quaternion;
|
|
308
|
+
const qVector = [qx, qy, qz];
|
|
309
|
+
// Optimized quaternion-vector rotation using vector cross product
|
|
310
|
+
// v' = v + 2 * cross(q.xyz, cross(q.xyz, v) + q.w * v)
|
|
311
|
+
const qCrossV = Vector3Cross(qVector, vector);
|
|
312
|
+
const qwTimesV = [qw * vector[0], qw * vector[1], qw * vector[2]];
|
|
313
|
+
const qCrossVPlusQwV = [
|
|
314
|
+
qCrossV[0] + qwTimesV[0],
|
|
315
|
+
qCrossV[1] + qwTimesV[1],
|
|
316
|
+
qCrossV[2] + qwTimesV[2],
|
|
317
|
+
];
|
|
318
|
+
const finalCross = Vector3Cross(qVector, qCrossVPlusQwV);
|
|
319
|
+
return [
|
|
320
|
+
vector[0] + (2 * finalCross[0]),
|
|
321
|
+
vector[1] + (2 * finalCross[1]),
|
|
322
|
+
vector[2] + (2 * finalCross[2]),
|
|
323
|
+
];
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Performs spherical linear interpolation (SLERP) between two quaternions.
|
|
327
|
+
* SLERP provides smooth rotation interpolation with constant angular velocity.
|
|
328
|
+
*
|
|
329
|
+
* @param a - Start quaternion
|
|
330
|
+
* @param b - End quaternion
|
|
331
|
+
* @param t - Interpolation parameter (0 = a, 1 = b)
|
|
332
|
+
* @returns Interpolated quaternion
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* const q1 = QuaternionIdentity();
|
|
336
|
+
* const q2 = QuaternionFromAxisAngle([0, 1, 0], Math.PI/2);
|
|
337
|
+
* const halfway = QuaternionSLERP(q1, q2, 0.5); // 45° rotation
|
|
338
|
+
*/
|
|
339
|
+
export function QuaternionSLERP(a, b, t) {
|
|
340
|
+
AssertNormalizedQuaternion(a);
|
|
341
|
+
AssertNormalizedQuaternion(b);
|
|
342
|
+
// Clamp t to [0, 1]
|
|
343
|
+
const clampedT = Math.max(0, Math.min(1, t));
|
|
344
|
+
// Compute dot product
|
|
345
|
+
let dot = VectorDot(a, b);
|
|
346
|
+
// If dot product is negative, use -b to take the shorter path
|
|
347
|
+
let bToUse = b;
|
|
348
|
+
if (dot < 0) {
|
|
349
|
+
bToUse = [-b[0], -b[1], -b[2], -b[3]];
|
|
350
|
+
dot = -dot;
|
|
351
|
+
}
|
|
352
|
+
// If quaternions are very close, use linear interpolation to avoid numerical issues
|
|
353
|
+
if (dot > SLERP_DOT_THRESHOLD) {
|
|
354
|
+
const result = [
|
|
355
|
+
a[0] + (clampedT * (bToUse[0] - a[0])),
|
|
356
|
+
a[1] + (clampedT * (bToUse[1] - a[1])),
|
|
357
|
+
a[2] + (clampedT * (bToUse[2] - a[2])),
|
|
358
|
+
a[3] + (clampedT * (bToUse[3] - a[3])),
|
|
359
|
+
];
|
|
360
|
+
return QuaternionNormalize(result);
|
|
361
|
+
}
|
|
362
|
+
// Calculate interpolation factors
|
|
363
|
+
const theta = Math.acos(Math.abs(dot));
|
|
364
|
+
const sinTheta = Math.sin(theta);
|
|
365
|
+
const factor1 = Math.sin((1 - clampedT) * theta) / sinTheta;
|
|
366
|
+
const factor2 = Math.sin(clampedT * theta) / sinTheta;
|
|
367
|
+
return [
|
|
368
|
+
(factor1 * a[0]) + (factor2 * bToUse[0]),
|
|
369
|
+
(factor1 * a[1]) + (factor2 * bToUse[1]),
|
|
370
|
+
(factor1 * a[2]) + (factor2 * bToUse[2]),
|
|
371
|
+
(factor1 * a[3]) + (factor2 * bToUse[3]),
|
|
372
|
+
];
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/quaternions/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,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