@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
package/README.md CHANGED
@@ -19,7 +19,7 @@ yarn add @pawells/math-extended
19
19
 
20
20
  ## Usage
21
21
 
22
- All exports are available as individual named imports for tree-shaking, or grouped via namespace imports for convenience.
22
+ All exports are available as individual named imports for tree-shaking optimization.
23
23
 
24
24
  ### Direct Named Imports (Tree-Shaking Friendly)
25
25
 
@@ -43,29 +43,22 @@ const v = SmoothStep(0, 10, 0.5); // 5
43
43
  const rad = DegreesToRadians(180); // Math.PI
44
44
  ```
45
45
 
46
- ### Namespace Imports (Grouped)
47
-
48
- Import related utilities together using namespace imports:
49
-
50
- ```typescript
51
- import { VectorUtils, MatrixUtils, QuaternionUtils } from '@pawells/math-extended';
52
-
53
- // Access utilities via namespace
54
- VectorUtils.VectorAdd([1, 0, 0], [0, 1, 0]);
55
- MatrixUtils.MatrixMultiply(matA, matB);
56
- QuaternionUtils.QuaternionSLERP(q1, q2, 0.5);
57
- ```
58
46
 
59
47
  ### Import Patterns
60
48
 
61
49
  | Pattern | Best For | Example |
62
50
  |---------|----------|---------|
63
51
  | **Direct named** | Tree-shaking, small imports | `import { VectorAdd } from '@pawells/math-extended'` |
64
- | **Namespace** | Grouping related functions | `import { VectorUtils } from '@pawells/math-extended'` |
65
- | **Mixed** | Flexibility | Both patterns together |
52
+ | **Mixed** | Flexibility | Multiple imports together |
66
53
 
67
54
  ## API
68
55
 
56
+ ### Core
57
+
58
+ | Export | Description |
59
+ |--------|-------------|
60
+ | `CubeRoot(value)` | Compute the cube root of a number |
61
+
69
62
  ### Angles
70
63
 
71
64
  | Export | Description |
@@ -106,7 +99,7 @@ All interpolation functions share the signature `(a, b, t)`. `t` is typically in
106
99
  | `CosineInterpolation` | Cosine interpolation |
107
100
  | `CatmullRomInterpolation` | Catmull-Rom spline `(p0, p1, p2, p3, t)` |
108
101
  | `HermiteInterpolation` | Hermite spline `(p0, p1, t0, t1, t)` |
109
- | `SphericalLinearInterpolation` | Shortest-arc scalar SLERP |
102
+ | `SphericalLinearInterpolation` | **@deprecated** Identical to `LinearInterpolation`. Use `QuaternionSLERP` for true spherical interpolation. |
110
103
  | `StepInterpolation` | Step function with configurable threshold |
111
104
  | `QuadraticEaseIn/Out/InOut` | Quadratic easing |
112
105
  | `CubicEaseIn/Out/InOut` | Cubic easing |
@@ -172,11 +165,11 @@ Every scalar easing function has a `Vector*` counterpart (e.g., `VectorSmoothSte
172
165
 
173
166
  #### Assertions
174
167
 
175
- `AssertVector`, `AssertVector2`, `AssertVector3`, `AssertVector4`, `AssertVectorValue`, `AssertVectors`, `VectorError`
168
+ `AssertVector`, `AssertVector2`, `AssertVector3`, `AssertVector4`, `AssertVectorNonZero`, `AssertVectorSameSize`, `ValidateVector`, `ValidateVector2`, `ValidateVector3`, `ValidateVector4`, `ValidateVectorSameSize`, `VectorError`
176
169
 
177
170
  ### Matrices
178
171
 
179
- Matrices are `number[][]` arrays (`IMatrix`, `IMatrix1`–`IMatrix4`). All operations return new matrices.
172
+ Matrices are `number[][]` arrays (`TMatrix`, `TMatrix1`–`TMatrix4`). All operations return new matrices.
180
173
 
181
174
  #### Core
182
175
 
@@ -266,7 +259,7 @@ Matrices are `number[][]` arrays (`IMatrix`, `IMatrix1`–`IMatrix4`). All opera
266
259
 
267
260
  #### Assertions
268
261
 
269
- `AssertMatrix`, `AssertMatrix1`–`AssertMatrix4`, `AssertMatrixRow`, `AssertMatrixValue`, `AssertMatrices`, `MatrixError`
262
+ `AssertMatrix`, `AssertMatrix1`–`AssertMatrix4`, `AssertMatrixSquare`, `AssertMatricesCompatible`, `ValidateMatrix`, `ValidateMatrix1`–`ValidateMatrix4`, `ValidateMatrixSquare`, `MatrixError`
270
263
 
271
264
  ### Quaternions
272
265
 
@@ -318,6 +311,7 @@ Quaternions are `[x, y, z, w]` tuples (`TQuaternion`).
318
311
 
319
312
  `AssertQuaternion`, `AssertQuaternions`, `AssertNormalizedQuaternion`, `AssertAxisAngle`, `AssertEulerAngles`, `AssertRotationMatrix`, `QuaternionError`
320
313
 
314
+
321
315
  ## Development
322
316
 
323
317
  ```bash
@@ -328,7 +322,7 @@ yarn watch # Watch mode
328
322
  yarn typecheck # Type check without building
329
323
  yarn lint # ESLint
330
324
  yarn lint:fix # ESLint with auto-fix
331
- yarn test # Run tests (1080 tests)
325
+ yarn test # Run tests (1137 tests)
332
326
  yarn test:ui # Interactive Vitest UI
333
327
  yarn test:coverage # Tests with coverage report
334
328
  ```
@@ -339,4 +333,4 @@ yarn test:coverage # Tests with coverage report
339
333
 
340
334
  ## License
341
335
 
342
- MIT See [LICENSE](./LICENSE) for details.
336
+ This project is licensed under the [MIT License](LICENSE).
package/build/clamp.d.ts CHANGED
@@ -9,11 +9,11 @@
9
9
  * @returns The clamped value in the range [min, max]
10
10
  *
11
11
  * @example
12
- * ```typescript
13
- * Clamp(5, 0, 10) // 5 (within range)
14
- * Clamp(-3, 0, 10) // 0 (below min)
15
- * Clamp(15, 0, 10) // 10 (above max)
16
- * ```
12
+ * ```typescript
13
+ * Clamp(5, 0, 10) // 5 (within range)
14
+ * Clamp(-3, 0, 10) // 0 (below min)
15
+ * Clamp(15, 0, 10) // 10 (above max)
16
+ * ```
17
17
  */
18
18
  export declare function Clamp(x: number, min: number, max: number): number;
19
19
  //# sourceMappingURL=clamp.d.ts.map
package/build/clamp.js CHANGED
@@ -9,11 +9,11 @@
9
9
  * @returns The clamped value in the range [min, max]
10
10
  *
11
11
  * @example
12
- * ```typescript
13
- * Clamp(5, 0, 10) // 5 (within range)
14
- * Clamp(-3, 0, 10) // 0 (below min)
15
- * Clamp(15, 0, 10) // 10 (above max)
16
- * ```
12
+ * ```typescript
13
+ * Clamp(5, 0, 10) // 5 (within range)
14
+ * Clamp(-3, 0, 10) // 0 (below min)
15
+ * Clamp(15, 0, 10) // 10 (above max)
16
+ * ```
17
17
  */
18
18
  export function Clamp(x, min, max) {
19
19
  return Math.max(min, Math.min(x, max));
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Core mathematical utilities for pure numeric calculations.
3
+ * Provides foundational math operations with no domain coupling.
4
+ */
5
+ /**
6
+ * Calculates the cube root of a number, preserving the sign of the input.
7
+ * Handles negative numbers correctly (unlike Math.cbrt in some contexts).
8
+ *
9
+ * @param value - The value to calculate the cube root of
10
+ * @returns The cube root of the value, with same sign as input
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { CubeRoot } from '@pawells/math-extended';
15
+ *
16
+ * CubeRoot(8); // 2
17
+ * CubeRoot(-8); // -2
18
+ * CubeRoot(27); // 3
19
+ * CubeRoot(0); // 0
20
+ * ```
21
+ */
22
+ export declare function CubeRoot(value: number): number;
23
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C"}
package/build/core.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Core mathematical utilities for pure numeric calculations.
3
+ * Provides foundational math operations with no domain coupling.
4
+ */
5
+ /**
6
+ * Calculates the cube root of a number, preserving the sign of the input.
7
+ * Handles negative numbers correctly (unlike Math.cbrt in some contexts).
8
+ *
9
+ * @param value - The value to calculate the cube root of
10
+ * @returns The cube root of the value, with same sign as input
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { CubeRoot } from '@pawells/math-extended';
15
+ *
16
+ * CubeRoot(8); // 2
17
+ * CubeRoot(-8); // -2
18
+ * CubeRoot(27); // 3
19
+ * CubeRoot(0); // 0
20
+ * ```
21
+ */
22
+ export function CubeRoot(value) {
23
+ return Math.sign(value) * Math.pow(Math.abs(value), 1 / 3);
24
+ }
25
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACrC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5D,CAAC"}
package/build/index.d.ts CHANGED
@@ -1,8 +1,5 @@
1
- export * as VectorUtils from './vectors/index.js';
2
- export * as MatrixUtils from './matrices/index.js';
3
- export * as QuaternionUtils from './quaternions/index.js';
4
- export * from './angles.js';
5
1
  export * from './clamp.js';
2
+ export * from './core.js';
6
3
  export * from './interpolation.js';
7
4
  export * from './matrices/index.js';
8
5
  export * from './quaternions/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAG1D,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
package/build/index.js CHANGED
@@ -1,10 +1,5 @@
1
- // Namespace exports for grouped imports
2
- export * as VectorUtils from './vectors/index.js';
3
- export * as MatrixUtils from './matrices/index.js';
4
- export * as QuaternionUtils from './quaternions/index.js';
5
- // Direct named exports for tree-shaking
6
- export * from './angles.js';
7
1
  export * from './clamp.js';
2
+ export * from './core.js';
8
3
  export * from './interpolation.js';
9
4
  export * from './matrices/index.js';
10
5
  export * from './quaternions/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,wCAAwC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}