@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,320 @@
|
|
|
1
|
+
import { QuaternionError, AssertQuaternion, AssertNormalizedQuaternion, AssertEulerAngles, AssertAxisAngle, AssertRotationMatrix, AssertQuaternions, } from './asserts.js';
|
|
2
|
+
describe('Quaternions Assertions', () => {
|
|
3
|
+
describe('QuaternionError', () => {
|
|
4
|
+
test('should create a QuaternionError with message', () => {
|
|
5
|
+
const error = new QuaternionError('test message');
|
|
6
|
+
expect(error).toBeInstanceOf(Error);
|
|
7
|
+
expect(error).toBeInstanceOf(QuaternionError);
|
|
8
|
+
expect(error.name).toBe('QuaternionError');
|
|
9
|
+
expect(error.message).toBe('test message');
|
|
10
|
+
});
|
|
11
|
+
test('should create a QuaternionError without message', () => {
|
|
12
|
+
const error = new QuaternionError();
|
|
13
|
+
expect(error).toBeInstanceOf(Error);
|
|
14
|
+
expect(error).toBeInstanceOf(QuaternionError);
|
|
15
|
+
expect(error.name).toBe('QuaternionError');
|
|
16
|
+
expect(error.message).toBe('');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe('AssertQuaternion', () => {
|
|
20
|
+
test('should pass for valid quaternions', () => {
|
|
21
|
+
expect(() => AssertQuaternion([0, 0, 0, 1])).not.toThrow();
|
|
22
|
+
expect(() => AssertQuaternion([1, 0, 0, 0])).not.toThrow();
|
|
23
|
+
expect(() => AssertQuaternion([0.5, 0.5, 0.5, 0.5])).not.toThrow();
|
|
24
|
+
expect(() => AssertQuaternion([-1, -2, -3, -4])).not.toThrow();
|
|
25
|
+
expect(() => AssertQuaternion([0, 0, 0, 0])).not.toThrow();
|
|
26
|
+
});
|
|
27
|
+
test('should throw for non-arrays', () => {
|
|
28
|
+
expect(() => AssertQuaternion(null)).toThrow(QuaternionError);
|
|
29
|
+
expect(() => AssertQuaternion(undefined)).toThrow(QuaternionError);
|
|
30
|
+
expect(() => AssertQuaternion(123)).toThrow(QuaternionError);
|
|
31
|
+
expect(() => AssertQuaternion('string')).toThrow(QuaternionError);
|
|
32
|
+
expect(() => AssertQuaternion({})).toThrow(QuaternionError);
|
|
33
|
+
});
|
|
34
|
+
test('should throw for arrays with wrong length', () => {
|
|
35
|
+
expect(() => AssertQuaternion([])).toThrow(QuaternionError);
|
|
36
|
+
expect(() => AssertQuaternion([1])).toThrow(QuaternionError);
|
|
37
|
+
expect(() => AssertQuaternion([1, 2])).toThrow(QuaternionError);
|
|
38
|
+
expect(() => AssertQuaternion([1, 2, 3])).toThrow(QuaternionError);
|
|
39
|
+
expect(() => AssertQuaternion([1, 2, 3, 4, 5])).toThrow(QuaternionError);
|
|
40
|
+
});
|
|
41
|
+
test('should throw for arrays with non-number elements', () => {
|
|
42
|
+
expect(() => AssertQuaternion([1, 2, 3, 'string'])).toThrow(QuaternionError);
|
|
43
|
+
expect(() => AssertQuaternion([1, null, 3, 4])).toThrow(QuaternionError);
|
|
44
|
+
expect(() => AssertQuaternion([1, undefined, 3, 4])).toThrow(QuaternionError);
|
|
45
|
+
expect(() => AssertQuaternion([1, {}, 3, 4])).toThrow(QuaternionError);
|
|
46
|
+
expect(() => AssertQuaternion([NaN, 0, 0, 1])).toThrow(QuaternionError);
|
|
47
|
+
// Note: Infinity is allowed by vector validation (finite constraint not set by default)
|
|
48
|
+
expect(() => AssertQuaternion([0, 0, 0, Infinity])).not.toThrow();
|
|
49
|
+
});
|
|
50
|
+
test('should throw with specific error messages', () => {
|
|
51
|
+
expect(() => AssertQuaternion('not an array')).toThrow('Quaternion must be an array');
|
|
52
|
+
expect(() => AssertQuaternion([1, 2, 3])).toThrow('Quaternion must have exactly 4 components, got 3');
|
|
53
|
+
expect(() => AssertQuaternion([1, 2, 3, 4, 5])).toThrow('Quaternion must have exactly 4 components, got 5');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('AssertNormalizedQuaternion', () => {
|
|
57
|
+
test('should pass for normalized quaternions', () => {
|
|
58
|
+
expect(() => AssertNormalizedQuaternion([0, 0, 0, 1])).not.toThrow();
|
|
59
|
+
expect(() => AssertNormalizedQuaternion([1, 0, 0, 0])).not.toThrow();
|
|
60
|
+
expect(() => AssertNormalizedQuaternion([0, 1, 0, 0])).not.toThrow();
|
|
61
|
+
expect(() => AssertNormalizedQuaternion([0, 0, 1, 0])).not.toThrow();
|
|
62
|
+
expect(() => AssertNormalizedQuaternion([0.5, 0.5, 0.5, 0.5])).not.toThrow();
|
|
63
|
+
expect(() => AssertNormalizedQuaternion([0.707107, 0, 0, 0.707107])).not.toThrow();
|
|
64
|
+
});
|
|
65
|
+
test('should throw for non-normalized quaternions', () => {
|
|
66
|
+
expect(() => AssertNormalizedQuaternion([1, 1, 1, 1])).toThrow(QuaternionError);
|
|
67
|
+
expect(() => AssertNormalizedQuaternion([2, 0, 0, 0])).toThrow(QuaternionError);
|
|
68
|
+
expect(() => AssertNormalizedQuaternion([0, 0, 0, 2])).toThrow(QuaternionError);
|
|
69
|
+
expect(() => AssertNormalizedQuaternion([0.1, 0.1, 0.1, 0.1])).toThrow(QuaternionError);
|
|
70
|
+
});
|
|
71
|
+
test('should respect tolerance parameter', () => {
|
|
72
|
+
const almostNormalized = [0.99999, 0, 0, 0];
|
|
73
|
+
expect(() => AssertNormalizedQuaternion(almostNormalized, 1e-4)).not.toThrow();
|
|
74
|
+
expect(() => AssertNormalizedQuaternion(almostNormalized, 1e-6)).toThrow(QuaternionError);
|
|
75
|
+
});
|
|
76
|
+
test('should use default tolerance', () => {
|
|
77
|
+
// A quaternion [1.000001, 0, 0, 0] has magnitude ≈ 1.000001
|
|
78
|
+
// Difference from 1 is ≈ 0.000001 = 1e-6, which equals the default tolerance
|
|
79
|
+
// Since the difference equals tolerance, it should pass (not greater than tolerance)
|
|
80
|
+
const slightlyOff = [1.000001, 0, 0, 0];
|
|
81
|
+
expect(() => AssertNormalizedQuaternion(slightlyOff)).not.toThrow();
|
|
82
|
+
// Test with a value that clearly exceeds default tolerance
|
|
83
|
+
const clearlyOff = [1.00001, 0, 0, 0]; // difference ≈ 1e-5, much larger than 1e-6
|
|
84
|
+
expect(() => AssertNormalizedQuaternion(clearlyOff)).toThrow(QuaternionError);
|
|
85
|
+
});
|
|
86
|
+
test('should throw with magnitude information', () => {
|
|
87
|
+
const magnitude2 = [2, 0, 0, 0];
|
|
88
|
+
expect(() => AssertNormalizedQuaternion(magnitude2)).toThrow(/magnitude = 2/);
|
|
89
|
+
});
|
|
90
|
+
test('should validate quaternion first', () => {
|
|
91
|
+
expect(() => AssertNormalizedQuaternion([1, 2, 3])).toThrow(QuaternionError);
|
|
92
|
+
expect(() => AssertNormalizedQuaternion('invalid')).toThrow(QuaternionError);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
describe('AssertEulerAngles', () => {
|
|
96
|
+
test('should pass for valid Euler angles', () => {
|
|
97
|
+
expect(() => AssertEulerAngles([0, 0, 0])).not.toThrow();
|
|
98
|
+
expect(() => AssertEulerAngles([Math.PI, 0, 0])).not.toThrow();
|
|
99
|
+
expect(() => AssertEulerAngles([0, Math.PI / 2, 0])).not.toThrow();
|
|
100
|
+
expect(() => AssertEulerAngles([Math.PI / 4, Math.PI / 3, Math.PI / 6])).not.toThrow();
|
|
101
|
+
expect(() => AssertEulerAngles([-Math.PI, -Math.PI / 2, -Math.PI / 4])).not.toThrow();
|
|
102
|
+
});
|
|
103
|
+
test('should throw for non-arrays', () => {
|
|
104
|
+
expect(() => AssertEulerAngles(null)).toThrow(QuaternionError);
|
|
105
|
+
expect(() => AssertEulerAngles(undefined)).toThrow(QuaternionError);
|
|
106
|
+
expect(() => AssertEulerAngles(123)).toThrow(QuaternionError);
|
|
107
|
+
expect(() => AssertEulerAngles('string')).toThrow(QuaternionError);
|
|
108
|
+
expect(() => AssertEulerAngles({})).toThrow(QuaternionError);
|
|
109
|
+
});
|
|
110
|
+
test('should throw for arrays with wrong length', () => {
|
|
111
|
+
expect(() => AssertEulerAngles([])).toThrow(QuaternionError);
|
|
112
|
+
expect(() => AssertEulerAngles([1])).toThrow(QuaternionError);
|
|
113
|
+
expect(() => AssertEulerAngles([1, 2])).toThrow(QuaternionError);
|
|
114
|
+
expect(() => AssertEulerAngles([1, 2, 3, 4])).toThrow(QuaternionError);
|
|
115
|
+
});
|
|
116
|
+
test('should throw for arrays with non-number elements', () => {
|
|
117
|
+
expect(() => AssertEulerAngles([1, 2, 'string'])).toThrow(QuaternionError);
|
|
118
|
+
expect(() => AssertEulerAngles([1, null, 3])).toThrow(QuaternionError);
|
|
119
|
+
expect(() => AssertEulerAngles([1, undefined, 3])).toThrow(QuaternionError);
|
|
120
|
+
expect(() => AssertEulerAngles([NaN, 0, 0])).toThrow(QuaternionError);
|
|
121
|
+
// Note: Infinity is allowed by vector validation (finite constraint not set by default)
|
|
122
|
+
expect(() => AssertEulerAngles([0, Infinity, 0])).not.toThrow();
|
|
123
|
+
});
|
|
124
|
+
test('should throw with specific error messages', () => {
|
|
125
|
+
expect(() => AssertEulerAngles('not an array')).toThrow('Euler angles must be an array');
|
|
126
|
+
expect(() => AssertEulerAngles([1, 2])).toThrow('Euler angles must have exactly 3 components, got 2');
|
|
127
|
+
});
|
|
128
|
+
test('should wrap VectorError in QuaternionError', () => {
|
|
129
|
+
expect(() => AssertEulerAngles([1, 2, NaN])).toThrow(QuaternionError);
|
|
130
|
+
expect(() => AssertEulerAngles([1, 2, NaN])).toThrow(/Invalid Euler angles:/);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
describe('AssertAxisAngle', () => {
|
|
134
|
+
test('should pass for valid axis-angle representations', () => {
|
|
135
|
+
expect(() => AssertAxisAngle([1, 0, 0, 0])).not.toThrow();
|
|
136
|
+
expect(() => AssertAxisAngle([0, 1, 0, Math.PI / 2])).not.toThrow();
|
|
137
|
+
expect(() => AssertAxisAngle([0, 0, 1, Math.PI])).not.toThrow();
|
|
138
|
+
expect(() => AssertAxisAngle([0.707, 0.707, 0, Math.PI / 4])).not.toThrow();
|
|
139
|
+
expect(() => AssertAxisAngle([0, 0, 0, 0])).not.toThrow();
|
|
140
|
+
});
|
|
141
|
+
test('should throw for non-arrays', () => {
|
|
142
|
+
expect(() => AssertAxisAngle(null)).toThrow(QuaternionError);
|
|
143
|
+
expect(() => AssertAxisAngle(undefined)).toThrow(QuaternionError);
|
|
144
|
+
expect(() => AssertAxisAngle(123)).toThrow(QuaternionError);
|
|
145
|
+
expect(() => AssertAxisAngle('string')).toThrow(QuaternionError);
|
|
146
|
+
expect(() => AssertAxisAngle({})).toThrow(QuaternionError);
|
|
147
|
+
});
|
|
148
|
+
test('should throw for arrays with wrong length', () => {
|
|
149
|
+
expect(() => AssertAxisAngle([])).toThrow(QuaternionError);
|
|
150
|
+
expect(() => AssertAxisAngle([1])).toThrow(QuaternionError);
|
|
151
|
+
expect(() => AssertAxisAngle([1, 2])).toThrow(QuaternionError);
|
|
152
|
+
expect(() => AssertAxisAngle([1, 2, 3])).toThrow(QuaternionError);
|
|
153
|
+
expect(() => AssertAxisAngle([1, 2, 3, 4, 5])).toThrow(QuaternionError);
|
|
154
|
+
});
|
|
155
|
+
test('should throw for arrays with non-number elements', () => {
|
|
156
|
+
expect(() => AssertAxisAngle([1, 2, 3, 'string'])).toThrow(QuaternionError);
|
|
157
|
+
expect(() => AssertAxisAngle([1, null, 3, 4])).toThrow(QuaternionError);
|
|
158
|
+
expect(() => AssertAxisAngle([1, undefined, 3, 4])).toThrow(QuaternionError);
|
|
159
|
+
expect(() => AssertAxisAngle([NaN, 0, 0, 1])).toThrow(QuaternionError);
|
|
160
|
+
// Note: Infinity is allowed by vector validation (finite constraint not set by default)
|
|
161
|
+
expect(() => AssertAxisAngle([0, 0, 0, Infinity])).not.toThrow();
|
|
162
|
+
});
|
|
163
|
+
test('should throw with specific error messages', () => {
|
|
164
|
+
expect(() => AssertAxisAngle('not an array')).toThrow('Axis-angle must be an array');
|
|
165
|
+
expect(() => AssertAxisAngle([1, 2, 3])).toThrow('Axis-angle must have exactly 4 components, got 3');
|
|
166
|
+
});
|
|
167
|
+
test('should wrap VectorError in QuaternionError', () => {
|
|
168
|
+
expect(() => AssertAxisAngle([1, 2, 3, NaN])).toThrow(QuaternionError);
|
|
169
|
+
expect(() => AssertAxisAngle([1, 2, 3, NaN])).toThrow(/Invalid axis-angle:/);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
describe('AssertRotationMatrix', () => {
|
|
173
|
+
test('should pass for valid rotation matrices', () => {
|
|
174
|
+
// Identity matrix
|
|
175
|
+
expect(() => AssertRotationMatrix([
|
|
176
|
+
[1, 0, 0],
|
|
177
|
+
[0, 1, 0],
|
|
178
|
+
[0, 0, 1],
|
|
179
|
+
])).not.toThrow();
|
|
180
|
+
// 90-degree rotation around Z-axis
|
|
181
|
+
expect(() => AssertRotationMatrix([
|
|
182
|
+
[0, -1, 0],
|
|
183
|
+
[1, 0, 0],
|
|
184
|
+
[0, 0, 1],
|
|
185
|
+
])).not.toThrow();
|
|
186
|
+
// Generic valid matrix
|
|
187
|
+
expect(() => AssertRotationMatrix([
|
|
188
|
+
[0.5, 0.5, 0.707],
|
|
189
|
+
[-0.5, 0.866, 0],
|
|
190
|
+
[-0.612, -0.354, 0.707],
|
|
191
|
+
])).not.toThrow();
|
|
192
|
+
});
|
|
193
|
+
test('should throw for non-arrays', () => {
|
|
194
|
+
expect(() => AssertRotationMatrix(null)).toThrow(QuaternionError);
|
|
195
|
+
expect(() => AssertRotationMatrix(undefined)).toThrow(QuaternionError);
|
|
196
|
+
expect(() => AssertRotationMatrix(123)).toThrow(QuaternionError);
|
|
197
|
+
expect(() => AssertRotationMatrix('string')).toThrow(QuaternionError);
|
|
198
|
+
expect(() => AssertRotationMatrix({})).toThrow(QuaternionError);
|
|
199
|
+
});
|
|
200
|
+
test('should throw for arrays with wrong row count', () => {
|
|
201
|
+
expect(() => AssertRotationMatrix([])).toThrow(QuaternionError);
|
|
202
|
+
expect(() => AssertRotationMatrix([[1, 0, 0]])).toThrow(QuaternionError);
|
|
203
|
+
expect(() => AssertRotationMatrix([[1, 0, 0], [0, 1, 0]])).toThrow(QuaternionError);
|
|
204
|
+
expect(() => AssertRotationMatrix([
|
|
205
|
+
[1, 0, 0],
|
|
206
|
+
[0, 1, 0],
|
|
207
|
+
[0, 0, 1],
|
|
208
|
+
[0, 0, 0],
|
|
209
|
+
])).toThrow(QuaternionError);
|
|
210
|
+
});
|
|
211
|
+
test('should throw for non-array rows', () => {
|
|
212
|
+
expect(() => AssertRotationMatrix([
|
|
213
|
+
[1, 0, 0],
|
|
214
|
+
'not an array',
|
|
215
|
+
[0, 0, 1],
|
|
216
|
+
])).toThrow(QuaternionError);
|
|
217
|
+
expect(() => AssertRotationMatrix([
|
|
218
|
+
[1, 0, 0],
|
|
219
|
+
null,
|
|
220
|
+
[0, 0, 1],
|
|
221
|
+
])).toThrow(QuaternionError);
|
|
222
|
+
});
|
|
223
|
+
test('should throw for rows with wrong column count', () => {
|
|
224
|
+
expect(() => AssertRotationMatrix([
|
|
225
|
+
[1, 0],
|
|
226
|
+
[0, 1, 0],
|
|
227
|
+
[0, 0, 1],
|
|
228
|
+
])).toThrow(QuaternionError);
|
|
229
|
+
expect(() => AssertRotationMatrix([
|
|
230
|
+
[1, 0, 0, 0],
|
|
231
|
+
[0, 1, 0],
|
|
232
|
+
[0, 0, 1],
|
|
233
|
+
])).toThrow(QuaternionError);
|
|
234
|
+
});
|
|
235
|
+
test('should throw for rows with non-number elements', () => {
|
|
236
|
+
expect(() => AssertRotationMatrix([
|
|
237
|
+
[1, 0, 0],
|
|
238
|
+
[0, 'string', 0],
|
|
239
|
+
[0, 0, 1],
|
|
240
|
+
])).toThrow(QuaternionError);
|
|
241
|
+
expect(() => AssertRotationMatrix([
|
|
242
|
+
[1, 0, 0],
|
|
243
|
+
[0, 1, 0],
|
|
244
|
+
[NaN, 0, 1],
|
|
245
|
+
])).toThrow(QuaternionError);
|
|
246
|
+
});
|
|
247
|
+
test('should throw with specific error messages', () => {
|
|
248
|
+
expect(() => AssertRotationMatrix('not an array')).toThrow('Rotation matrix must be an array');
|
|
249
|
+
expect(() => AssertRotationMatrix([[1, 0, 0]])).toThrow('Rotation matrix must have exactly 3 rows, got 1');
|
|
250
|
+
expect(() => AssertRotationMatrix([
|
|
251
|
+
[1, 0],
|
|
252
|
+
[0, 1, 0],
|
|
253
|
+
[0, 0, 1],
|
|
254
|
+
])).toThrow('Rotation matrix row 0 must have exactly 3 elements, got 2');
|
|
255
|
+
});
|
|
256
|
+
test('should wrap VectorError in QuaternionError', () => {
|
|
257
|
+
expect(() => AssertRotationMatrix([
|
|
258
|
+
[1, 0, 0],
|
|
259
|
+
[0, 1, 0],
|
|
260
|
+
[0, 0, NaN],
|
|
261
|
+
])).toThrow(QuaternionError);
|
|
262
|
+
expect(() => AssertRotationMatrix([
|
|
263
|
+
[1, 0, 0],
|
|
264
|
+
[0, 1, 0],
|
|
265
|
+
[0, 0, NaN],
|
|
266
|
+
])).toThrow(/Invalid rotation matrix row 2:/);
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
describe('AssertQuaternions', () => {
|
|
270
|
+
test('should pass for valid quaternion arrays', () => {
|
|
271
|
+
expect(() => AssertQuaternions([])).not.toThrow();
|
|
272
|
+
expect(() => AssertQuaternions([[0, 0, 0, 1]])).not.toThrow();
|
|
273
|
+
expect(() => AssertQuaternions([
|
|
274
|
+
[0, 0, 0, 1],
|
|
275
|
+
[1, 0, 0, 0],
|
|
276
|
+
[0.5, 0.5, 0.5, 0.5],
|
|
277
|
+
])).not.toThrow();
|
|
278
|
+
});
|
|
279
|
+
test('should throw for non-arrays', () => {
|
|
280
|
+
expect(() => AssertQuaternions(null)).toThrow(QuaternionError);
|
|
281
|
+
expect(() => AssertQuaternions(undefined)).toThrow(QuaternionError);
|
|
282
|
+
expect(() => AssertQuaternions(123)).toThrow(QuaternionError);
|
|
283
|
+
expect(() => AssertQuaternions('string')).toThrow(QuaternionError);
|
|
284
|
+
expect(() => AssertQuaternions({})).toThrow(QuaternionError);
|
|
285
|
+
});
|
|
286
|
+
test('should throw for arrays containing invalid quaternions', () => {
|
|
287
|
+
expect(() => AssertQuaternions([
|
|
288
|
+
[0, 0, 0, 1],
|
|
289
|
+
[1, 2, 3], // Invalid - wrong length
|
|
290
|
+
[0, 1, 0, 0],
|
|
291
|
+
])).toThrow(QuaternionError);
|
|
292
|
+
expect(() => AssertQuaternions([
|
|
293
|
+
[0, 0, 0, 1],
|
|
294
|
+
[1, 2, 3, 'string'], // Invalid - non-number
|
|
295
|
+
])).toThrow(QuaternionError);
|
|
296
|
+
expect(() => AssertQuaternions([
|
|
297
|
+
[0, 0, 0, 1],
|
|
298
|
+
'not a quaternion', // Invalid - not an array
|
|
299
|
+
])).toThrow(QuaternionError);
|
|
300
|
+
});
|
|
301
|
+
test('should provide index information in error messages', () => {
|
|
302
|
+
expect(() => AssertQuaternions([
|
|
303
|
+
[0, 0, 0, 1],
|
|
304
|
+
[1, 2, 3], // Invalid at index 1
|
|
305
|
+
])).toThrow(/Invalid quaternion at index 1:/);
|
|
306
|
+
expect(() => AssertQuaternions([
|
|
307
|
+
[0, 0, 0, 1],
|
|
308
|
+
[1, 0, 0, 0],
|
|
309
|
+
[1, 2, 3, NaN], // Invalid at index 2
|
|
310
|
+
])).toThrow(/Invalid quaternion at index 2:/);
|
|
311
|
+
});
|
|
312
|
+
test('should pass options to individual quaternion validation', () => {
|
|
313
|
+
const options = { someOption: true };
|
|
314
|
+
// This test verifies that options are passed through,
|
|
315
|
+
// though the current implementation doesn't use them
|
|
316
|
+
expect(() => AssertQuaternions([[0, 0, 0, 1]], options)).not.toThrow();
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
//# sourceMappingURL=asserts.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asserts.spec.js","sourceRoot":"","sources":["../../src/quaternions/asserts.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,eAAe,EACf,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,GACjB,MAAM,cAAc,CAAC;AAEtB,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACvC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAChC,IAAI,CAAC,8CAA8C,EAAE,GAAG,EAAE;YACzD,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,cAAc,CAAC,CAAC;YAClD,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACpC,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;YAC9C,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC3C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,iDAAiD,EAAE,GAAG,EAAE;YAC5D,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;YACpC,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACpC,MAAM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,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAAC;YAE9C,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC;gBAC9B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,qBAAqB;aACrC,CAAC,CAAC,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,yDAAyD,EAAE,GAAG,EAAE;YACpE,MAAM,OAAO,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;YACrC,sDAAsD;YACtD,qDAAqD;YACrD,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACxE,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion utilities for quaternions and various rotation representations.
|
|
3
|
+
* Provides comprehensive conversion between different rotation formats.
|
|
4
|
+
*/
|
|
5
|
+
import { IMatrix4 } from '../matrices/types.js';
|
|
6
|
+
import { TQuaternion, TRotationMatrix } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Converts a quaternion to a 3x3 rotation matrix.
|
|
9
|
+
* The matrix is returned as a proper IMatrix3 type.
|
|
10
|
+
*
|
|
11
|
+
* @param quaternion - The normalized quaternion to convert
|
|
12
|
+
* @returns 3x3 rotation matrix as IMatrix3
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z-axis
|
|
16
|
+
* const matrix = QuaternionToRotationMatrix(q);
|
|
17
|
+
* // matrix represents rotation that transforms +X to +Y
|
|
18
|
+
*/
|
|
19
|
+
export declare function QuaternionToRotationMatrix(quaternion: TQuaternion): TRotationMatrix;
|
|
20
|
+
/**
|
|
21
|
+
* Converts a 3x3 rotation matrix to a quaternion.
|
|
22
|
+
* The matrix should be a proper IMatrix3 type.
|
|
23
|
+
*
|
|
24
|
+
* @param matrix - 3x3 rotation matrix as IMatrix3
|
|
25
|
+
* @returns Normalized quaternion representing the same rotation
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const identityMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
29
|
+
* const q = QuaternionFromRotationMatrix(identityMatrix);
|
|
30
|
+
* console.log(q); // [0, 0, 0, 1] (identity quaternion)
|
|
31
|
+
*/
|
|
32
|
+
export declare function QuaternionFromRotationMatrix(matrix: TRotationMatrix): TQuaternion;
|
|
33
|
+
/**
|
|
34
|
+
* Converts a quaternion to a 4x4 transformation matrix.
|
|
35
|
+
* The resulting matrix can be used for 3D transformations in homogeneous coordinates.
|
|
36
|
+
* Translation component is zero (pure rotation matrix).
|
|
37
|
+
*
|
|
38
|
+
* @param quaternion - The normalized quaternion to convert
|
|
39
|
+
* @returns 4x4 transformation matrix as a flat array of 16 elements (row-major)
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const q = [0, 0, 0, 1]; // Identity quaternion
|
|
43
|
+
* const matrix4x4 = QuaternionToTransformationMatrix(q);
|
|
44
|
+
* // Returns identity 4x4 matrix
|
|
45
|
+
*/
|
|
46
|
+
export declare function QuaternionToTransformationMatrix(quaternion: TQuaternion): IMatrix4;
|
|
47
|
+
/**
|
|
48
|
+
* Extracts the rotation quaternion from a 4x4 transformation matrix.
|
|
49
|
+
* Ignores translation and scaling components, extracting only the rotation.
|
|
50
|
+
*
|
|
51
|
+
* @param matrix4x4 - 4x4 transformation matrix as a flat array of 16 elements
|
|
52
|
+
* @returns Normalized quaternion representing the rotation component
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* const transformMatrix = [1, 0, 0, 5, 0, 1, 0, 10, 0, 0, 1, 15, 0, 0, 0, 1];
|
|
56
|
+
* const q = QuaternionFromTransformationMatrix(transformMatrix);
|
|
57
|
+
* // Extracts rotation (identity in this case), ignores translation [5, 10, 15]
|
|
58
|
+
*/
|
|
59
|
+
export declare function QuaternionFromTransformationMatrix(matrix: IMatrix4): TQuaternion;
|
|
60
|
+
/**
|
|
61
|
+
* Checks if a matrix is a valid rotation matrix.
|
|
62
|
+
* A valid rotation matrix should be orthogonal and have determinant +1.
|
|
63
|
+
*
|
|
64
|
+
* @param matrix - The matrix to validate
|
|
65
|
+
* @param tolerance - Tolerance for floating-point comparisons (default: 1e-6)
|
|
66
|
+
* @returns True if the matrix is a valid rotation matrix
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // Identity matrix
|
|
70
|
+
* console.log(IsValidRotationMatrix(matrix)); // true
|
|
71
|
+
*/
|
|
72
|
+
export declare function IsValidRotationMatrix(matrix: TRotationMatrix, tolerance?: number): boolean;
|
|
73
|
+
//# sourceMappingURL=conversions.d.ts.map
|
|
@@ -0,0 +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;AAEhD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAI1D;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,WAAW,GAAG,eAAe,CAmBnF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CAyCjF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,WAAW,GAAG,QAAQ,CAUlF;AACD;;;;;;;;;;;GAWG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,QAAQ,GAAG,WAAW,CAShF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,GAAE,MAAa,GAAG,OAAO,CAkChG"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion utilities for quaternions and various rotation representations.
|
|
3
|
+
* Provides comprehensive conversion between different rotation formats.
|
|
4
|
+
*/
|
|
5
|
+
import { AssertNormalizedQuaternion, AssertRotationMatrix } from './asserts.js';
|
|
6
|
+
const SHEPPERD_QUARTER = 0.25;
|
|
7
|
+
/**
|
|
8
|
+
* Converts a quaternion to a 3x3 rotation matrix.
|
|
9
|
+
* The matrix is returned as a proper IMatrix3 type.
|
|
10
|
+
*
|
|
11
|
+
* @param quaternion - The normalized quaternion to convert
|
|
12
|
+
* @returns 3x3 rotation matrix as IMatrix3
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z-axis
|
|
16
|
+
* const matrix = QuaternionToRotationMatrix(q);
|
|
17
|
+
* // matrix represents rotation that transforms +X to +Y
|
|
18
|
+
*/
|
|
19
|
+
export function QuaternionToRotationMatrix(quaternion) {
|
|
20
|
+
AssertNormalizedQuaternion(quaternion);
|
|
21
|
+
const [x, y, z, w] = quaternion;
|
|
22
|
+
const xx = x * x;
|
|
23
|
+
const yy = y * y;
|
|
24
|
+
const zz = z * z;
|
|
25
|
+
const xy = x * y;
|
|
26
|
+
const xz = x * z;
|
|
27
|
+
const yz = y * z;
|
|
28
|
+
const wx = w * x;
|
|
29
|
+
const wy = w * y;
|
|
30
|
+
const wz = w * z;
|
|
31
|
+
return [
|
|
32
|
+
[1 - (2 * (yy + zz)), 2 * (xy - wz), 2 * (xz + wy)],
|
|
33
|
+
[2 * (xy + wz), 1 - (2 * (xx + zz)), 2 * (yz - wx)],
|
|
34
|
+
[2 * (xz - wy), 2 * (yz + wx), 1 - (2 * (xx + yy))],
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Converts a 3x3 rotation matrix to a quaternion.
|
|
39
|
+
* The matrix should be a proper IMatrix3 type.
|
|
40
|
+
*
|
|
41
|
+
* @param matrix - 3x3 rotation matrix as IMatrix3
|
|
42
|
+
* @returns Normalized quaternion representing the same rotation
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const identityMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
46
|
+
* const q = QuaternionFromRotationMatrix(identityMatrix);
|
|
47
|
+
* console.log(q); // [0, 0, 0, 1] (identity quaternion)
|
|
48
|
+
*/
|
|
49
|
+
export function QuaternionFromRotationMatrix(matrix) {
|
|
50
|
+
AssertRotationMatrix(matrix);
|
|
51
|
+
const [[m00, m01, m02], [m10, m11, m12], [m20, m21, m22]] = matrix;
|
|
52
|
+
// Trace of the matrix
|
|
53
|
+
const trace = m00 + m11 + m22;
|
|
54
|
+
if (trace > 0) {
|
|
55
|
+
// Standard case
|
|
56
|
+
const s = Math.sqrt(trace + 1) * 2; // s = 4 * qw
|
|
57
|
+
const w = SHEPPERD_QUARTER * s;
|
|
58
|
+
const x = (m21 - m12) / s;
|
|
59
|
+
const y = (m02 - m20) / s;
|
|
60
|
+
const z = (m10 - m01) / s;
|
|
61
|
+
return [x, y, z, w];
|
|
62
|
+
}
|
|
63
|
+
else if ((m00 > m11) && (m00 > m22)) {
|
|
64
|
+
// m00 is largest
|
|
65
|
+
const s = Math.sqrt(1 + m00 - m11 - m22) * 2; // s = 4 * qx
|
|
66
|
+
const w = (m21 - m12) / s;
|
|
67
|
+
const x = SHEPPERD_QUARTER * s;
|
|
68
|
+
const y = (m01 + m10) / s;
|
|
69
|
+
const z = (m02 + m20) / s;
|
|
70
|
+
return [x, y, z, w];
|
|
71
|
+
}
|
|
72
|
+
else if (m11 > m22) {
|
|
73
|
+
// m11 is largest
|
|
74
|
+
const s = Math.sqrt(1 + m11 - m00 - m22) * 2; // s = 4 * qy
|
|
75
|
+
const w = (m02 - m20) / s;
|
|
76
|
+
const x = (m01 + m10) / s;
|
|
77
|
+
const y = SHEPPERD_QUARTER * s;
|
|
78
|
+
const z = (m12 + m21) / s;
|
|
79
|
+
return [x, y, z, w];
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// m22 is largest
|
|
83
|
+
const s = Math.sqrt(1 + m22 - m00 - m11) * 2; // s = 4 * qz
|
|
84
|
+
const w = (m10 - m01) / s;
|
|
85
|
+
const x = (m02 + m20) / s;
|
|
86
|
+
const y = (m12 + m21) / s;
|
|
87
|
+
const z = SHEPPERD_QUARTER * s;
|
|
88
|
+
return [x, y, z, w];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Converts a quaternion to a 4x4 transformation matrix.
|
|
93
|
+
* The resulting matrix can be used for 3D transformations in homogeneous coordinates.
|
|
94
|
+
* Translation component is zero (pure rotation matrix).
|
|
95
|
+
*
|
|
96
|
+
* @param quaternion - The normalized quaternion to convert
|
|
97
|
+
* @returns 4x4 transformation matrix as a flat array of 16 elements (row-major)
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* const q = [0, 0, 0, 1]; // Identity quaternion
|
|
101
|
+
* const matrix4x4 = QuaternionToTransformationMatrix(q);
|
|
102
|
+
* // Returns identity 4x4 matrix
|
|
103
|
+
*/
|
|
104
|
+
export function QuaternionToTransformationMatrix(quaternion) {
|
|
105
|
+
const rotationMatrix = QuaternionToRotationMatrix(quaternion);
|
|
106
|
+
// Fill 4x4 matrix in row-major order
|
|
107
|
+
return [
|
|
108
|
+
[rotationMatrix[0][0], rotationMatrix[0][1], rotationMatrix[0][2], 0],
|
|
109
|
+
[rotationMatrix[1][0], rotationMatrix[1][1], rotationMatrix[1][2], 0],
|
|
110
|
+
[rotationMatrix[2][0], rotationMatrix[2][1], rotationMatrix[2][2], 0],
|
|
111
|
+
[0, 0, 0, 1],
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Extracts the rotation quaternion from a 4x4 transformation matrix.
|
|
116
|
+
* Ignores translation and scaling components, extracting only the rotation.
|
|
117
|
+
*
|
|
118
|
+
* @param matrix4x4 - 4x4 transformation matrix as a flat array of 16 elements
|
|
119
|
+
* @returns Normalized quaternion representing the rotation component
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* const transformMatrix = [1, 0, 0, 5, 0, 1, 0, 10, 0, 0, 1, 15, 0, 0, 0, 1];
|
|
123
|
+
* const q = QuaternionFromTransformationMatrix(transformMatrix);
|
|
124
|
+
* // Extracts rotation (identity in this case), ignores translation [5, 10, 15]
|
|
125
|
+
*/
|
|
126
|
+
export function QuaternionFromTransformationMatrix(matrix) {
|
|
127
|
+
// Extract 3x3 rotation matrix from 4x4 transformation matrix
|
|
128
|
+
const rotationMatrix = [
|
|
129
|
+
[matrix[0][0], matrix[0][1], matrix[0][2]],
|
|
130
|
+
[matrix[1][0], matrix[1][1], matrix[1][2]],
|
|
131
|
+
[matrix[2][0], matrix[2][1], matrix[2][2]],
|
|
132
|
+
];
|
|
133
|
+
return QuaternionFromRotationMatrix(rotationMatrix);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Checks if a matrix is a valid rotation matrix.
|
|
137
|
+
* A valid rotation matrix should be orthogonal and have determinant +1.
|
|
138
|
+
*
|
|
139
|
+
* @param matrix - The matrix to validate
|
|
140
|
+
* @param tolerance - Tolerance for floating-point comparisons (default: 1e-6)
|
|
141
|
+
* @returns True if the matrix is a valid rotation matrix
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* const matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // Identity matrix
|
|
145
|
+
* console.log(IsValidRotationMatrix(matrix)); // true
|
|
146
|
+
*/
|
|
147
|
+
export function IsValidRotationMatrix(matrix, tolerance = 1e-6) {
|
|
148
|
+
AssertRotationMatrix(matrix);
|
|
149
|
+
const [[m00, m01, m02], [m10, m11, m12], [m20, m21, m22]] = matrix;
|
|
150
|
+
// Check if matrix is orthogonal (columns are unit vectors and orthogonal)
|
|
151
|
+
// Column 1: [m00, m10, m20]
|
|
152
|
+
const col1LengthSq = (m00 * m00) + (m10 * m10) + (m20 * m20);
|
|
153
|
+
if (Math.abs(col1LengthSq - 1) > tolerance)
|
|
154
|
+
return false;
|
|
155
|
+
// Column 2: [m01, m11, m21]
|
|
156
|
+
const col2LengthSq = (m01 * m01) + (m11 * m11) + (m21 * m21);
|
|
157
|
+
if (Math.abs(col2LengthSq - 1) > tolerance)
|
|
158
|
+
return false;
|
|
159
|
+
// Column 3: [m02, m12, m22]
|
|
160
|
+
const col3LengthSq = (m02 * m02) + (m12 * m12) + (m22 * m22);
|
|
161
|
+
if (Math.abs(col3LengthSq - 1) > tolerance)
|
|
162
|
+
return false;
|
|
163
|
+
// Check orthogonality between columns
|
|
164
|
+
const dot12 = (m00 * m01) + (m10 * m11) + (m20 * m21);
|
|
165
|
+
if (Math.abs(dot12) > tolerance)
|
|
166
|
+
return false;
|
|
167
|
+
const dot13 = (m00 * m02) + (m10 * m12) + (m20 * m22);
|
|
168
|
+
if (Math.abs(dot13) > tolerance)
|
|
169
|
+
return false;
|
|
170
|
+
const dot23 = (m01 * m02) + (m11 * m12) + (m21 * m22);
|
|
171
|
+
if (Math.abs(dot23) > tolerance)
|
|
172
|
+
return false;
|
|
173
|
+
// Check determinant is +1 (not -1, which would be a reflection)
|
|
174
|
+
const det = (m00 * ((m11 * m22) - (m12 * m21))) - (m01 * ((m10 * m22) - (m12 * m20))) + (m02 * ((m10 * m21) - (m11 * m20)));
|
|
175
|
+
if (Math.abs(det - 1) > tolerance)
|
|
176
|
+
return false;
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=conversions.js.map
|
|
@@ -0,0 +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;;;;;;;;;;;GAWG;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;IACjB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAEjB,OAAO;QACN,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QACnD,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,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