@lakuna/umath 1.3.9 → 1.4.2

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 (162) hide show
  1. package/README.md +1 -1
  2. package/dist/algorithms/approx.d.ts +9 -0
  3. package/dist/algorithms/approx.d.ts.map +1 -0
  4. package/dist/algorithms/approx.js +12 -0
  5. package/dist/algorithms/approx.js.map +1 -0
  6. package/dist/algorithms/approxRelative.d.ts +9 -0
  7. package/dist/algorithms/approxRelative.d.ts.map +1 -0
  8. package/dist/algorithms/approxRelative.js +12 -0
  9. package/dist/algorithms/approxRelative.js.map +1 -0
  10. package/dist/algorithms/combinations.d.ts +2 -1
  11. package/dist/algorithms/combinations.d.ts.map +1 -1
  12. package/dist/algorithms/combinations.js +2 -1
  13. package/dist/algorithms/combinations.js.map +1 -1
  14. package/dist/algorithms/degreesToRadians.d.ts +3 -2
  15. package/dist/algorithms/degreesToRadians.d.ts.map +1 -1
  16. package/dist/algorithms/degreesToRadians.js +5 -3
  17. package/dist/algorithms/degreesToRadians.js.map +1 -1
  18. package/dist/algorithms/factorial.d.ts +2 -1
  19. package/dist/algorithms/factorial.d.ts.map +1 -1
  20. package/dist/algorithms/factorial.js +2 -1
  21. package/dist/algorithms/factorial.js.map +1 -1
  22. package/dist/algorithms/fibonacci.d.ts +2 -1
  23. package/dist/algorithms/fibonacci.d.ts.map +1 -1
  24. package/dist/algorithms/fibonacci.js +6 -2
  25. package/dist/algorithms/fibonacci.js.map +1 -1
  26. package/dist/algorithms/greatestCommonDivisor.d.ts +4 -2
  27. package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
  28. package/dist/algorithms/greatestCommonDivisor.js +5 -2
  29. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  30. package/dist/algorithms/hypergeometricPmf.d.ts +3 -2
  31. package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
  32. package/dist/algorithms/hypergeometricPmf.js +3 -2
  33. package/dist/algorithms/hypergeometricPmf.js.map +1 -1
  34. package/dist/algorithms/isPrime.d.ts +2 -1
  35. package/dist/algorithms/isPrime.d.ts.map +1 -1
  36. package/dist/algorithms/isPrime.js +2 -1
  37. package/dist/algorithms/isPrime.js.map +1 -1
  38. package/dist/algorithms/permutations.d.ts +2 -1
  39. package/dist/algorithms/permutations.d.ts.map +1 -1
  40. package/dist/algorithms/permutations.js +2 -1
  41. package/dist/algorithms/permutations.js.map +1 -1
  42. package/dist/algorithms/primeFactorization.d.ts +2 -1
  43. package/dist/algorithms/primeFactorization.d.ts.map +1 -1
  44. package/dist/algorithms/primeFactorization.js +2 -1
  45. package/dist/algorithms/primeFactorization.js.map +1 -1
  46. package/dist/algorithms/radiansToDegrees.d.ts +3 -2
  47. package/dist/algorithms/radiansToDegrees.d.ts.map +1 -1
  48. package/dist/algorithms/radiansToDegrees.js +5 -3
  49. package/dist/algorithms/radiansToDegrees.js.map +1 -1
  50. package/dist/algorithms/summation.d.ts +2 -1
  51. package/dist/algorithms/summation.d.ts.map +1 -1
  52. package/dist/algorithms/summation.js +2 -1
  53. package/dist/algorithms/summation.js.map +1 -1
  54. package/dist/linalg/DualQuaternion.d.ts +102 -32
  55. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  56. package/dist/linalg/DualQuaternion.js +243 -272
  57. package/dist/linalg/DualQuaternion.js.map +1 -1
  58. package/dist/linalg/Matrix.d.ts +14 -10
  59. package/dist/linalg/Matrix.d.ts.map +1 -1
  60. package/dist/linalg/Matrix2.d.ts +74 -51
  61. package/dist/linalg/Matrix2.d.ts.map +1 -1
  62. package/dist/linalg/Matrix2.js +95 -171
  63. package/dist/linalg/Matrix2.js.map +1 -1
  64. package/dist/linalg/Matrix3.d.ts +122 -72
  65. package/dist/linalg/Matrix3.d.ts.map +1 -1
  66. package/dist/linalg/Matrix3.js +186 -355
  67. package/dist/linalg/Matrix3.js.map +1 -1
  68. package/dist/linalg/Matrix4.d.ts +266 -149
  69. package/dist/linalg/Matrix4.d.ts.map +1 -1
  70. package/dist/linalg/Matrix4.js +512 -852
  71. package/dist/linalg/Matrix4.js.map +1 -1
  72. package/dist/linalg/Quaternion.d.ts +252 -34
  73. package/dist/linalg/Quaternion.d.ts.map +1 -1
  74. package/dist/linalg/Quaternion.js +436 -166
  75. package/dist/linalg/Quaternion.js.map +1 -1
  76. package/dist/linalg/SlowMatrix.d.ts +10 -9
  77. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  78. package/dist/linalg/SlowMatrix.js +10 -9
  79. package/dist/linalg/SlowMatrix.js.map +1 -1
  80. package/dist/linalg/SlowSquareMatrix.d.ts +10 -9
  81. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  82. package/dist/linalg/SlowSquareMatrix.js +10 -9
  83. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  84. package/dist/linalg/SquareMatrix.d.ts +6 -5
  85. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  86. package/dist/linalg/Vector.d.ts +8 -4
  87. package/dist/linalg/Vector.d.ts.map +1 -1
  88. package/dist/linalg/Vector2.d.ts +82 -31
  89. package/dist/linalg/Vector2.d.ts.map +1 -1
  90. package/dist/linalg/Vector2.js +112 -154
  91. package/dist/linalg/Vector2.js.map +1 -1
  92. package/dist/linalg/Vector3.d.ts +93 -41
  93. package/dist/linalg/Vector3.d.ts.map +1 -1
  94. package/dist/linalg/Vector3.js +171 -282
  95. package/dist/linalg/Vector3.js.map +1 -1
  96. package/dist/linalg/Vector4.d.ts +71 -21
  97. package/dist/linalg/Vector4.d.ts.map +1 -1
  98. package/dist/linalg/Vector4.js +121 -195
  99. package/dist/linalg/Vector4.js.map +1 -1
  100. package/dist/types/AxisAngle.d.ts +4 -1
  101. package/dist/types/AxisAngle.d.ts.map +1 -1
  102. package/dist/types/FieldOfView.d.ts +4 -1
  103. package/dist/types/FieldOfView.d.ts.map +1 -1
  104. package/dist/utility/BigNumber.d.ts +4 -1
  105. package/dist/utility/BigNumber.d.ts.map +1 -1
  106. package/dist/utility/BigNumber.js +4 -1
  107. package/dist/utility/BigNumber.js.map +1 -1
  108. package/dist/utility/MagnitudeError.d.ts +4 -1
  109. package/dist/utility/MagnitudeError.d.ts.map +1 -1
  110. package/dist/utility/MagnitudeError.js +4 -1
  111. package/dist/utility/MagnitudeError.js.map +1 -1
  112. package/dist/utility/MatrixSizeError.d.ts +4 -1
  113. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  114. package/dist/utility/MatrixSizeError.js +4 -1
  115. package/dist/utility/MatrixSizeError.js.map +1 -1
  116. package/dist/utility/PartialMatrixError.d.ts +4 -1
  117. package/dist/utility/PartialMatrixError.d.ts.map +1 -1
  118. package/dist/utility/PartialMatrixError.js +4 -1
  119. package/dist/utility/PartialMatrixError.js.map +1 -1
  120. package/dist/utility/SingularMatrixError.d.ts +2 -1
  121. package/dist/utility/SingularMatrixError.d.ts.map +1 -1
  122. package/dist/utility/SingularMatrixError.js +2 -1
  123. package/dist/utility/SingularMatrixError.js.map +1 -1
  124. package/dist/utility/epsilon.d.ts +4 -1
  125. package/dist/utility/epsilon.d.ts.map +1 -1
  126. package/dist/utility/epsilon.js +4 -1
  127. package/dist/utility/epsilon.js.map +1 -1
  128. package/package.json +11 -11
  129. package/src/algorithms/approx.ts +12 -0
  130. package/src/algorithms/approxRelative.ts +12 -0
  131. package/src/algorithms/combinations.ts +2 -1
  132. package/src/algorithms/degreesToRadians.ts +6 -3
  133. package/src/algorithms/factorial.ts +3 -1
  134. package/src/algorithms/fibonacci.ts +7 -2
  135. package/src/algorithms/greatestCommonDivisor.ts +9 -4
  136. package/src/algorithms/hypergeometricPmf.ts +3 -2
  137. package/src/algorithms/isPrime.ts +2 -1
  138. package/src/algorithms/permutations.ts +2 -1
  139. package/src/algorithms/primeFactorization.ts +2 -1
  140. package/src/algorithms/radiansToDegrees.ts +6 -3
  141. package/src/algorithms/summation.ts +2 -1
  142. package/src/linalg/DualQuaternion.ts +424 -289
  143. package/src/linalg/Matrix.ts +14 -10
  144. package/src/linalg/Matrix2.ts +141 -188
  145. package/src/linalg/Matrix3.ts +400 -375
  146. package/src/linalg/Matrix4.ts +1083 -905
  147. package/src/linalg/Quaternion.ts +706 -188
  148. package/src/linalg/SlowMatrix.ts +10 -9
  149. package/src/linalg/SlowSquareMatrix.ts +10 -9
  150. package/src/linalg/SquareMatrix.ts +6 -5
  151. package/src/linalg/Vector.ts +8 -4
  152. package/src/linalg/Vector2.ts +146 -173
  153. package/src/linalg/Vector3.ts +293 -326
  154. package/src/linalg/Vector4.ts +227 -215
  155. package/src/types/AxisAngle.ts +4 -1
  156. package/src/types/FieldOfView.ts +4 -1
  157. package/src/utility/BigNumber.ts +6 -3
  158. package/src/utility/MagnitudeError.ts +4 -1
  159. package/src/utility/MatrixSizeError.ts +4 -1
  160. package/src/utility/PartialMatrixError.ts +4 -1
  161. package/src/utility/SingularMatrixError.ts +2 -1
  162. package/src/utility/epsilon.ts +4 -1
@@ -5,7 +5,8 @@ import epsilon from "../utility/epsilon.js";
5
5
 
6
6
  /**
7
7
  * A variable-size matrix.
8
- * @see [Matrix](https://en.wikipedia.org/wiki/Matrix_(mathematics))
8
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_(mathematics) | Matrix}
9
+ * @public
9
10
  */
10
11
  export default class SlowMatrix extends Float32Array implements Matrix {
11
12
  /**
@@ -41,7 +42,7 @@ export default class SlowMatrix extends Float32Array implements Matrix {
41
42
 
42
43
  /**
43
44
  * Get the Frobenius norm of this matrix.
44
- * @see [Matrix norm](https://en.wikipedia.org/wiki/Matrix_norm)
45
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
45
46
  */
46
47
  public get frob(): number {
47
48
  return Math.hypot(...this);
@@ -51,7 +52,7 @@ export default class SlowMatrix extends Float32Array implements Matrix {
51
52
  * Add two matrices of the same size.
52
53
  * @param matrix - The other matrix.
53
54
  * @returns The sum of the matrices.
54
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
55
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
55
56
  */
56
57
  public add(matrix: MatrixLike): SlowMatrix {
57
58
  const matrixWidth = "width" in matrix ? (matrix.width as number) : 1;
@@ -170,7 +171,7 @@ export default class SlowMatrix extends Float32Array implements Matrix {
170
171
  * Multiply this matrix by another.
171
172
  * @param matrix - The other matrix.
172
173
  * @returns The product of the matrices.
173
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
174
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
174
175
  */
175
176
  public multiply(matrix: MatrixLike): SlowMatrix {
176
177
  const matrixWidth = "width" in matrix ? (matrix.width as number) : 1;
@@ -206,7 +207,7 @@ export default class SlowMatrix extends Float32Array implements Matrix {
206
207
  * Multiply this matrix by a scalar value.
207
208
  * @param scalar - The scalar value.
208
209
  * @returns The product of the matrix and the scalar value.
209
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
210
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
210
211
  */
211
212
  public multiplyScalar(scalar: number): SlowMatrix {
212
213
  const out = this.clone();
@@ -226,8 +227,8 @@ export default class SlowMatrix extends Float32Array implements Matrix {
226
227
  * @param matrix - The other matrix.
227
228
  * @param scalar - The scalar.
228
229
  * @returns The sum.
229
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
230
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
230
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
231
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
231
232
  */
232
233
  public multiplyScalarAndAdd(matrix: MatrixLike, scalar: number): SlowMatrix {
233
234
  if (!("multiplyScalar" in matrix)) {
@@ -242,7 +243,7 @@ export default class SlowMatrix extends Float32Array implements Matrix {
242
243
  * Subtract another matrix from this one.
243
244
  * @param matrix - The other matrix.
244
245
  * @returns The difference between the matrices.
245
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
246
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
246
247
  */
247
248
  public subtract(matrix: MatrixLike): SlowMatrix {
248
249
  const matrixWidth = "width" in matrix ? (matrix.width as number) : 1;
@@ -269,7 +270,7 @@ export default class SlowMatrix extends Float32Array implements Matrix {
269
270
  /**
270
271
  * Transpose this matrix.
271
272
  * @returns The transpose of this matrix.
272
- * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
273
+ * @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
273
274
  */
274
275
  public transpose(): SlowMatrix {
275
276
  const cols: number[][] = [];
@@ -5,7 +5,8 @@ import type SquareMatrix from "./SquareMatrix.js";
5
5
 
6
6
  /**
7
7
  * A variable-size matrix with the same number of rows and columns.
8
- * @see [Square matrix](https://en.wikipedia.org/wiki/Square_matrix)
8
+ * @see {@link https://en.wikipedia.org/wiki/Square_matrix | Square matrix}
9
+ * @public
9
10
  */
10
11
  export default class SlowSquareMatrix
11
12
  extends SlowMatrix
@@ -14,7 +15,7 @@ export default class SlowSquareMatrix
14
15
  /**
15
16
  * Create a variable-size matrix with the same number of rows and columns from the given columns.
16
17
  * @param cols - The columns in the matrix.
17
- * @see [Square matrix](https://en.wikipedia.org/wiki/Square_matrix)
18
+ * @see {@link https://en.wikipedia.org/wiki/Square_matrix | Square matrix}
18
19
  */
19
20
  public constructor(...cols: number[][]) {
20
21
  super(...cols);
@@ -30,7 +31,7 @@ export default class SlowSquareMatrix
30
31
 
31
32
  /**
32
33
  * Get the determinant of this matrix.
33
- * @see [Determinant](https://en.wikipedia.org/wiki/Determinant)
34
+ * @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
34
35
  */
35
36
  public get determinant(): number {
36
37
  if (this.length < 1) {
@@ -56,7 +57,7 @@ export default class SlowSquareMatrix
56
57
  /**
57
58
  * Calculate the adjugate of this matrix.
58
59
  * @returns The adjugate of this matrix.
59
- * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
60
+ * @see {@link https://en.wikipedia.org/wiki/Adjugate_matrix | Adjugate matrix}
60
61
  */
61
62
  public adjoint(): SlowSquareMatrix {
62
63
  return this.cofactor().transpose();
@@ -84,7 +85,7 @@ export default class SlowSquareMatrix
84
85
  /**
85
86
  * Calculate the cofactor of this matrix.
86
87
  * @returns The cofactor.
87
- * @see [Minor](https://en.wikipedia.org/wiki/Minor_(linear_algebra))
88
+ * @see {@link https://en.wikipedia.org/wiki/Minor_(linear_algebra) | Minor}
88
89
  */
89
90
  public cofactor(): SlowSquareMatrix {
90
91
  const out: number[][] = [];
@@ -102,7 +103,7 @@ export default class SlowSquareMatrix
102
103
  /**
103
104
  * Reset this matrix to identity.
104
105
  * @returns This matrix.
105
- * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
106
+ * @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
106
107
  */
107
108
  public identity(): this {
108
109
  for (let i = 0; i < this.width; i++) {
@@ -117,7 +118,7 @@ export default class SlowSquareMatrix
117
118
  /**
118
119
  * Invert this matrix.
119
120
  * @returns The inverted matrix.
120
- * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
121
+ * @see {@link https://en.wikipedia.org/wiki/Invertible_matrix | Invertible matrix}
121
122
  */
122
123
  public invert(): SlowSquareMatrix {
123
124
  const dim = this.width;
@@ -188,7 +189,7 @@ export default class SlowSquareMatrix
188
189
  * @param row - The row to remove.
189
190
  * @param col - The column to remove.
190
191
  * @returns The minor.
191
- * @see [Minor](https://en.wikipedia.org/wiki/Minor_(linear_algebra))
192
+ * @see {@link https://en.wikipedia.org/wiki/Minor_(linear_algebra) | Minor}
192
193
  */
193
194
  public minor(row: number, col: number): number {
194
195
  return this.submatrix(row, col).determinant;
@@ -228,7 +229,7 @@ export default class SlowSquareMatrix
228
229
  /**
229
230
  * Transpose this matrix.
230
231
  * @returns The transpose of this matrix.
231
- * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
232
+ * @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
232
233
  */
233
234
  public override transpose(): SlowSquareMatrix {
234
235
  const cols: number[][] = [];
@@ -2,33 +2,34 @@ import type { default as Matrix, MatrixLike } from "./Matrix.js";
2
2
 
3
3
  /**
4
4
  * A matrix with the same number of rows and columns.
5
- * @see [Square matrix](https://en.wikipedia.org/wiki/Square_matrix)
5
+ * @see {@link https://en.wikipedia.org/wiki/Square_matrix | Square matrix}
6
+ * @public
6
7
  */
7
8
  export default interface SquareMatrix extends Matrix {
8
9
  /**
9
10
  * Get the determinant of this matrix.
10
- * @see [Determinant](https://en.wikipedia.org/wiki/Determinant)
11
+ * @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
11
12
  */
12
13
  get determinant(): number;
13
14
 
14
15
  /**
15
16
  * Calculate the adjugate of this matrix.
16
17
  * @returns The adjugate of this matrix.
17
- * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
18
+ * @see {@link https://en.wikipedia.org/wiki/Adjugate_matrix | Adjugate matrix}
18
19
  */
19
20
  adjoint(): MatrixLike;
20
21
 
21
22
  /**
22
23
  * Reset this matrix to identity.
23
24
  * @returns This matrix.
24
- * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
25
+ * @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
25
26
  */
26
27
  identity(): this;
27
28
 
28
29
  /**
29
30
  * Invert this matrix.
30
31
  * @returns The inverted matrix.
31
- * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
32
+ * @see {@link https://en.wikipedia.org/wiki/Invertible_matrix | Invertible matrix}
32
33
  */
33
34
  invert(): MatrixLike;
34
35
  }
@@ -1,11 +1,15 @@
1
1
  import type { Vector4Like } from "./Vector4.js";
2
2
 
3
- /** An object that could be interpreted as a vector. */
3
+ /**
4
+ * An object that could be interpreted as a vector.
5
+ * @public
6
+ */
4
7
  export type VectorLike = Record<number, number>;
5
8
 
6
9
  /**
7
10
  * A quantity with magnitude and direction.
8
- * @see [Wikipedia](https://en.wikipedia.org/wiki/Euclidean_vector)
11
+ * @see {@link https://en.wikipedia.org/wiki/Euclidean_vector | Euclidean vector}
12
+ * @public
9
13
  */
10
14
  export default interface Vector extends VectorLike {
11
15
  /**
@@ -145,7 +149,7 @@ export default interface Vector extends VectorLike {
145
149
  /**
146
150
  * Normalize this vector.
147
151
  * @returns The normalized vector.
148
- * @see [Unit vector](https://en.wikipedia.org/wiki/Unit_vector)
152
+ * @see {@link https://en.wikipedia.org/wiki/Unit_vector | Unit vector}
149
153
  */
150
154
  normalize(): VectorLike;
151
155
 
@@ -153,7 +157,7 @@ export default interface Vector extends VectorLike {
153
157
  * Calculate the dot product of this and another vector.
154
158
  * @param vector - The other vector.
155
159
  * @returns The dot product.
156
- * @see [Dot product](https://en.wikipedia.org/wiki/Dot_product)
160
+ * @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
157
161
  */
158
162
  dot(vector: Vector4Like): number;
159
163