@pawells/math-extended 1.1.1 → 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/angles.d.ts +28 -18
- package/build/angles.d.ts.map +1 -1
- package/build/angles.js +28 -18
- package/build/angles.js.map +1 -1
- package/build/clamp.d.ts +2 -0
- package/build/clamp.d.ts.map +1 -1
- package/build/clamp.js +2 -0
- package/build/clamp.js.map +1 -1
- 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 +62 -13
- package/build/interpolation.d.ts.map +1 -1
- package/build/interpolation.js +66 -23
- package/build/interpolation.js.map +1 -1
- package/build/matrices/arithmetic.d.ts +65 -76
- package/build/matrices/arithmetic.d.ts.map +1 -1
- package/build/matrices/arithmetic.js +65 -107
- package/build/matrices/arithmetic.js.map +1 -1
- package/build/matrices/asserts.d.ts +26 -273
- package/build/matrices/asserts.d.ts.map +1 -1
- package/build/matrices/asserts.js +106 -350
- package/build/matrices/asserts.js.map +1 -1
- package/build/matrices/core.d.ts +150 -79
- package/build/matrices/core.d.ts.map +1 -1
- package/build/matrices/core.js +128 -104
- package/build/matrices/core.js.map +1 -1
- package/build/matrices/decompositions.d.ts +41 -44
- package/build/matrices/decompositions.d.ts.map +1 -1
- package/build/matrices/decompositions.js +51 -94
- package/build/matrices/decompositions.js.map +1 -1
- package/build/matrices/index.d.ts +2 -2
- package/build/matrices/index.d.ts.map +1 -1
- package/build/matrices/index.js +2 -2
- package/build/matrices/index.js.map +1 -1
- package/build/matrices/linear-algebra.d.ts +56 -19
- package/build/matrices/linear-algebra.d.ts.map +1 -1
- package/build/matrices/linear-algebra.js +80 -36
- package/build/matrices/linear-algebra.js.map +1 -1
- package/build/matrices/normalization.d.ts +36 -15
- 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 +39 -52
- package/build/matrices/transformations.d.ts.map +1 -1
- package/build/matrices/transformations.js +8 -11
- package/build/matrices/transformations.js.map +1 -1
- package/build/matrices/types.d.ts +39 -67
- 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 +114 -15
- package/build/quaternions/asserts.d.ts.map +1 -1
- package/build/quaternions/asserts.js +189 -51
- package/build/quaternions/asserts.js.map +1 -1
- package/build/quaternions/conversions.d.ts +18 -8
- package/build/quaternions/conversions.d.ts.map +1 -1
- package/build/quaternions/conversions.js +14 -4
- package/build/quaternions/conversions.js.map +1 -1
- package/build/quaternions/core.d.ts +31 -2
- package/build/quaternions/core.d.ts.map +1 -1
- package/build/quaternions/core.js +32 -4
- package/build/quaternions/core.js.map +1 -1
- package/build/quaternions/index.d.ts +2 -2
- package/build/quaternions/index.d.ts.map +1 -1
- package/build/quaternions/index.js +3 -2
- package/build/quaternions/index.js.map +1 -1
- package/build/quaternions/interpolation.d.ts +7 -1
- package/build/quaternions/interpolation.d.ts.map +1 -1
- package/build/quaternions/interpolation.js +12 -6
- package/build/quaternions/interpolation.js.map +1 -1
- package/build/quaternions/predefined.d.ts +7 -1
- package/build/quaternions/predefined.d.ts.map +1 -1
- package/build/quaternions/predefined.js +6 -0
- package/build/quaternions/predefined.js.map +1 -1
- package/build/quaternions/types.d.ts +24 -13
- 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 +33 -99
- package/build/vectors/asserts.d.ts.map +1 -1
- package/build/vectors/asserts.js +145 -181
- package/build/vectors/asserts.js.map +1 -1
- package/build/vectors/core.d.ts +76 -44
- package/build/vectors/core.d.ts.map +1 -1
- package/build/vectors/core.js +128 -119
- package/build/vectors/core.js.map +1 -1
- package/build/vectors/index.d.ts.map +1 -1
- package/build/vectors/index.js +1 -0
- package/build/vectors/index.js.map +1 -1
- package/build/vectors/interpolation.d.ts +13 -1
- package/build/vectors/interpolation.d.ts.map +1 -1
- package/build/vectors/interpolation.js +48 -47
- package/build/vectors/interpolation.js.map +1 -1
- package/build/vectors/predefined.d.ts +73 -25
- package/build/vectors/predefined.d.ts.map +1 -1
- package/build/vectors/predefined.js +62 -18
- 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 +4 -3
|
@@ -2,17 +2,6 @@
|
|
|
2
2
|
* Assertion utilities for quaternion validation and error handling.
|
|
3
3
|
* Provides runtime type checking and validation for quaternion operations.
|
|
4
4
|
*/
|
|
5
|
-
import { AssertVector, VectorError } from '../vectors/asserts.js';
|
|
6
|
-
/**
|
|
7
|
-
* Custom error class for quaternion-specific validation errors.
|
|
8
|
-
* Extends the base VectorError to maintain consistency with vector operations.
|
|
9
|
-
*/
|
|
10
|
-
export class QuaternionError extends VectorError {
|
|
11
|
-
constructor(message = '') {
|
|
12
|
-
super(message);
|
|
13
|
-
this.name = 'QuaternionError';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
5
|
/**
|
|
17
6
|
* Validates that a value is a proper quaternion.
|
|
18
7
|
* A valid quaternion must be an array of exactly 4 finite numbers.
|
|
@@ -22,26 +11,36 @@ export class QuaternionError extends VectorError {
|
|
|
22
11
|
* @throws {QuaternionError} If the quaternion is invalid
|
|
23
12
|
*
|
|
24
13
|
* @example
|
|
14
|
+
* ```typescript
|
|
25
15
|
* AssertQuaternion([0, 0, 0, 1]); // Valid - passes silently
|
|
26
16
|
* AssertQuaternion([1, 2, 3]); // Throws QuaternionError - wrong length
|
|
27
17
|
* AssertQuaternion([1, 2, 3, NaN]); // Throws QuaternionError - contains NaN
|
|
18
|
+
* ```
|
|
28
19
|
*/
|
|
29
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Error thrown when quaternion validation fails.
|
|
22
|
+
*/
|
|
23
|
+
export class QuaternionError extends Error {
|
|
24
|
+
code = 'QUATERNION_ERROR';
|
|
25
|
+
constructor(message, options) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = 'QuaternionError';
|
|
28
|
+
if (options?.cause) {
|
|
29
|
+
this.cause = options.cause;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function AssertQuaternion(quaternion) {
|
|
30
34
|
if (!Array.isArray(quaternion)) {
|
|
31
35
|
throw new QuaternionError('Quaternion must be an array');
|
|
32
36
|
}
|
|
33
37
|
if (quaternion.length !== 4) {
|
|
34
38
|
throw new QuaternionError(`Quaternion must have exactly 4 components, got ${quaternion.length}`);
|
|
35
39
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
if (error instanceof VectorError) {
|
|
42
|
-
throw new QuaternionError(error.message);
|
|
40
|
+
for (let i = 0; i < 4; i++) {
|
|
41
|
+
if (typeof quaternion[i] !== 'number' || Number.isNaN(quaternion[i])) {
|
|
42
|
+
throw new QuaternionError(`Quaternion component ${i} must be a number (not ${typeof quaternion[i]})`);
|
|
43
43
|
}
|
|
44
|
-
throw error;
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
/**
|
|
@@ -53,11 +52,17 @@ export function AssertQuaternion(quaternion, options = {}) {
|
|
|
53
52
|
* @throws {QuaternionError} If the quaternion is not normalized
|
|
54
53
|
*
|
|
55
54
|
* @example
|
|
55
|
+
* ```typescript
|
|
56
56
|
* AssertNormalizedQuaternion([0, 0, 0, 1]); // Valid unit quaternion
|
|
57
57
|
* AssertNormalizedQuaternion([1, 1, 1, 1]); // Throws - not normalized
|
|
58
|
+
* ```
|
|
58
59
|
*/
|
|
59
60
|
export function AssertNormalizedQuaternion(quaternion, tolerance = 1e-6) {
|
|
60
61
|
AssertQuaternion(quaternion);
|
|
62
|
+
// Type guard to establish type narrowing for TypeScript
|
|
63
|
+
if (!Array.isArray(quaternion) || quaternion.length !== 4) {
|
|
64
|
+
throw new QuaternionError('Quaternion must be an array of 4 numbers');
|
|
65
|
+
}
|
|
61
66
|
const [x, y, z, w] = quaternion;
|
|
62
67
|
const magnitude = Math.sqrt((x * x) + (y * y) + (z * z) + (w * w));
|
|
63
68
|
if (Math.abs(magnitude - 1) > tolerance) {
|
|
@@ -72,21 +77,18 @@ export function AssertNormalizedQuaternion(quaternion, tolerance = 1e-6) {
|
|
|
72
77
|
* @param options - Validation options
|
|
73
78
|
* @throws {QuaternionError} If the Euler angles are invalid
|
|
74
79
|
*/
|
|
75
|
-
export function AssertEulerAngles(euler
|
|
80
|
+
export function AssertEulerAngles(euler) {
|
|
76
81
|
if (!Array.isArray(euler)) {
|
|
77
82
|
throw new QuaternionError('Euler angles must be an array');
|
|
78
83
|
}
|
|
79
84
|
if (euler.length !== 3) {
|
|
80
85
|
throw new QuaternionError(`Euler angles must have exactly 3 components, got ${euler.length}`);
|
|
81
86
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (error instanceof VectorError) {
|
|
87
|
-
throw new QuaternionError(`Invalid Euler angles: ${error.message}`);
|
|
87
|
+
// Validate each element is a number (NaN is rejected, but Infinity is allowed)
|
|
88
|
+
for (let i = 0; i < 3; i++) {
|
|
89
|
+
if (typeof euler[i] !== 'number' || Number.isNaN(euler[i])) {
|
|
90
|
+
throw new QuaternionError(`Invalid Euler angles: component ${i} must be a number (not ${typeof euler[i]})`);
|
|
88
91
|
}
|
|
89
|
-
throw error;
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
/**
|
|
@@ -97,32 +99,29 @@ export function AssertEulerAngles(euler, options = {}) {
|
|
|
97
99
|
* @param options - Validation options
|
|
98
100
|
* @throws {QuaternionError} If the axis-angle is invalid
|
|
99
101
|
*/
|
|
100
|
-
export function AssertAxisAngle(axisAngle
|
|
102
|
+
export function AssertAxisAngle(axisAngle) {
|
|
101
103
|
if (!Array.isArray(axisAngle)) {
|
|
102
104
|
throw new QuaternionError('Axis-angle must be an array');
|
|
103
105
|
}
|
|
104
106
|
if (axisAngle.length !== 4) {
|
|
105
107
|
throw new QuaternionError(`Axis-angle must have exactly 4 components, got ${axisAngle.length}`);
|
|
106
108
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (error instanceof VectorError) {
|
|
112
|
-
throw new QuaternionError(`Invalid axis-angle: ${error.message}`);
|
|
109
|
+
// Validate each element is a number (NaN is rejected, but Infinity is allowed)
|
|
110
|
+
for (let i = 0; i < 4; i++) {
|
|
111
|
+
if (typeof axisAngle[i] !== 'number' || Number.isNaN(axisAngle[i])) {
|
|
112
|
+
throw new QuaternionError(`Invalid axis-angle: component ${i} must be a number (not ${typeof axisAngle[i]})`);
|
|
113
113
|
}
|
|
114
|
-
throw error;
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
116
|
/**
|
|
118
117
|
* Validates that a value is a proper rotation matrix.
|
|
119
|
-
* Rotation matrix must be a 3x3 matrix (
|
|
118
|
+
* Rotation matrix must be a 3x3 matrix (TMatrix3).
|
|
120
119
|
*
|
|
121
120
|
* @param matrix - The value to validate as a rotation matrix
|
|
122
121
|
* @param options - Validation options
|
|
123
122
|
* @throws {QuaternionError} If the rotation matrix is invalid
|
|
124
123
|
*/
|
|
125
|
-
export function AssertRotationMatrix(matrix
|
|
124
|
+
export function AssertRotationMatrix(matrix) {
|
|
126
125
|
if (!Array.isArray(matrix)) {
|
|
127
126
|
throw new QuaternionError('Rotation matrix must be an array');
|
|
128
127
|
}
|
|
@@ -137,14 +136,11 @@ export function AssertRotationMatrix(matrix, options = {}) {
|
|
|
137
136
|
if (matrix[i].length !== 3) {
|
|
138
137
|
throw new QuaternionError(`Rotation matrix row ${i} must have exactly 3 elements, got ${matrix[i].length}`);
|
|
139
138
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (error instanceof VectorError) {
|
|
145
|
-
throw new QuaternionError(`Invalid rotation matrix row ${i}: ${error.message}`);
|
|
139
|
+
// Validate each element is a number (NaN is rejected, but Infinity is allowed)
|
|
140
|
+
for (let j = 0; j < 3; j++) {
|
|
141
|
+
if (typeof matrix[i][j] !== 'number' || Number.isNaN(matrix[i][j])) {
|
|
142
|
+
throw new QuaternionError(`Invalid rotation matrix row ${i}: component ${j} must be a number (not ${typeof matrix[i][j]})`);
|
|
146
143
|
}
|
|
147
|
-
throw error;
|
|
148
144
|
}
|
|
149
145
|
}
|
|
150
146
|
}
|
|
@@ -156,20 +152,162 @@ export function AssertRotationMatrix(matrix, options = {}) {
|
|
|
156
152
|
* @param options - Validation options
|
|
157
153
|
* @throws {QuaternionError} If any quaternion is invalid
|
|
158
154
|
*/
|
|
159
|
-
export function AssertQuaternions(quaternions
|
|
155
|
+
export function AssertQuaternions(quaternions) {
|
|
160
156
|
if (!Array.isArray(quaternions)) {
|
|
161
157
|
throw new QuaternionError('Quaternions must be an array');
|
|
162
158
|
}
|
|
163
159
|
for (let i = 0; i < quaternions.length; i++) {
|
|
164
160
|
try {
|
|
165
|
-
AssertQuaternion(quaternions[i]
|
|
161
|
+
AssertQuaternion(quaternions[i]);
|
|
166
162
|
}
|
|
167
163
|
catch (error) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
164
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
165
|
+
throw new QuaternionError(`Invalid quaternion at index ${i}: ${message}`, {
|
|
166
|
+
cause: error instanceof Error ? error : undefined,
|
|
167
|
+
});
|
|
172
168
|
}
|
|
173
169
|
}
|
|
174
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Validates that an unknown value is a valid quaternion without throwing an error.
|
|
173
|
+
*
|
|
174
|
+
* This function performs the same validation as AssertQuaternion but returns
|
|
175
|
+
* a boolean instead of throwing an exception, making it suitable for
|
|
176
|
+
* conditional logic where exceptions are not desired.
|
|
177
|
+
*
|
|
178
|
+
* @param quaternion - The value to validate as a quaternion
|
|
179
|
+
* @param options - Validation options
|
|
180
|
+
* @returns true if the quaternion is valid, false otherwise
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* if (ValidateQuaternion(someValue)) {
|
|
185
|
+
* // Process the valid quaternion
|
|
186
|
+
* }
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export function ValidateQuaternion(quaternion) {
|
|
190
|
+
try {
|
|
191
|
+
AssertQuaternion(quaternion);
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Validates that a quaternion is normalized (magnitude = 1) without throwing an error.
|
|
200
|
+
*
|
|
201
|
+
* @param quaternion - The quaternion to validate as normalized
|
|
202
|
+
* @param tolerance - Maximum allowed deviation from unit magnitude (default: 1e-6)
|
|
203
|
+
* @returns true if the quaternion is normalized, false otherwise
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* if (ValidateNormalizedQuaternion([1, 0, 0, 0])) {
|
|
208
|
+
* // Process the normalized quaternion
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export function ValidateNormalizedQuaternion(quaternion, tolerance = 1e-6) {
|
|
213
|
+
try {
|
|
214
|
+
AssertNormalizedQuaternion(quaternion, tolerance);
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Validates that an unknown value is valid Euler angles without throwing an error.
|
|
223
|
+
*
|
|
224
|
+
* @param euler - The value to validate as Euler angles
|
|
225
|
+
* @param options - Validation options
|
|
226
|
+
* @returns true if the Euler angles are valid, false otherwise
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```typescript
|
|
230
|
+
* if (ValidateEulerAngles([0.5, 1.0, 1.5])) {
|
|
231
|
+
* // Process the valid Euler angles
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
export function ValidateEulerAngles(euler) {
|
|
236
|
+
try {
|
|
237
|
+
AssertEulerAngles(euler);
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Validates that an unknown value is a valid axis-angle representation without throwing an error.
|
|
246
|
+
*
|
|
247
|
+
* @param axisAngle - The value to validate as axis-angle
|
|
248
|
+
* @param options - Validation options
|
|
249
|
+
* @returns true if the axis-angle is valid, false otherwise
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* if (ValidateAxisAngle({ axis: [0, 0, 1], angle: Math.PI / 2 })) {
|
|
254
|
+
* // Process the valid axis-angle
|
|
255
|
+
* }
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
export function ValidateAxisAngle(axisAngle) {
|
|
259
|
+
try {
|
|
260
|
+
AssertAxisAngle(axisAngle);
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Validates that an unknown value is a valid rotation matrix without throwing an error.
|
|
269
|
+
*
|
|
270
|
+
* @param matrix - The value to validate as a rotation matrix
|
|
271
|
+
* @param options - Validation options
|
|
272
|
+
* @returns true if the matrix is a valid rotation matrix, false otherwise
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* if (ValidateRotationMatrix(someValue)) {
|
|
277
|
+
* // Process the valid rotation matrix
|
|
278
|
+
* }
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
export function ValidateRotationMatrix(matrix) {
|
|
282
|
+
try {
|
|
283
|
+
AssertRotationMatrix(matrix);
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Validates that an unknown value is an array of valid quaternions without throwing an error.
|
|
292
|
+
*
|
|
293
|
+
* @param quaternions - The value to validate as an array of quaternions
|
|
294
|
+
* @param options - Validation options
|
|
295
|
+
* @returns true if all quaternions are valid, false otherwise
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* if (ValidateQuaternions([q1, q2, q3])) {
|
|
300
|
+
* // Process the valid quaternion array
|
|
301
|
+
* }
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
export function ValidateQuaternions(quaternions) {
|
|
305
|
+
try {
|
|
306
|
+
AssertQuaternions(quaternions);
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
175
313
|
//# sourceMappingURL=asserts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asserts.js","sourceRoot":"","sources":["../../src/quaternions/asserts.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"asserts.js","sourceRoot":"","sources":["../../src/quaternions/asserts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;;;;;;;GAcG;AACH;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACzB,IAAI,GAAW,kBAAkB,CAAC;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;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAsB;IACzD,IAAI,CAAC;QACJ,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC"}
|
|
@@ -2,32 +2,36 @@
|
|
|
2
2
|
* Conversion utilities for quaternions and various rotation representations.
|
|
3
3
|
* Provides comprehensive conversion between different rotation formats.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import { TQuaternion, TRotationMatrix } from './types.js';
|
|
5
|
+
import type { TMatrix4 } from '../matrices/types.js';
|
|
6
|
+
import type { TQuaternion, TRotationMatrix } from './types.js';
|
|
7
7
|
/**
|
|
8
8
|
* Converts a quaternion to a 3x3 rotation matrix.
|
|
9
|
-
* The matrix is returned as a proper
|
|
9
|
+
* The matrix is returned as a proper TMatrix3 type.
|
|
10
10
|
*
|
|
11
11
|
* @param quaternion - The normalized quaternion to convert
|
|
12
|
-
* @returns 3x3 rotation matrix as
|
|
12
|
+
* @returns 3x3 rotation matrix as TMatrix3
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
|
+
* ```typescript
|
|
15
16
|
* const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z-axis
|
|
16
17
|
* const matrix = QuaternionToRotationMatrix(q);
|
|
17
18
|
* // matrix represents rotation that transforms +X to +Y
|
|
19
|
+
* ```
|
|
18
20
|
*/
|
|
19
21
|
export declare function QuaternionToRotationMatrix(quaternion: TQuaternion): TRotationMatrix;
|
|
20
22
|
/**
|
|
21
23
|
* Converts a 3x3 rotation matrix to a quaternion.
|
|
22
|
-
* The matrix should be a proper
|
|
24
|
+
* The matrix should be a proper TMatrix3 type.
|
|
23
25
|
*
|
|
24
|
-
* @param matrix - 3x3 rotation matrix as
|
|
26
|
+
* @param matrix - 3x3 rotation matrix as TMatrix3
|
|
25
27
|
* @returns Normalized quaternion representing the same rotation
|
|
26
28
|
*
|
|
27
29
|
* @example
|
|
30
|
+
* ```typescript
|
|
28
31
|
* const identityMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
29
32
|
* const q = QuaternionFromRotationMatrix(identityMatrix);
|
|
30
33
|
* console.log(q); // [0, 0, 0, 1] (identity quaternion)
|
|
34
|
+
* ```
|
|
31
35
|
*/
|
|
32
36
|
export declare function QuaternionFromRotationMatrix(matrix: TRotationMatrix): TQuaternion;
|
|
33
37
|
/**
|
|
@@ -39,11 +43,13 @@ export declare function QuaternionFromRotationMatrix(matrix: TRotationMatrix): T
|
|
|
39
43
|
* @returns 4x4 transformation matrix as a flat array of 16 elements (row-major)
|
|
40
44
|
*
|
|
41
45
|
* @example
|
|
46
|
+
* ```typescript
|
|
42
47
|
* const q = [0, 0, 0, 1]; // Identity quaternion
|
|
43
48
|
* const matrix4x4 = QuaternionToTransformationMatrix(q);
|
|
44
49
|
* // Returns identity 4x4 matrix
|
|
50
|
+
* ```
|
|
45
51
|
*/
|
|
46
|
-
export declare function QuaternionToTransformationMatrix(quaternion: TQuaternion):
|
|
52
|
+
export declare function QuaternionToTransformationMatrix(quaternion: TQuaternion): TMatrix4;
|
|
47
53
|
/**
|
|
48
54
|
* Extracts the rotation quaternion from a 4x4 transformation matrix.
|
|
49
55
|
* Ignores translation and scaling components, extracting only the rotation.
|
|
@@ -52,11 +58,13 @@ export declare function QuaternionToTransformationMatrix(quaternion: TQuaternion
|
|
|
52
58
|
* @returns Normalized quaternion representing the rotation component
|
|
53
59
|
*
|
|
54
60
|
* @example
|
|
61
|
+
* ```typescript
|
|
55
62
|
* const transformMatrix = [1, 0, 0, 5, 0, 1, 0, 10, 0, 0, 1, 15, 0, 0, 0, 1];
|
|
56
63
|
* const q = QuaternionFromTransformationMatrix(transformMatrix);
|
|
57
64
|
* // Extracts rotation (identity in this case), ignores translation [5, 10, 15]
|
|
65
|
+
* ```
|
|
58
66
|
*/
|
|
59
|
-
export declare function QuaternionFromTransformationMatrix(matrix:
|
|
67
|
+
export declare function QuaternionFromTransformationMatrix(matrix: TMatrix4): TQuaternion;
|
|
60
68
|
/**
|
|
61
69
|
* Checks if a matrix is a valid rotation matrix.
|
|
62
70
|
* A valid rotation matrix should be orthogonal and have determinant +1.
|
|
@@ -66,8 +74,10 @@ export declare function QuaternionFromTransformationMatrix(matrix: IMatrix4): TQ
|
|
|
66
74
|
* @returns True if the matrix is a valid rotation matrix
|
|
67
75
|
*
|
|
68
76
|
* @example
|
|
77
|
+
* ```typescript
|
|
69
78
|
* const matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // Identity matrix
|
|
70
79
|
* console.log(IsValidRotationMatrix(matrix)); // true
|
|
80
|
+
* ```
|
|
71
81
|
*/
|
|
72
82
|
export declare function IsValidRotationMatrix(matrix: TRotationMatrix, tolerance?: number): boolean;
|
|
73
83
|
//# sourceMappingURL=conversions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversions.d.ts","sourceRoot":"","sources":["../../src/quaternions/conversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"conversions.d.ts","sourceRoot":"","sources":["../../src/quaternions/conversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAI/D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,WAAW,GAAG,eAAe,CAmBnF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CAyCjF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,WAAW,GAAG,QAAQ,CAUlF;AACD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,QAAQ,GAAG,WAAW,CAShF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,GAAE,MAAa,GAAG,OAAO,CAkChG"}
|
|
@@ -6,15 +6,17 @@ import { AssertNormalizedQuaternion, AssertRotationMatrix } from './asserts.js';
|
|
|
6
6
|
const SHEPPERD_QUARTER = 0.25;
|
|
7
7
|
/**
|
|
8
8
|
* Converts a quaternion to a 3x3 rotation matrix.
|
|
9
|
-
* The matrix is returned as a proper
|
|
9
|
+
* The matrix is returned as a proper TMatrix3 type.
|
|
10
10
|
*
|
|
11
11
|
* @param quaternion - The normalized quaternion to convert
|
|
12
|
-
* @returns 3x3 rotation matrix as
|
|
12
|
+
* @returns 3x3 rotation matrix as TMatrix3
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
|
+
* ```typescript
|
|
15
16
|
* const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z-axis
|
|
16
17
|
* const matrix = QuaternionToRotationMatrix(q);
|
|
17
18
|
* // matrix represents rotation that transforms +X to +Y
|
|
19
|
+
* ```
|
|
18
20
|
*/
|
|
19
21
|
export function QuaternionToRotationMatrix(quaternion) {
|
|
20
22
|
AssertNormalizedQuaternion(quaternion);
|
|
@@ -36,15 +38,17 @@ export function QuaternionToRotationMatrix(quaternion) {
|
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* Converts a 3x3 rotation matrix to a quaternion.
|
|
39
|
-
* The matrix should be a proper
|
|
41
|
+
* The matrix should be a proper TMatrix3 type.
|
|
40
42
|
*
|
|
41
|
-
* @param matrix - 3x3 rotation matrix as
|
|
43
|
+
* @param matrix - 3x3 rotation matrix as TMatrix3
|
|
42
44
|
* @returns Normalized quaternion representing the same rotation
|
|
43
45
|
*
|
|
44
46
|
* @example
|
|
47
|
+
* ```typescript
|
|
45
48
|
* const identityMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
46
49
|
* const q = QuaternionFromRotationMatrix(identityMatrix);
|
|
47
50
|
* console.log(q); // [0, 0, 0, 1] (identity quaternion)
|
|
51
|
+
* ```
|
|
48
52
|
*/
|
|
49
53
|
export function QuaternionFromRotationMatrix(matrix) {
|
|
50
54
|
AssertRotationMatrix(matrix);
|
|
@@ -97,9 +101,11 @@ export function QuaternionFromRotationMatrix(matrix) {
|
|
|
97
101
|
* @returns 4x4 transformation matrix as a flat array of 16 elements (row-major)
|
|
98
102
|
*
|
|
99
103
|
* @example
|
|
104
|
+
* ```typescript
|
|
100
105
|
* const q = [0, 0, 0, 1]; // Identity quaternion
|
|
101
106
|
* const matrix4x4 = QuaternionToTransformationMatrix(q);
|
|
102
107
|
* // Returns identity 4x4 matrix
|
|
108
|
+
* ```
|
|
103
109
|
*/
|
|
104
110
|
export function QuaternionToTransformationMatrix(quaternion) {
|
|
105
111
|
const rotationMatrix = QuaternionToRotationMatrix(quaternion);
|
|
@@ -119,9 +125,11 @@ export function QuaternionToTransformationMatrix(quaternion) {
|
|
|
119
125
|
* @returns Normalized quaternion representing the rotation component
|
|
120
126
|
*
|
|
121
127
|
* @example
|
|
128
|
+
* ```typescript
|
|
122
129
|
* const transformMatrix = [1, 0, 0, 5, 0, 1, 0, 10, 0, 0, 1, 15, 0, 0, 0, 1];
|
|
123
130
|
* const q = QuaternionFromTransformationMatrix(transformMatrix);
|
|
124
131
|
* // Extracts rotation (identity in this case), ignores translation [5, 10, 15]
|
|
132
|
+
* ```
|
|
125
133
|
*/
|
|
126
134
|
export function QuaternionFromTransformationMatrix(matrix) {
|
|
127
135
|
// Extract 3x3 rotation matrix from 4x4 transformation matrix
|
|
@@ -141,8 +149,10 @@ export function QuaternionFromTransformationMatrix(matrix) {
|
|
|
141
149
|
* @returns True if the matrix is a valid rotation matrix
|
|
142
150
|
*
|
|
143
151
|
* @example
|
|
152
|
+
* ```typescript
|
|
144
153
|
* const matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // Identity matrix
|
|
145
154
|
* console.log(IsValidRotationMatrix(matrix)); // true
|
|
155
|
+
* ```
|
|
146
156
|
*/
|
|
147
157
|
export function IsValidRotationMatrix(matrix, tolerance = 1e-6) {
|
|
148
158
|
AssertRotationMatrix(matrix);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversions.js","sourceRoot":"","sources":["../../src/quaternions/conversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGhF,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B
|
|
1
|
+
{"version":3,"file":"conversions.js","sourceRoot":"","sources":["../../src/quaternions/conversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGhF,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,0BAA0B,CAAC,UAAuB;IACjE,0BAA0B,CAAC,UAAU,CAAC,CAAC;IAEvC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC;IAChC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC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