@pawells/math-extended 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +15 -21
  2. package/build/clamp.d.ts +5 -5
  3. package/build/clamp.js +5 -5
  4. package/build/core.d.ts +23 -0
  5. package/build/core.d.ts.map +1 -0
  6. package/build/core.js +25 -0
  7. package/build/core.js.map +1 -0
  8. package/build/index.d.ts +1 -4
  9. package/build/index.d.ts.map +1 -1
  10. package/build/index.js +1 -6
  11. package/build/index.js.map +1 -1
  12. package/build/interpolation.d.ts +158 -171
  13. package/build/interpolation.d.ts.map +1 -1
  14. package/build/interpolation.js +162 -181
  15. package/build/interpolation.js.map +1 -1
  16. package/build/matrices/arithmetic.d.ts +132 -132
  17. package/build/matrices/arithmetic.d.ts.map +1 -1
  18. package/build/matrices/arithmetic.js +194 -226
  19. package/build/matrices/arithmetic.js.map +1 -1
  20. package/build/matrices/asserts.d.ts +30 -408
  21. package/build/matrices/asserts.d.ts.map +1 -1
  22. package/build/matrices/asserts.js +98 -542
  23. package/build/matrices/asserts.js.map +1 -1
  24. package/build/matrices/core.d.ts +117 -46
  25. package/build/matrices/core.d.ts.map +1 -1
  26. package/build/matrices/core.js +127 -103
  27. package/build/matrices/core.js.map +1 -1
  28. package/build/matrices/decompositions.d.ts +95 -96
  29. package/build/matrices/decompositions.d.ts.map +1 -1
  30. package/build/matrices/decompositions.js +119 -160
  31. package/build/matrices/decompositions.js.map +1 -1
  32. package/build/matrices/index.d.ts +0 -1
  33. package/build/matrices/index.d.ts.map +1 -1
  34. package/build/matrices/index.js +0 -3
  35. package/build/matrices/index.js.map +1 -1
  36. package/build/matrices/linear-algebra.d.ts +45 -8
  37. package/build/matrices/linear-algebra.d.ts.map +1 -1
  38. package/build/matrices/linear-algebra.js +76 -32
  39. package/build/matrices/linear-algebra.js.map +1 -1
  40. package/build/matrices/normalization.d.ts +29 -8
  41. package/build/matrices/normalization.d.ts.map +1 -1
  42. package/build/matrices/normalization.js +32 -23
  43. package/build/matrices/normalization.js.map +1 -1
  44. package/build/matrices/transformations.d.ts +116 -148
  45. package/build/matrices/transformations.d.ts.map +1 -1
  46. package/build/matrices/transformations.js +69 -91
  47. package/build/matrices/transformations.js.map +1 -1
  48. package/build/matrices/types.d.ts +32 -60
  49. package/build/matrices/types.d.ts.map +1 -1
  50. package/build/matrices/types.js +63 -1
  51. package/build/matrices/types.js.map +1 -1
  52. package/build/quaternions/asserts.d.ts +29 -38
  53. package/build/quaternions/asserts.d.ts.map +1 -1
  54. package/build/quaternions/asserts.js +61 -77
  55. package/build/quaternions/asserts.js.map +1 -1
  56. package/build/quaternions/conversions.d.ts +26 -26
  57. package/build/quaternions/conversions.d.ts.map +1 -1
  58. package/build/quaternions/conversions.js +24 -24
  59. package/build/quaternions/core.d.ts +70 -69
  60. package/build/quaternions/core.d.ts.map +1 -1
  61. package/build/quaternions/core.js +71 -71
  62. package/build/quaternions/core.js.map +1 -1
  63. package/build/quaternions/index.d.ts +0 -1
  64. package/build/quaternions/index.d.ts.map +1 -1
  65. package/build/quaternions/index.js +0 -2
  66. package/build/quaternions/index.js.map +1 -1
  67. package/build/quaternions/interpolation.d.ts +16 -16
  68. package/build/quaternions/interpolation.d.ts.map +1 -1
  69. package/build/quaternions/interpolation.js +21 -21
  70. package/build/quaternions/interpolation.js.map +1 -1
  71. package/build/quaternions/predefined.d.ts +10 -10
  72. package/build/quaternions/predefined.d.ts.map +1 -1
  73. package/build/quaternions/predefined.js +9 -9
  74. package/build/quaternions/types.d.ts +23 -12
  75. package/build/quaternions/types.d.ts.map +1 -1
  76. package/build/quaternions/types.js +51 -1
  77. package/build/quaternions/types.js.map +1 -1
  78. package/build/random.d.ts +66 -20
  79. package/build/random.d.ts.map +1 -1
  80. package/build/random.js +73 -20
  81. package/build/random.js.map +1 -1
  82. package/build/vectors/asserts.d.ts +50 -220
  83. package/build/vectors/asserts.d.ts.map +1 -1
  84. package/build/vectors/asserts.js +141 -327
  85. package/build/vectors/asserts.js.map +1 -1
  86. package/build/vectors/core.d.ts +182 -229
  87. package/build/vectors/core.d.ts.map +1 -1
  88. package/build/vectors/core.js +234 -288
  89. package/build/vectors/core.js.map +1 -1
  90. package/build/vectors/index.d.ts +0 -1
  91. package/build/vectors/index.d.ts.map +1 -1
  92. package/build/vectors/index.js +0 -2
  93. package/build/vectors/index.js.map +1 -1
  94. package/build/vectors/interpolation.d.ts +40 -40
  95. package/build/vectors/interpolation.d.ts.map +1 -1
  96. package/build/vectors/interpolation.js +75 -86
  97. package/build/vectors/interpolation.js.map +1 -1
  98. package/build/vectors/predefined.d.ts +31 -7
  99. package/build/vectors/predefined.d.ts.map +1 -1
  100. package/build/vectors/predefined.js +30 -6
  101. package/build/vectors/predefined.js.map +1 -1
  102. package/build/vectors/types.d.ts +26 -4
  103. package/build/vectors/types.d.ts.map +1 -1
  104. package/build/vectors/types.js +50 -1
  105. package/build/vectors/types.js.map +1 -1
  106. package/package.json +3 -2
  107. package/build/matrices/_exports.d.ts +0 -13
  108. package/build/matrices/_exports.d.ts.map +0 -1
  109. package/build/matrices/_exports.js +0 -13
  110. package/build/matrices/_exports.js.map +0 -1
  111. package/build/quaternions/_exports.d.ts +0 -11
  112. package/build/quaternions/_exports.d.ts.map +0 -1
  113. package/build/quaternions/_exports.js +0 -11
  114. package/build/quaternions/_exports.js.map +0 -1
  115. package/build/vectors/_exports.d.ts +0 -10
  116. package/build/vectors/_exports.d.ts.map +0 -1
  117. package/build/vectors/_exports.js +0 -10
  118. package/build/vectors/_exports.js.map +0 -1
@@ -2,25 +2,7 @@
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 { VectorError } from '../vectors/asserts.js';
6
- import { TQuaternion, TEulerAngles, TAxisAngle, TRotationMatrix } from './types.js';
7
- /**
8
- * Custom error class for quaternion-specific validation errors.
9
- * Extends the base VectorError to maintain consistency with vector operations.
10
- */
11
- export declare class QuaternionError extends VectorError {
12
- readonly code: string;
13
- /**
14
- * Creates a new QuaternionError instance.
15
- *
16
- * @param message - Error message describing the validation failure
17
- * @param options - Optional error context
18
- * @param options.cause - Original error that caused this error
19
- */
20
- constructor(message: string, options?: {
21
- cause?: unknown;
22
- });
23
- }
5
+ import { type TQuaternion, type TEulerAngles, type TAxisAngle, type TRotationMatrix } from './types.js';
24
6
  /**
25
7
  * Validates that a value is a proper quaternion.
26
8
  * A valid quaternion must be an array of exactly 4 finite numbers.
@@ -30,13 +12,22 @@ export declare class QuaternionError extends VectorError {
30
12
  * @throws {QuaternionError} If the quaternion is invalid
31
13
  *
32
14
  * @example
33
- * ```typescript
34
- * AssertQuaternion([0, 0, 0, 1]); // Valid - passes silently
35
- * AssertQuaternion([1, 2, 3]); // Throws QuaternionError - wrong length
36
- * AssertQuaternion([1, 2, 3, NaN]); // Throws QuaternionError - contains NaN
37
- * ```
15
+ * ```typescript
16
+ * AssertQuaternion([0, 0, 0, 1]); // Valid - passes silently
17
+ * AssertQuaternion([1, 2, 3]); // Throws QuaternionError - wrong length
18
+ * AssertQuaternion([1, 2, 3, NaN]); // Throws QuaternionError - contains NaN
19
+ * ```
38
20
  */
39
- export declare function AssertQuaternion(quaternion: unknown, options?: Record<string, unknown>): asserts quaternion is TQuaternion;
21
+ /**
22
+ * Error thrown when quaternion validation fails.
23
+ */
24
+ export declare class QuaternionError extends Error {
25
+ readonly code: string;
26
+ constructor(message: string, options?: {
27
+ cause?: unknown;
28
+ });
29
+ }
30
+ export declare function AssertQuaternion(quaternion: unknown): asserts quaternion is TQuaternion;
40
31
  /**
41
32
  * Validates that a quaternion is normalized (unit quaternion).
42
33
  * A unit quaternion has a magnitude of 1 and represents a valid rotation.
@@ -46,10 +37,10 @@ export declare function AssertQuaternion(quaternion: unknown, options?: Record<s
46
37
  * @throws {QuaternionError} If the quaternion is not normalized
47
38
  *
48
39
  * @example
49
- * ```typescript
50
- * AssertNormalizedQuaternion([0, 0, 0, 1]); // Valid unit quaternion
51
- * AssertNormalizedQuaternion([1, 1, 1, 1]); // Throws - not normalized
52
- * ```
40
+ * ```typescript
41
+ * AssertNormalizedQuaternion([0, 0, 0, 1]); // Valid unit quaternion
42
+ * AssertNormalizedQuaternion([1, 1, 1, 1]); // Throws - not normalized
43
+ * ```
53
44
  */
54
45
  export declare function AssertNormalizedQuaternion(quaternion: TQuaternion, tolerance?: number): void;
55
46
  /**
@@ -60,7 +51,7 @@ export declare function AssertNormalizedQuaternion(quaternion: TQuaternion, tole
60
51
  * @param options - Validation options
61
52
  * @throws {QuaternionError} If the Euler angles are invalid
62
53
  */
63
- export declare function AssertEulerAngles(euler: unknown, options?: Record<string, unknown>): asserts euler is TEulerAngles;
54
+ export declare function AssertEulerAngles(euler: unknown): asserts euler is TEulerAngles;
64
55
  /**
65
56
  * Validates that a value is proper axis-angle representation.
66
57
  * Axis-angle must be an array of exactly 4 finite numbers.
@@ -69,7 +60,7 @@ export declare function AssertEulerAngles(euler: unknown, options?: Record<strin
69
60
  * @param options - Validation options
70
61
  * @throws {QuaternionError} If the axis-angle is invalid
71
62
  */
72
- export declare function AssertAxisAngle(axisAngle: unknown, options?: Record<string, unknown>): asserts axisAngle is TAxisAngle;
63
+ export declare function AssertAxisAngle(axisAngle: unknown): asserts axisAngle is TAxisAngle;
73
64
  /**
74
65
  * Validates that a value is a proper rotation matrix.
75
66
  * Rotation matrix must be a 3x3 matrix (TMatrix3).
@@ -78,7 +69,7 @@ export declare function AssertAxisAngle(axisAngle: unknown, options?: Record<str
78
69
  * @param options - Validation options
79
70
  * @throws {QuaternionError} If the rotation matrix is invalid
80
71
  */
81
- export declare function AssertRotationMatrix(matrix: unknown, options?: Record<string, unknown>): asserts matrix is TRotationMatrix;
72
+ export declare function AssertRotationMatrix(matrix: unknown): asserts matrix is TRotationMatrix;
82
73
  /**
83
74
  * Validates that multiple quaternions are all valid.
84
75
  * Convenience function for batch validation.
@@ -87,7 +78,7 @@ export declare function AssertRotationMatrix(matrix: unknown, options?: Record<s
87
78
  * @param options - Validation options
88
79
  * @throws {QuaternionError} If any quaternion is invalid
89
80
  */
90
- export declare function AssertQuaternions(quaternions: unknown[], options?: Record<string, unknown>): asserts quaternions is TQuaternion[];
81
+ export declare function AssertQuaternions(quaternions: unknown[]): asserts quaternions is TQuaternion[];
91
82
  /**
92
83
  * Validates that an unknown value is a valid quaternion without throwing an error.
93
84
  *
@@ -106,7 +97,7 @@ export declare function AssertQuaternions(quaternions: unknown[], options?: Reco
106
97
  * }
107
98
  * ```
108
99
  */
109
- export declare function ValidateQuaternion(quaternion: unknown, options?: Record<string, unknown>): quaternion is TQuaternion;
100
+ export declare function ValidateQuaternion(quaternion: unknown): quaternion is TQuaternion;
110
101
  /**
111
102
  * Validates that a quaternion is normalized (magnitude = 1) without throwing an error.
112
103
  *
@@ -136,7 +127,7 @@ export declare function ValidateNormalizedQuaternion(quaternion: TQuaternion, to
136
127
  * }
137
128
  * ```
138
129
  */
139
- export declare function ValidateEulerAngles(euler: unknown, options?: Record<string, unknown>): euler is TEulerAngles;
130
+ export declare function ValidateEulerAngles(euler: unknown): euler is TEulerAngles;
140
131
  /**
141
132
  * Validates that an unknown value is a valid axis-angle representation without throwing an error.
142
133
  *
@@ -151,7 +142,7 @@ export declare function ValidateEulerAngles(euler: unknown, options?: Record<str
151
142
  * }
152
143
  * ```
153
144
  */
154
- export declare function ValidateAxisAngle(axisAngle: unknown, options?: Record<string, unknown>): axisAngle is TAxisAngle;
145
+ export declare function ValidateAxisAngle(axisAngle: unknown): axisAngle is TAxisAngle;
155
146
  /**
156
147
  * Validates that an unknown value is a valid rotation matrix without throwing an error.
157
148
  *
@@ -166,7 +157,7 @@ export declare function ValidateAxisAngle(axisAngle: unknown, options?: Record<s
166
157
  * }
167
158
  * ```
168
159
  */
169
- export declare function ValidateRotationMatrix(matrix: unknown, options?: Record<string, unknown>): matrix is TRotationMatrix;
160
+ export declare function ValidateRotationMatrix(matrix: unknown): matrix is TRotationMatrix;
170
161
  /**
171
162
  * Validates that an unknown value is an array of valid quaternions without throwing an error.
172
163
  *
@@ -181,5 +172,5 @@ export declare function ValidateRotationMatrix(matrix: unknown, options?: Record
181
172
  * }
182
173
  * ```
183
174
  */
184
- export declare function ValidateQuaternions(quaternions: unknown[], options?: Record<string, unknown>): quaternions is TQuaternion[];
175
+ export declare function ValidateQuaternions(quaternions: unknown[]): quaternions is TQuaternion[];
185
176
  //# sourceMappingURL=asserts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asserts.d.ts","sourceRoot":"","sources":["../../src/quaternions/asserts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAgB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpF;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAC/C,SAAgB,IAAI,EAAE,MAAM,CAAsB;IAElD;;;;;;OAMG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI1D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,UAAU,IAAI,WAAW,CAkB9H;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,GAAE,MAAa,GAAG,IAAI,CASlG;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAiBtH;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,S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AAkB,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,IAAI,WAAW,CAOjF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,GAAE,MAAa,GAAG,OAAO,CAOvG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAOzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,UAAU,CAO7E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,eAAe,CAOjF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,WAAW,IAAI,WAAW,EAAE,CAOxF"}
@@ -2,25 +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
- code = 'QUATERNION_ERROR';
12
- /**
13
- * Creates a new QuaternionError instance.
14
- *
15
- * @param message - Error message describing the validation failure
16
- * @param options - Optional error context
17
- * @param options.cause - Original error that caused this error
18
- */
19
- constructor(message, options) {
20
- super(message, options);
21
- this.name = 'QuaternionError';
22
- }
23
- }
24
5
  /**
25
6
  * Validates that a value is a proper quaternion.
26
7
  * A valid quaternion must be an array of exactly 4 finite numbers.
@@ -30,28 +11,36 @@ export class QuaternionError extends VectorError {
30
11
  * @throws {QuaternionError} If the quaternion is invalid
31
12
  *
32
13
  * @example
33
- * ```typescript
34
- * AssertQuaternion([0, 0, 0, 1]); // Valid - passes silently
35
- * AssertQuaternion([1, 2, 3]); // Throws QuaternionError - wrong length
36
- * AssertQuaternion([1, 2, 3, NaN]); // Throws QuaternionError - contains NaN
37
- * ```
14
+ * ```typescript
15
+ * AssertQuaternion([0, 0, 0, 1]); // Valid - passes silently
16
+ * AssertQuaternion([1, 2, 3]); // Throws QuaternionError - wrong length
17
+ * AssertQuaternion([1, 2, 3, NaN]); // Throws QuaternionError - contains NaN
18
+ * ```
19
+ */
20
+ /**
21
+ * Error thrown when quaternion validation fails.
38
22
  */
39
- export function AssertQuaternion(quaternion, options = {}) {
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) {
40
34
  if (!Array.isArray(quaternion)) {
41
35
  throw new QuaternionError('Quaternion must be an array');
42
36
  }
43
37
  if (quaternion.length !== 4) {
44
38
  throw new QuaternionError(`Quaternion must have exactly 4 components, got ${quaternion.length}`);
45
39
  }
46
- // Use existing vector validation for number checking
47
- try {
48
- AssertVector(quaternion, options);
49
- }
50
- catch (error) {
51
- if (error instanceof VectorError) {
52
- 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]})`);
53
43
  }
54
- throw error;
55
44
  }
56
45
  }
57
46
  /**
@@ -63,13 +52,17 @@ export function AssertQuaternion(quaternion, options = {}) {
63
52
  * @throws {QuaternionError} If the quaternion is not normalized
64
53
  *
65
54
  * @example
66
- * ```typescript
67
- * AssertNormalizedQuaternion([0, 0, 0, 1]); // Valid unit quaternion
68
- * AssertNormalizedQuaternion([1, 1, 1, 1]); // Throws - not normalized
69
- * ```
55
+ * ```typescript
56
+ * AssertNormalizedQuaternion([0, 0, 0, 1]); // Valid unit quaternion
57
+ * AssertNormalizedQuaternion([1, 1, 1, 1]); // Throws - not normalized
58
+ * ```
70
59
  */
71
60
  export function AssertNormalizedQuaternion(quaternion, tolerance = 1e-6) {
72
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
+ }
73
66
  const [x, y, z, w] = quaternion;
74
67
  const magnitude = Math.sqrt((x * x) + (y * y) + (z * z) + (w * w));
75
68
  if (Math.abs(magnitude - 1) > tolerance) {
@@ -84,21 +77,18 @@ export function AssertNormalizedQuaternion(quaternion, tolerance = 1e-6) {
84
77
  * @param options - Validation options
85
78
  * @throws {QuaternionError} If the Euler angles are invalid
86
79
  */
87
- export function AssertEulerAngles(euler, options = {}) {
80
+ export function AssertEulerAngles(euler) {
88
81
  if (!Array.isArray(euler)) {
89
82
  throw new QuaternionError('Euler angles must be an array');
90
83
  }
91
84
  if (euler.length !== 3) {
92
85
  throw new QuaternionError(`Euler angles must have exactly 3 components, got ${euler.length}`);
93
86
  }
94
- try {
95
- AssertVector(euler, options);
96
- }
97
- catch (error) {
98
- if (error instanceof VectorError) {
99
- 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]})`);
100
91
  }
101
- throw error;
102
92
  }
103
93
  }
104
94
  /**
@@ -109,21 +99,18 @@ export function AssertEulerAngles(euler, options = {}) {
109
99
  * @param options - Validation options
110
100
  * @throws {QuaternionError} If the axis-angle is invalid
111
101
  */
112
- export function AssertAxisAngle(axisAngle, options = {}) {
102
+ export function AssertAxisAngle(axisAngle) {
113
103
  if (!Array.isArray(axisAngle)) {
114
104
  throw new QuaternionError('Axis-angle must be an array');
115
105
  }
116
106
  if (axisAngle.length !== 4) {
117
107
  throw new QuaternionError(`Axis-angle must have exactly 4 components, got ${axisAngle.length}`);
118
108
  }
119
- try {
120
- AssertVector(axisAngle, options);
121
- }
122
- catch (error) {
123
- if (error instanceof VectorError) {
124
- 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]})`);
125
113
  }
126
- throw error;
127
114
  }
128
115
  }
129
116
  /**
@@ -134,7 +121,7 @@ export function AssertAxisAngle(axisAngle, options = {}) {
134
121
  * @param options - Validation options
135
122
  * @throws {QuaternionError} If the rotation matrix is invalid
136
123
  */
137
- export function AssertRotationMatrix(matrix, options = {}) {
124
+ export function AssertRotationMatrix(matrix) {
138
125
  if (!Array.isArray(matrix)) {
139
126
  throw new QuaternionError('Rotation matrix must be an array');
140
127
  }
@@ -149,14 +136,11 @@ export function AssertRotationMatrix(matrix, options = {}) {
149
136
  if (matrix[i].length !== 3) {
150
137
  throw new QuaternionError(`Rotation matrix row ${i} must have exactly 3 elements, got ${matrix[i].length}`);
151
138
  }
152
- try {
153
- AssertVector(matrix[i], options);
154
- }
155
- catch (error) {
156
- if (error instanceof VectorError) {
157
- 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]})`);
158
143
  }
159
- throw error;
160
144
  }
161
145
  }
162
146
  }
@@ -168,19 +152,19 @@ export function AssertRotationMatrix(matrix, options = {}) {
168
152
  * @param options - Validation options
169
153
  * @throws {QuaternionError} If any quaternion is invalid
170
154
  */
171
- export function AssertQuaternions(quaternions, options = {}) {
155
+ export function AssertQuaternions(quaternions) {
172
156
  if (!Array.isArray(quaternions)) {
173
157
  throw new QuaternionError('Quaternions must be an array');
174
158
  }
175
159
  for (let i = 0; i < quaternions.length; i++) {
176
160
  try {
177
- AssertQuaternion(quaternions[i], options);
161
+ AssertQuaternion(quaternions[i]);
178
162
  }
179
163
  catch (error) {
180
- if (error instanceof QuaternionError) {
181
- throw new QuaternionError(`Invalid quaternion at index ${i}: ${error.message}`);
182
- }
183
- throw error;
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
+ });
184
168
  }
185
169
  }
186
170
  }
@@ -202,9 +186,9 @@ export function AssertQuaternions(quaternions, options = {}) {
202
186
  * }
203
187
  * ```
204
188
  */
205
- export function ValidateQuaternion(quaternion, options = {}) {
189
+ export function ValidateQuaternion(quaternion) {
206
190
  try {
207
- AssertQuaternion(quaternion, options);
191
+ AssertQuaternion(quaternion);
208
192
  return true;
209
193
  }
210
194
  catch {
@@ -248,9 +232,9 @@ export function ValidateNormalizedQuaternion(quaternion, tolerance = 1e-6) {
248
232
  * }
249
233
  * ```
250
234
  */
251
- export function ValidateEulerAngles(euler, options = {}) {
235
+ export function ValidateEulerAngles(euler) {
252
236
  try {
253
- AssertEulerAngles(euler, options);
237
+ AssertEulerAngles(euler);
254
238
  return true;
255
239
  }
256
240
  catch {
@@ -271,9 +255,9 @@ export function ValidateEulerAngles(euler, options = {}) {
271
255
  * }
272
256
  * ```
273
257
  */
274
- export function ValidateAxisAngle(axisAngle, options = {}) {
258
+ export function ValidateAxisAngle(axisAngle) {
275
259
  try {
276
- AssertAxisAngle(axisAngle, options);
260
+ AssertAxisAngle(axisAngle);
277
261
  return true;
278
262
  }
279
263
  catch {
@@ -294,9 +278,9 @@ export function ValidateAxisAngle(axisAngle, options = {}) {
294
278
  * }
295
279
  * ```
296
280
  */
297
- export function ValidateRotationMatrix(matrix, options = {}) {
281
+ export function ValidateRotationMatrix(matrix) {
298
282
  try {
299
- AssertRotationMatrix(matrix, options);
283
+ AssertRotationMatrix(matrix);
300
284
  return true;
301
285
  }
302
286
  catch {
@@ -317,9 +301,9 @@ export function ValidateRotationMatrix(matrix, options = {}) {
317
301
  * }
318
302
  * ```
319
303
  */
320
- export function ValidateQuaternions(quaternions, options = {}) {
304
+ export function ValidateQuaternions(quaternions) {
321
305
  try {
322
- AssertQuaternions(quaternions, options);
306
+ AssertQuaternions(quaternions);
323
307
  return true;
324
308
  }
325
309
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"asserts.js","sourceRoot":"","sources":["../../src/quaternions/asserts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGlE;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC/B,IAAI,GAAW,kBAAkB,CAAC;IAElD;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,OAA6B;QACzD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAC/B,CAAC;CACD;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAmB,EAAE,UAAmC,EAAE;IAC1F,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,eAAe,CAAC,6BAA6B,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,eAAe,CAAC,kDAAkD,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IAClG,CAAC;IAED,qDAAqD;IACrD,IAAI,CA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UAAU,mBAAmB,CAAC,KAAc;IACjD,IAAI,CAAC;QACJ,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAkB;IACnD,IAAI,CAAC;QACJ,eAAe,CAAC,SAAS,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAe;IACrD,IAAI,CAAC;QACJ,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;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,8 +2,8 @@
2
2
  * Conversion utilities for quaternions and various rotation representations.
3
3
  * Provides comprehensive conversion between different rotation formats.
4
4
  */
5
- import { TMatrix4 } from '../matrices/types.js';
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
9
  * The matrix is returned as a proper TMatrix3 type.
@@ -12,11 +12,11 @@ import { TQuaternion, TRotationMatrix } from './types.js';
12
12
  * @returns 3x3 rotation matrix as TMatrix3
13
13
  *
14
14
  * @example
15
- * ```typescript
16
- * const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z-axis
17
- * const matrix = QuaternionToRotationMatrix(q);
18
- * // matrix represents rotation that transforms +X to +Y
19
- * ```
15
+ * ```typescript
16
+ * const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z-axis
17
+ * const matrix = QuaternionToRotationMatrix(q);
18
+ * // matrix represents rotation that transforms +X to +Y
19
+ * ```
20
20
  */
21
21
  export declare function QuaternionToRotationMatrix(quaternion: TQuaternion): TRotationMatrix;
22
22
  /**
@@ -27,11 +27,11 @@ export declare function QuaternionToRotationMatrix(quaternion: TQuaternion): TRo
27
27
  * @returns Normalized quaternion representing the same rotation
28
28
  *
29
29
  * @example
30
- * ```typescript
31
- * const identityMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
32
- * const q = QuaternionFromRotationMatrix(identityMatrix);
33
- * console.log(q); // [0, 0, 0, 1] (identity quaternion)
34
- * ```
30
+ * ```typescript
31
+ * const identityMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
32
+ * const q = QuaternionFromRotationMatrix(identityMatrix);
33
+ * console.log(q); // [0, 0, 0, 1] (identity quaternion)
34
+ * ```
35
35
  */
36
36
  export declare function QuaternionFromRotationMatrix(matrix: TRotationMatrix): TQuaternion;
37
37
  /**
@@ -43,11 +43,11 @@ export declare function QuaternionFromRotationMatrix(matrix: TRotationMatrix): T
43
43
  * @returns 4x4 transformation matrix as a flat array of 16 elements (row-major)
44
44
  *
45
45
  * @example
46
- * ```typescript
47
- * const q = [0, 0, 0, 1]; // Identity quaternion
48
- * const matrix4x4 = QuaternionToTransformationMatrix(q);
49
- * // Returns identity 4x4 matrix
50
- * ```
46
+ * ```typescript
47
+ * const q = [0, 0, 0, 1]; // Identity quaternion
48
+ * const matrix4x4 = QuaternionToTransformationMatrix(q);
49
+ * // Returns identity 4x4 matrix
50
+ * ```
51
51
  */
52
52
  export declare function QuaternionToTransformationMatrix(quaternion: TQuaternion): TMatrix4;
53
53
  /**
@@ -58,11 +58,11 @@ export declare function QuaternionToTransformationMatrix(quaternion: TQuaternion
58
58
  * @returns Normalized quaternion representing the rotation component
59
59
  *
60
60
  * @example
61
- * ```typescript
62
- * const transformMatrix = [1, 0, 0, 5, 0, 1, 0, 10, 0, 0, 1, 15, 0, 0, 0, 1];
63
- * const q = QuaternionFromTransformationMatrix(transformMatrix);
64
- * // Extracts rotation (identity in this case), ignores translation [5, 10, 15]
65
- * ```
61
+ * ```typescript
62
+ * const transformMatrix = [1, 0, 0, 5, 0, 1, 0, 10, 0, 0, 1, 15, 0, 0, 0, 1];
63
+ * const q = QuaternionFromTransformationMatrix(transformMatrix);
64
+ * // Extracts rotation (identity in this case), ignores translation [5, 10, 15]
65
+ * ```
66
66
  */
67
67
  export declare function QuaternionFromTransformationMatrix(matrix: TMatrix4): TQuaternion;
68
68
  /**
@@ -74,10 +74,10 @@ export declare function QuaternionFromTransformationMatrix(matrix: TMatrix4): TQ
74
74
  * @returns True if the matrix is a valid rotation matrix
75
75
  *
76
76
  * @example
77
- * ```typescript
78
- * const matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // Identity matrix
79
- * console.log(IsValidRotationMatrix(matrix)); // true
80
- * ```
77
+ * ```typescript
78
+ * const matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // Identity matrix
79
+ * console.log(IsValidRotationMatrix(matrix)); // true
80
+ * ```
81
81
  */
82
82
  export declare function IsValidRotationMatrix(matrix: TRotationMatrix, tolerance?: number): boolean;
83
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;AAEhD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAI1D;;;;;;;;;;;;;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"}
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"}
@@ -12,11 +12,11 @@ const SHEPPERD_QUARTER = 0.25;
12
12
  * @returns 3x3 rotation matrix as TMatrix3
13
13
  *
14
14
  * @example
15
- * ```typescript
16
- * const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z-axis
17
- * const matrix = QuaternionToRotationMatrix(q);
18
- * // matrix represents rotation that transforms +X to +Y
19
- * ```
15
+ * ```typescript
16
+ * const q = [0, 0, 0.707, 0.707]; // 90° rotation around Z-axis
17
+ * const matrix = QuaternionToRotationMatrix(q);
18
+ * // matrix represents rotation that transforms +X to +Y
19
+ * ```
20
20
  */
21
21
  export function QuaternionToRotationMatrix(quaternion) {
22
22
  AssertNormalizedQuaternion(quaternion);
@@ -44,11 +44,11 @@ export function QuaternionToRotationMatrix(quaternion) {
44
44
  * @returns Normalized quaternion representing the same rotation
45
45
  *
46
46
  * @example
47
- * ```typescript
48
- * const identityMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
49
- * const q = QuaternionFromRotationMatrix(identityMatrix);
50
- * console.log(q); // [0, 0, 0, 1] (identity quaternion)
51
- * ```
47
+ * ```typescript
48
+ * const identityMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
49
+ * const q = QuaternionFromRotationMatrix(identityMatrix);
50
+ * console.log(q); // [0, 0, 0, 1] (identity quaternion)
51
+ * ```
52
52
  */
53
53
  export function QuaternionFromRotationMatrix(matrix) {
54
54
  AssertRotationMatrix(matrix);
@@ -101,11 +101,11 @@ export function QuaternionFromRotationMatrix(matrix) {
101
101
  * @returns 4x4 transformation matrix as a flat array of 16 elements (row-major)
102
102
  *
103
103
  * @example
104
- * ```typescript
105
- * const q = [0, 0, 0, 1]; // Identity quaternion
106
- * const matrix4x4 = QuaternionToTransformationMatrix(q);
107
- * // Returns identity 4x4 matrix
108
- * ```
104
+ * ```typescript
105
+ * const q = [0, 0, 0, 1]; // Identity quaternion
106
+ * const matrix4x4 = QuaternionToTransformationMatrix(q);
107
+ * // Returns identity 4x4 matrix
108
+ * ```
109
109
  */
110
110
  export function QuaternionToTransformationMatrix(quaternion) {
111
111
  const rotationMatrix = QuaternionToRotationMatrix(quaternion);
@@ -125,11 +125,11 @@ export function QuaternionToTransformationMatrix(quaternion) {
125
125
  * @returns Normalized quaternion representing the rotation component
126
126
  *
127
127
  * @example
128
- * ```typescript
129
- * const transformMatrix = [1, 0, 0, 5, 0, 1, 0, 10, 0, 0, 1, 15, 0, 0, 0, 1];
130
- * const q = QuaternionFromTransformationMatrix(transformMatrix);
131
- * // Extracts rotation (identity in this case), ignores translation [5, 10, 15]
132
- * ```
128
+ * ```typescript
129
+ * const transformMatrix = [1, 0, 0, 5, 0, 1, 0, 10, 0, 0, 1, 15, 0, 0, 0, 1];
130
+ * const q = QuaternionFromTransformationMatrix(transformMatrix);
131
+ * // Extracts rotation (identity in this case), ignores translation [5, 10, 15]
132
+ * ```
133
133
  */
134
134
  export function QuaternionFromTransformationMatrix(matrix) {
135
135
  // Extract 3x3 rotation matrix from 4x4 transformation matrix
@@ -149,10 +149,10 @@ export function QuaternionFromTransformationMatrix(matrix) {
149
149
  * @returns True if the matrix is a valid rotation matrix
150
150
  *
151
151
  * @example
152
- * ```typescript
153
- * const matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // Identity matrix
154
- * console.log(IsValidRotationMatrix(matrix)); // true
155
- * ```
152
+ * ```typescript
153
+ * const matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // Identity matrix
154
+ * console.log(IsValidRotationMatrix(matrix)); // true
155
+ * ```
156
156
  */
157
157
  export function IsValidRotationMatrix(matrix, tolerance = 1e-6) {
158
158
  AssertRotationMatrix(matrix);