@lakuna/umath 1.3.3 → 1.3.5

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 (133) hide show
  1. package/README.md +7 -9
  2. package/dist/algorithms/combinations.d.ts.map +1 -1
  3. package/dist/algorithms/combinations.js +1 -1
  4. package/dist/algorithms/combinations.js.map +1 -1
  5. package/dist/algorithms/degreesToRadians.d.ts.map +1 -1
  6. package/dist/algorithms/factorial.d.ts.map +1 -1
  7. package/dist/algorithms/factorial.js +8 -5
  8. package/dist/algorithms/factorial.js.map +1 -1
  9. package/dist/algorithms/fibonacci.d.ts +1 -1
  10. package/dist/algorithms/fibonacci.d.ts.map +1 -1
  11. package/dist/algorithms/fibonacci.js +1 -1
  12. package/dist/algorithms/fibonacci.js.map +1 -1
  13. package/dist/algorithms/greatestCommonDivisor.js +5 -9
  14. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  15. package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
  16. package/dist/algorithms/hypergeometricPmf.js +1 -1
  17. package/dist/algorithms/hypergeometricPmf.js.map +1 -1
  18. package/dist/algorithms/isPrime.d.ts.map +1 -1
  19. package/dist/algorithms/isPrime.js +1 -1
  20. package/dist/algorithms/isPrime.js.map +1 -1
  21. package/dist/algorithms/permutations.d.ts.map +1 -1
  22. package/dist/algorithms/permutations.js +1 -1
  23. package/dist/algorithms/permutations.js.map +1 -1
  24. package/dist/algorithms/primeFactorization.d.ts +1 -1
  25. package/dist/algorithms/primeFactorization.d.ts.map +1 -1
  26. package/dist/algorithms/primeFactorization.js +4 -3
  27. package/dist/algorithms/primeFactorization.js.map +1 -1
  28. package/dist/algorithms/radiansToDegrees.d.ts.map +1 -1
  29. package/dist/algorithms/summation.d.ts.map +1 -1
  30. package/dist/algorithms/summation.js.map +1 -1
  31. package/dist/index.d.ts +32 -33
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +27 -27
  34. package/dist/index.js.map +1 -1
  35. package/dist/linalg/DualQuaternion.d.ts +50 -56
  36. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  37. package/dist/linalg/DualQuaternion.js +67 -61
  38. package/dist/linalg/DualQuaternion.js.map +1 -1
  39. package/dist/linalg/Matrix.d.ts +13 -12
  40. package/dist/linalg/Matrix.d.ts.map +1 -1
  41. package/dist/linalg/Matrix2.d.ts +30 -34
  42. package/dist/linalg/Matrix2.d.ts.map +1 -1
  43. package/dist/linalg/Matrix2.js +26 -23
  44. package/dist/linalg/Matrix2.js.map +1 -1
  45. package/dist/linalg/Matrix3.d.ts +47 -47
  46. package/dist/linalg/Matrix3.d.ts.map +1 -1
  47. package/dist/linalg/Matrix3.js +52 -43
  48. package/dist/linalg/Matrix3.js.map +1 -1
  49. package/dist/linalg/Matrix4.d.ts +83 -102
  50. package/dist/linalg/Matrix4.d.ts.map +1 -1
  51. package/dist/linalg/Matrix4.js +105 -89
  52. package/dist/linalg/Matrix4.js.map +1 -1
  53. package/dist/linalg/Quaternion.d.ts +36 -49
  54. package/dist/linalg/Quaternion.d.ts.map +1 -1
  55. package/dist/linalg/Quaternion.js +33 -25
  56. package/dist/linalg/Quaternion.js.map +1 -1
  57. package/dist/linalg/SlowMatrix.d.ts +9 -9
  58. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  59. package/dist/linalg/SlowMatrix.js +76 -27
  60. package/dist/linalg/SlowMatrix.js.map +1 -1
  61. package/dist/linalg/SlowSquareMatrix.d.ts +3 -3
  62. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  63. package/dist/linalg/SlowSquareMatrix.js +53 -21
  64. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  65. package/dist/linalg/SquareMatrix.d.ts +3 -3
  66. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  67. package/dist/linalg/Vector.d.ts +25 -24
  68. package/dist/linalg/Vector.d.ts.map +1 -1
  69. package/dist/linalg/Vector2.d.ts +35 -52
  70. package/dist/linalg/Vector2.d.ts.map +1 -1
  71. package/dist/linalg/Vector2.js +8 -6
  72. package/dist/linalg/Vector2.js.map +1 -1
  73. package/dist/linalg/Vector3.d.ts +43 -63
  74. package/dist/linalg/Vector3.d.ts.map +1 -1
  75. package/dist/linalg/Vector3.js +46 -58
  76. package/dist/linalg/Vector3.js.map +1 -1
  77. package/dist/linalg/Vector4.d.ts +34 -45
  78. package/dist/linalg/Vector4.d.ts.map +1 -1
  79. package/dist/linalg/Vector4.js +6 -2
  80. package/dist/linalg/Vector4.js.map +1 -1
  81. package/dist/types/AxisAngle.d.ts +1 -1
  82. package/dist/types/AxisAngle.d.ts.map +1 -1
  83. package/dist/utility/BigNumber.d.ts +5 -8
  84. package/dist/utility/BigNumber.d.ts.map +1 -1
  85. package/dist/utility/BigNumber.js +5 -5
  86. package/dist/utility/BigNumber.js.map +1 -1
  87. package/dist/utility/MagnitudeError.d.ts.map +1 -1
  88. package/dist/utility/MagnitudeError.js +1 -1
  89. package/dist/utility/MagnitudeError.js.map +1 -1
  90. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  91. package/dist/utility/MatrixSizeError.js.map +1 -1
  92. package/dist/utility/PartialMatrixError.d.ts.map +1 -1
  93. package/dist/utility/PartialMatrixError.js.map +1 -1
  94. package/dist/utility/epsilon.d.ts.map +1 -1
  95. package/dist/utility/epsilon.js.map +1 -1
  96. package/package.json +20 -51
  97. package/src/algorithms/combinations.ts +5 -5
  98. package/src/algorithms/degreesToRadians.ts +4 -4
  99. package/src/algorithms/factorial.ts +14 -9
  100. package/src/algorithms/fibonacci.ts +3 -3
  101. package/src/algorithms/greatestCommonDivisor.ts +15 -19
  102. package/src/algorithms/hypergeometricPmf.ts +6 -7
  103. package/src/algorithms/isPrime.ts +5 -5
  104. package/src/algorithms/permutations.ts +5 -5
  105. package/src/algorithms/primeFactorization.ts +9 -9
  106. package/src/algorithms/radiansToDegrees.ts +4 -4
  107. package/src/algorithms/summation.ts +6 -6
  108. package/src/index.ts +35 -33
  109. package/src/linalg/DualQuaternion.ts +528 -780
  110. package/src/linalg/Matrix.ts +35 -36
  111. package/src/linalg/Matrix2.ts +253 -402
  112. package/src/linalg/Matrix3.ts +502 -720
  113. package/src/linalg/Matrix4.ts +1032 -1574
  114. package/src/linalg/Quaternion.ts +400 -679
  115. package/src/linalg/SlowMatrix.ts +124 -75
  116. package/src/linalg/SlowSquareMatrix.ts +92 -63
  117. package/src/linalg/SquareMatrix.ts +7 -7
  118. package/src/linalg/Vector.ts +71 -70
  119. package/src/linalg/Vector2.ts +342 -552
  120. package/src/linalg/Vector3.ts +502 -815
  121. package/src/linalg/Vector4.ts +347 -530
  122. package/src/types/AxisAngle.ts +1 -1
  123. package/src/utility/BigNumber.ts +36 -45
  124. package/src/utility/MagnitudeError.ts +4 -4
  125. package/src/utility/MatrixSizeError.ts +2 -3
  126. package/src/utility/PartialMatrixError.ts +2 -3
  127. package/src/utility/SingularMatrixError.ts +2 -2
  128. package/src/utility/epsilon.ts +1 -4
  129. package/dist/types/IntegerRepresentation.d.ts +0 -2
  130. package/dist/types/IntegerRepresentation.d.ts.map +0 -1
  131. package/dist/types/IntegerRepresentation.js +0 -2
  132. package/dist/types/IntegerRepresentation.js.map +0 -1
  133. package/src/types/IntegerRepresentation.ts +0 -2
@@ -1,36 +1,45 @@
1
- import type SquareMatrix from "#SquareMatrix";
2
- import type { Vector2Like } from "#Vector2";
3
- import epsilon from "#epsilon";
4
- import SingularMatrixError from "#SingularMatrixError";
1
+ import type { MatrixLike } from "./Matrix.js";
2
+ import SingularMatrixError from "../utility/SingularMatrixError.js";
3
+ import type SquareMatrix from "./SquareMatrix.js";
4
+ import type { Vector2Like } from "./Vector2.js";
5
+ import epsilon from "../utility/epsilon.js";
5
6
 
6
7
  /**
7
8
  * Numbers arranged into two columns and two rows.
8
9
  * @see [Matrix](https://en.wikipedia.org/wiki/Matrix_(mathematics))
9
10
  */
10
- export type Matrix2Like = Matrix2 | [number, number, number, number];
11
+ export interface Matrix2Like extends MatrixLike {
12
+ /** The value in the first column and first row. */
13
+ 0: number;
14
+
15
+ /** The value in the first column and second row. */
16
+ 1: number;
17
+
18
+ /** The value in the second column and first row. */
19
+ 2: number;
20
+
21
+ /** The value in the second column and second row. */
22
+ 3: number;
23
+ }
11
24
 
12
25
  /**
13
- * Creates a 2x2 matrix-like object.
26
+ * Create a 2x2 matrix-like object.
14
27
  * @returns A 2x2 matrix-like object.
15
28
  */
16
- export function createMatrix2Like(): Matrix2Like {
17
- return new Float32Array(4) as Matrix2Like;
29
+ export function createMatrix2Like() {
30
+ return new Float32Array(4) as unknown as Matrix2Like;
18
31
  }
19
32
 
20
33
  /**
21
- * Creates a transformation matrix that represents a rotation by the given
22
- * angle around the Z-axis.
23
- * @param radians The angle in radians.
24
- * @param out The matrix to store the result in.
34
+ * Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
35
+ * @param r - The angle in radians.
36
+ * @param out - The matrix to store the result in.
25
37
  * @returns The transformation matrix.
26
38
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
27
39
  */
28
- export function fromRotation<T extends Matrix2Like>(
29
- radians: number,
30
- out: T
31
- ): T {
32
- const s: number = Math.sin(radians);
33
- const c: number = Math.cos(radians);
40
+ export function fromRotation<T extends Matrix2Like>(r: number, out: T) {
41
+ const s = Math.sin(r);
42
+ const c = Math.cos(r);
34
43
 
35
44
  out[0] = c;
36
45
  out[1] = s;
@@ -40,17 +49,16 @@ export function fromRotation<T extends Matrix2Like>(
40
49
  }
41
50
 
42
51
  /**
43
- * Creates a transformation matrix that represents a scaling by the given
44
- * vector.
45
- * @param vector The scaling vector.
46
- * @param out The matrix to store the result in.
52
+ * Create a transformation matrix that represents a scaling by the given vector.
53
+ * @param v - The scaling vector.
54
+ * @param out - The matrix to store the result in.
47
55
  * @returns The transformation matrix.
48
56
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
49
57
  */
50
58
  export function fromScaling<T extends Matrix2Like>(
51
59
  vector: Vector2Like,
52
60
  out: T
53
- ): T {
61
+ ) {
54
62
  out[0] = vector[0];
55
63
  out[1] = 0;
56
64
  out[2] = 0;
@@ -59,12 +67,12 @@ export function fromScaling<T extends Matrix2Like>(
59
67
  }
60
68
 
61
69
  /**
62
- * Creates a two-by-two matrix with the given values.
63
- * @param c0r0 The value in the first column and first row.
64
- * @param c0r1 The value in the first column and second row.
65
- * @param c1r0 The value in the second column and first row.
66
- * @param c1r1 The value in the second column and second row.
67
- * @param out The matrix to store the result in.
70
+ * Create a two-by-two matrix with the given values.
71
+ * @param c0r0 - The value in the first column and first row.
72
+ * @param c0r1 - The value in the first column and second row.
73
+ * @param c1r0 - The value in the second column and first row.
74
+ * @param c1r1 - The value in the second column and second row.
75
+ * @param out - The matrix to store the result in.
68
76
  * @returns The matrix.
69
77
  */
70
78
  export function fromValues<T extends Matrix2Like>(
@@ -73,7 +81,7 @@ export function fromValues<T extends Matrix2Like>(
73
81
  c1r0: number,
74
82
  c1r1: number,
75
83
  out: T
76
- ): T {
84
+ ) {
77
85
  out[0] = c0r0;
78
86
  out[1] = c0r1;
79
87
  out[2] = c1r0;
@@ -82,21 +90,21 @@ export function fromValues<T extends Matrix2Like>(
82
90
  }
83
91
 
84
92
  /**
85
- * Determines whether two matrices are roughly equivalent.
86
- * @param a The first matrix.
87
- * @param b The second matrix.
88
- * @returns Whether the matrices are equivalent.
93
+ * Determine whether or not two matrices are roughly equivalent.
94
+ * @param a - The first matrix.
95
+ * @param b - The second matrix.
96
+ * @returns Whether or not the matrices are equivalent.
89
97
  */
90
- export function equals(a: Matrix2Like, b: Matrix2Like): boolean {
91
- const a0: number = a[0];
92
- const a1: number = a[1];
93
- const a2: number = a[2];
94
- const a3: number = a[3];
98
+ export function equals(a: Matrix2Like, b: Matrix2Like) {
99
+ const a0 = a[0];
100
+ const a1 = a[1];
101
+ const a2 = a[2];
102
+ const a3 = a[3];
95
103
 
96
- const b0: number = b[0];
97
- const b1: number = b[1];
98
- const b2: number = b[2];
99
- const b3: number = b[3];
104
+ const b0 = b[0];
105
+ const b1 = b[1];
106
+ const b2 = b[2];
107
+ const b3 = b[3];
100
108
 
101
109
  return (
102
110
  Math.abs(a0 - b0) <= epsilon * Math.max(1, Math.abs(a0), Math.abs(b0)) &&
@@ -107,20 +115,20 @@ export function equals(a: Matrix2Like, b: Matrix2Like): boolean {
107
115
  }
108
116
 
109
117
  /**
110
- * Determines whether two matrices are exactly equivalent.
111
- * @param a The first matrix.
112
- * @param b The second matrix.
118
+ * Determine whether or not two matrices are exactly equivalent.
119
+ * @param a - The first matrix.
120
+ * @param b - The second matrix.
113
121
  * @returns Whether the matrices are equivalent.
114
122
  */
115
- export function exactEquals(a: Matrix2Like, b: Matrix2Like): boolean {
116
- return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3];
123
+ export function exactEquals(a: Matrix2Like, b: Matrix2Like) {
124
+ return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
117
125
  }
118
126
 
119
127
  /**
120
- * Adds two matrices.
121
- * @param a The augend.
122
- * @param b The addend.
123
- * @param out The matrix to store the result in.
128
+ * Add two matrices.
129
+ * @param a - The augend.
130
+ * @param b - The addend.
131
+ * @param out - The matrix to store the result in.
124
132
  * @returns The sum.
125
133
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
126
134
  */
@@ -128,7 +136,7 @@ export function add<T extends Matrix2Like>(
128
136
  a: Matrix2Like,
129
137
  b: Matrix2Like,
130
138
  out: T
131
- ): T {
139
+ ) {
132
140
  out[0] = a[0] + b[0];
133
141
  out[1] = a[1] + b[1];
134
142
  out[2] = a[2] + b[2];
@@ -137,14 +145,14 @@ export function add<T extends Matrix2Like>(
137
145
  }
138
146
 
139
147
  /**
140
- * Calculates the adjugate of a matrix.
141
- * @param matrix The matrix.
142
- * @param out The matrix to store the result in.
148
+ * Calculate the adjugate of a matrix.
149
+ * @param matrix - The matrix.
150
+ * @param out - The matrix to store the result in.
143
151
  * @returns The adjugate of the matrix.
144
152
  * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
145
153
  */
146
- export function adjoint<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T {
147
- const a0: number = matrix[0];
154
+ export function adjoint<T extends Matrix2Like>(matrix: Matrix2Like, out: T) {
155
+ const a0 = matrix[0];
148
156
  out[0] = matrix[3];
149
157
  out[1] = -matrix[1];
150
158
  out[2] = -matrix[2];
@@ -153,12 +161,12 @@ export function adjoint<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T {
153
161
  }
154
162
 
155
163
  /**
156
- * Copies the values of one matrix to another.
157
- * @param matrix The matrix to copy.
158
- * @param out The matrix to store the result in.
164
+ * Copy the values from one matrix into another.
165
+ * @param matrix - The matrix to copy.
166
+ * @param out - The matrix to store the result in.
159
167
  * @returns The copy matrix.
160
168
  */
161
- export function copy<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T {
169
+ export function copy<T extends Matrix2Like>(matrix: Matrix2Like, out: T) {
162
170
  out[0] = matrix[0];
163
171
  out[1] = matrix[1];
164
172
  out[2] = matrix[2];
@@ -167,25 +175,20 @@ export function copy<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T {
167
175
  }
168
176
 
169
177
  /**
170
- * Calculates the Frobenius norm of a matrix.
171
- * @param matrix The matrix.
178
+ * Calculate the Frobenius norm of a matrix.
179
+ * @param matrix - The matrix.
172
180
  * @returns The Frobenius norm.
173
181
  * @see [Matrix norm](https://en.wikipedia.org/wiki/Matrix_norm)
174
182
  */
175
- export function frob(matrix: Matrix2Like): number {
176
- return Math.hypot(
177
- matrix[0] as number,
178
- matrix[1] as number,
179
- matrix[2] as number,
180
- matrix[3] as number
181
- );
183
+ export function frob(matrix: Matrix2Like) {
184
+ return Math.hypot(matrix[0], matrix[1], matrix[2], matrix[3]);
182
185
  }
183
186
 
184
187
  /**
185
- * Multiplies one matrix by another.
186
- * @param a The multiplicand.
187
- * @param b The multiplier.
188
- * @param out The matrix to store the result in.
188
+ * Multiply one matrix by another.
189
+ * @param a - The multiplicand.
190
+ * @param b - The multiplier.
191
+ * @param out - The matrix to store the result in.
189
192
  * @returns The product.
190
193
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
191
194
  */
@@ -193,16 +196,16 @@ export function multiply<T extends Matrix2Like>(
193
196
  a: Matrix2Like,
194
197
  b: Matrix2Like,
195
198
  out: T
196
- ): T {
197
- const a0: number = a[0];
198
- const a1: number = a[1];
199
- const a2: number = a[2];
200
- const a3: number = a[3];
199
+ ) {
200
+ const a0 = a[0];
201
+ const a1 = a[1];
202
+ const a2 = a[2];
203
+ const a3 = a[3];
201
204
 
202
- const b0: number = b[0];
203
- const b1: number = b[1];
204
- const b2: number = b[2];
205
- const b3: number = b[3];
205
+ const b0 = b[0];
206
+ const b1 = b[1];
207
+ const b2 = b[2];
208
+ const b3 = b[3];
206
209
 
207
210
  out[0] = a0 * b0 + a2 * b1;
208
211
  out[1] = a1 * b0 + a3 * b1;
@@ -212,10 +215,10 @@ export function multiply<T extends Matrix2Like>(
212
215
  }
213
216
 
214
217
  /**
215
- * Multiplies a matrix by a scalar value.
216
- * @param matrix The multiplicand.
217
- * @param scalar The multiplier.
218
- * @param out The matrix to store the result in.
218
+ * Multiply a matrix by a scalar value.
219
+ * @param matrix - The multiplicand.
220
+ * @param scalar - The multiplier.
221
+ * @param out - The matrix to store the result in.
219
222
  * @returns The product.
220
223
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
221
224
  */
@@ -223,7 +226,7 @@ export function multiplyScalar<T extends Matrix2Like>(
223
226
  matrix: Matrix2Like,
224
227
  scalar: number,
225
228
  out: T
226
- ): T {
229
+ ) {
227
230
  out[0] = matrix[0] * scalar;
228
231
  out[1] = matrix[1] * scalar;
229
232
  out[2] = matrix[2] * scalar;
@@ -232,11 +235,11 @@ export function multiplyScalar<T extends Matrix2Like>(
232
235
  }
233
236
 
234
237
  /**
235
- * Adds a matrix to another after multiplying the other by a scalar.
236
- * @param a The augend.
237
- * @param b The addend.
238
- * @param scalar The multiplier.
239
- * @param out The matrix to store the result in.
238
+ * Add a matrix to another after multiplying the other by a scalar.
239
+ * @param a - The augend.
240
+ * @param b - The addend.
241
+ * @param scalar - The multiplier.
242
+ * @param out - The matrix to store the result in.
240
243
  * @returns The sum.
241
244
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
242
245
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
@@ -246,7 +249,7 @@ export function multiplyScalarAndAdd<T extends Matrix2Like>(
246
249
  b: Matrix2Like,
247
250
  scalar: number,
248
251
  out: T
249
- ): T {
252
+ ) {
250
253
  out[0] = a[0] + b[0] * scalar;
251
254
  out[1] = a[1] + b[1] * scalar;
252
255
  out[2] = a[2] + b[2] * scalar;
@@ -255,10 +258,10 @@ export function multiplyScalarAndAdd<T extends Matrix2Like>(
255
258
  }
256
259
 
257
260
  /**
258
- * Subtracts one matrix from another.
259
- * @param a The minuend.
260
- * @param b The subtrahend.
261
- * @param out The matrix to store the result in.
261
+ * Subtract one matrix from another.
262
+ * @param a - The minuend.
263
+ * @param b - The subtrahend.
264
+ * @param out - The matrix to store the result in.
262
265
  * @returns The difference.
263
266
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
264
267
  */
@@ -266,7 +269,7 @@ export function subtract<T extends Matrix2Like>(
266
269
  a: Matrix2Like,
267
270
  b: Matrix2Like,
268
271
  out: T
269
- ): T {
272
+ ) {
270
273
  out[0] = a[0] - b[0];
271
274
  out[1] = a[1] - b[1];
272
275
  out[2] = a[2] - b[2];
@@ -275,17 +278,14 @@ export function subtract<T extends Matrix2Like>(
275
278
  }
276
279
 
277
280
  /**
278
- * Transposes a matrix.
279
- * @param matrix The matrix.
280
- * @param out The matrix to store the result in.
281
+ * Transpose a matrix.
282
+ * @param matrix - The matrix.
283
+ * @param out - The matrix to store the result in.
281
284
  * @returns The transpose of the matrix.
282
285
  * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
283
286
  */
284
- export function transpose<T extends Matrix2Like>(
285
- matrix: Matrix2Like,
286
- out: T
287
- ): T {
288
- if (out == matrix) {
287
+ export function transpose<T extends Matrix2Like>(matrix: Matrix2Like, out: T) {
288
+ if (out === matrix) {
289
289
  const a1 = matrix[1];
290
290
  out[1] = matrix[2];
291
291
  out[2] = a1;
@@ -299,25 +299,22 @@ export function transpose<T extends Matrix2Like>(
299
299
  }
300
300
 
301
301
  /**
302
- * Calculates the determinant of a matrix.
303
- * @param matrix The matrix.
302
+ * Calculate the determinant of a matrix.
303
+ * @param matrix- The matrix.
304
304
  * @returns The determinant.
305
305
  * @see [Determinant](https://en.wikipedia.org/wiki/Determinant)
306
306
  */
307
- export function determinant(matrix: Matrix2Like): number {
308
- return (
309
- (matrix[0] as number) * (matrix[3] as number) -
310
- (matrix[2] as number) * (matrix[1] as number)
311
- );
307
+ export function determinant(matrix: Matrix2Like) {
308
+ return matrix[0] * matrix[3] - matrix[2] * matrix[1];
312
309
  }
313
310
 
314
311
  /**
315
- * Resets a matrix to identity.
316
- * @param out The matrix to store the result in.
312
+ * Reset a matrix to identity.
313
+ * @param out - The matrix to store the result in.
317
314
  * @returns The matrix.
318
315
  * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
319
316
  */
320
- export function identity<T extends Matrix2Like>(out: T): T {
317
+ export function identity<T extends Matrix2Like>(out: T) {
321
318
  out[0] = 1;
322
319
  out[1] = 0;
323
320
  out[2] = 0;
@@ -326,51 +323,51 @@ export function identity<T extends Matrix2Like>(out: T): T {
326
323
  }
327
324
 
328
325
  /**
329
- * Inverts a matrix.
330
- * @param matrix The matrix.
331
- * @param out The matrix to store the result in.
326
+ * Invert a matrix.
327
+ * @param matrix - The matrix.
328
+ * @param out - The matrix to store the result in.
332
329
  * @returns The inverted matrix.
333
330
  * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
334
331
  */
335
- export function invert<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T {
336
- const a0: number = matrix[0];
337
- const a1: number = matrix[1];
338
- const a2: number = matrix[2];
339
- const a3: number = matrix[3];
340
-
341
- let determinant: number = a0 * a3 - a2 * a1;
342
- if (!determinant) {
332
+ export function invert<T extends Matrix2Like>(matrix: Matrix2Like, out: T) {
333
+ const a0 = matrix[0];
334
+ const a1 = matrix[1];
335
+ const a2 = matrix[2];
336
+ const a3 = matrix[3];
337
+
338
+ let det = a0 * a3 - a2 * a1;
339
+ if (!det) {
343
340
  throw new SingularMatrixError();
344
341
  }
345
- determinant = 1 / determinant;
342
+ det = 1 / det;
346
343
 
347
- out[0] = a3 * determinant;
348
- out[1] = -a1 * determinant;
349
- out[2] = -a2 * determinant;
350
- out[3] = a0 * determinant;
344
+ out[0] = a3 * det;
345
+ out[1] = -a1 * det;
346
+ out[2] = -a2 * det;
347
+ out[3] = a0 * det;
351
348
  return out;
352
349
  }
353
350
 
354
351
  /**
355
- * Rotates a matrix by the given angle.
356
- * @param matrix The matrix.
357
- * @param radians The angle in radians.
358
- * @param out The matrix to store the result in.
352
+ * Rotate a matrix by the given angle.
353
+ * @param matrix - The matrix.
354
+ * @param r - The angle in radians.
355
+ * @param out - The matrix to store the result in.
359
356
  * @returns The rotated matrix.
360
357
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
361
358
  */
362
359
  export function rotate<T extends Matrix2Like>(
363
360
  matrix: Matrix2Like,
364
- radians: number,
361
+ r: number,
365
362
  out: T
366
- ): T {
367
- const a0: number = matrix[0];
368
- const a1: number = matrix[1];
369
- const a2: number = matrix[2];
370
- const a3: number = matrix[3];
363
+ ) {
364
+ const a0 = matrix[0];
365
+ const a1 = matrix[1];
366
+ const a2 = matrix[2];
367
+ const a3 = matrix[3];
371
368
 
372
- const s: number = Math.sin(radians);
373
- const c: number = Math.cos(radians);
369
+ const s = Math.sin(r);
370
+ const c = Math.cos(r);
374
371
 
375
372
  out[0] = a0 * c + a2 * s;
376
373
  out[1] = a1 * c + a3 * s;
@@ -380,10 +377,10 @@ export function rotate<T extends Matrix2Like>(
380
377
  }
381
378
 
382
379
  /**
383
- * Scales a matrix by the given vector.
384
- * @param matrix The matrix.
385
- * @param vector The scaling vector.
386
- * @param out The matrix to store the result in.
380
+ * Scale a matrix by the given vector.
381
+ * @param matrix - The matrix.
382
+ * @param vector - The scaling vector.
383
+ * @param out - The matrix to store the result in.
387
384
  * @returns The scaled matrix.
388
385
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
389
386
  */
@@ -391,9 +388,9 @@ export function scale<T extends Matrix2Like>(
391
388
  matrix: Matrix2Like,
392
389
  vector: Vector2Like,
393
390
  out: T
394
- ): T {
395
- const v0: number = vector[0];
396
- const v1: number = vector[1];
391
+ ) {
392
+ const v0 = vector[0];
393
+ const v1 = vector[1];
397
394
 
398
395
  out[0] = matrix[0] * v0;
399
396
  out[1] = matrix[1] * v0;
@@ -406,84 +403,45 @@ export function scale<T extends Matrix2Like>(
406
403
  * A two-by-two matrix.
407
404
  * @see [Matrix](https://en.wikipedia.org/wiki/Matrix_(mathematics))
408
405
  */
409
- export default class Matrix2 extends Float32Array implements SquareMatrix {
410
- /**
411
- * Creates a transformation matrix that represents a rotation by the given
412
- * angle around the Z-axis.
413
- * @param radians The angle in radians.
414
- * @returns The transformation matrix.
415
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
416
- */
417
- public static fromRotation(radians: number): Matrix2;
418
-
419
- /**
420
- * Creates a transformation matrix that represents a rotation by the given
421
- * angle around the Z-axis.
422
- * @param radians The angle in radians.
423
- * @param out The matrix to store the result in.
406
+ export default class Matrix2
407
+ extends Float32Array
408
+ implements SquareMatrix, Matrix2Like
409
+ {
410
+ /**
411
+ * Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
412
+ * @param r - The angle in radians.
413
+ * @param out - The matrix to store the result in.
424
414
  * @returns The transformation matrix.
425
415
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
426
416
  */
427
- public static fromRotation<T extends Matrix2Like>(radians: number, out: T): T;
428
-
429
417
  public static fromRotation<T extends Matrix2Like>(
430
- radians: number,
431
- out: T = new Matrix2() as T
432
- ): T {
433
- return fromRotation(radians, out);
418
+ r: number,
419
+ out = new Matrix2() as unknown as T
420
+ ) {
421
+ return fromRotation(r, out);
434
422
  }
435
423
 
436
424
  /**
437
- * Creates a transformation matrix that represents a scaling by the given
438
- * vector.
439
- * @param vector The scaling vector.
440
- * @returns The transformation matrix.
441
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
442
- */
443
- public static fromScaling(vector: Vector2Like): Matrix2;
444
-
445
- /**
446
- * Creates a transformation matrix that represents a scaling by the given
447
- * vector.
448
- * @param vector The scaling vector.
449
- * @param out The matrix to store the result in.
425
+ * Create a transformation matrix that represents a scaling by the given vector.
426
+ * @param vector - The scaling vector.
427
+ * @param out - The matrix to store the result in.
450
428
  * @returns The transformation matrix.
451
429
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
452
430
  */
453
431
  public static fromScaling<T extends Matrix2Like>(
454
432
  vector: Vector2Like,
455
- out: T
456
- ): T;
457
-
458
- public static fromScaling<T extends Matrix2Like>(
459
- vector: Vector2Like,
460
- out: T = new Matrix2() as T
461
- ): T {
433
+ out = new Matrix2() as unknown as T
434
+ ) {
462
435
  return fromScaling(vector, out);
463
436
  }
464
437
 
465
438
  /**
466
- * Creates a two-by-two matrix with the given values.
467
- * @param c0r0 The value in the first column and first row.
468
- * @param c0r1 The value in the first column and second row.
469
- * @param c1r0 The value in the second column and first row.
470
- * @param c1r1 The value in the second column and second row.
471
- * @returns The matrix.
472
- */
473
- public static fromValues(
474
- c0r0: number,
475
- c0r1: number,
476
- c1r0: number,
477
- c1r1: number
478
- ): Matrix2;
479
-
480
- /**
481
- * Creates a two-by-two matrix with the given values.
482
- * @param c0r0 The value in the first column and first row.
483
- * @param c0r1 The value in the first column and second row.
484
- * @param c1r0 The value in the second column and first row.
485
- * @param c1r1 The value in the second column and second row.
486
- * @param out The matrix to store the result in.
439
+ * Create a two-by-two matrix with the given values.
440
+ * @param c0r0 - The value in the first column and first row.
441
+ * @param c0r1 - The value in the first column and second row.
442
+ * @param c1r0 - The value in the second column and first row.
443
+ * @param c1r1 - The value in the second column and second row.
444
+ * @param out - The matrix to store the result in.
487
445
  * @returns The matrix.
488
446
  */
489
447
  public static fromValues<T extends Matrix2Like>(
@@ -491,21 +449,13 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
491
449
  c0r1: number,
492
450
  c1r0: number,
493
451
  c1r1: number,
494
- out: T
495
- ): T;
496
-
497
- public static fromValues<T extends Matrix2Like>(
498
- c0r0: number,
499
- c0r1: number,
500
- c1r0: number,
501
- c1r1: number,
502
- out: T = new Matrix2() as T
503
- ): T {
452
+ out = new Matrix2() as unknown as T
453
+ ) {
504
454
  return fromValues(c0r0, c0r1, c1r0, c1r1, out);
505
455
  }
506
456
 
507
457
  /**
508
- * Creates a two-by-two identity matrix.
458
+ * Create a two-by-two identity matrix.
509
459
  * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
510
460
  */
511
461
  public constructor() {
@@ -518,6 +468,18 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
518
468
  this.height = 2;
519
469
  }
520
470
 
471
+ /** The value in the first column and first row. */
472
+ public 0: number;
473
+
474
+ /** The value in the first column and second row. */
475
+ public 1: number;
476
+
477
+ /** The value in the second column and first row. */
478
+ public 2: number;
479
+
480
+ /** The value in the second column and second row. */
481
+ public 3: number;
482
+
521
483
  /** The number of columns in this matrix. */
522
484
  public readonly width: 2;
523
485
 
@@ -525,163 +487,106 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
525
487
  public readonly height: 2;
526
488
 
527
489
  /**
528
- * Determines whether this matrix is roughly equivalent to another.
529
- * @param matrix The other matrix.
490
+ * Determine whether or not this matrix is roughly equivalent to another.
491
+ * @param matrix - The other matrix.
530
492
  * @returns Whether the matrices are equivalent.
531
493
  */
532
- public equals(matrix: Matrix2Like): boolean {
494
+ public equals(matrix: Matrix2Like) {
533
495
  return equals(this, matrix);
534
496
  }
535
497
 
536
498
  /**
537
- * Determines whether this matrix is exactly equivalent to another.
538
- * @param matrix The other matrix.
499
+ * Determine whether or not this matrix is exactly equivalent to another.
500
+ * @param matrix - The other matrix.
539
501
  * @returns Whether the matrices are equivalent.
540
502
  */
541
- public exactEquals(matrix: Matrix2Like): boolean {
503
+ public exactEquals(matrix: Matrix2Like) {
542
504
  return exactEquals(this, matrix);
543
505
  }
544
506
 
545
507
  /**
546
- * Adds another matrix to this one.
547
- * @param matrix The other matrix.
508
+ * Add another matrix to this one.
509
+ * @param matrix - The other matrix.
510
+ * @param out - The matrix to store the result in.
548
511
  * @returns The sum of the matrices.
549
512
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
550
513
  */
551
- public add(matrix: Matrix2Like): Matrix2;
552
-
553
- /**
554
- * Adds another matrix to this one.
555
- * @param matrix The other matrix.
556
- * @param out The matrix to store the result in.
557
- * @returns The sum of the matrices.
558
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
559
- */
560
- public add<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T;
561
-
562
514
  public add<T extends Matrix2Like>(
563
515
  matrix: Matrix2Like,
564
- out: T = new Matrix2() as T
565
- ): T {
516
+ out = new Matrix2() as unknown as T
517
+ ) {
566
518
  return add(this, matrix, out);
567
519
  }
568
520
 
569
521
  /**
570
- * Calculates the adjugate of this matrix.
522
+ * Calculate the adjugate of this matrix.
523
+ * @param out - The matrix to store the result in.
571
524
  * @returns The adjugate of this matrix.
572
525
  * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
573
526
  */
574
- public adjoint(): Matrix2;
575
-
576
- /**
577
- * Calculates the adjugate of this matrix.
578
- * @param out The matrix to store the result in.
579
- * @returns The adjugate of this matrix.
580
- * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
581
- */
582
- public adjoint<T extends Matrix2Like>(out: T): T;
583
-
584
- public adjoint<T extends Matrix2Like>(out: T = new Matrix2() as T): T {
527
+ public adjoint<T extends Matrix2Like>(out = new Matrix2() as unknown as T) {
585
528
  return adjoint(this, out);
586
529
  }
587
530
 
588
531
  /**
589
- * Creates a copy of this matrix.
590
- * @returns The copy.
591
- */
592
- public clone(): Matrix2;
593
-
594
- /**
595
- * Copies the values from this matrix to another one.
596
- * @param out The matrix to store the result in.
532
+ * Copy the values from this matrix to another one.
533
+ * @param out - The matrix to store the result in.
597
534
  * @returns The copy.
598
535
  */
599
- public clone<T extends Matrix2Like>(out: T): T;
600
-
601
- public clone<T extends Matrix2Like>(out: T = new Matrix2() as T): T {
536
+ public clone<T extends Matrix2Like>(out = new Matrix2() as unknown as T) {
602
537
  return copy(this, out);
603
538
  }
604
539
 
605
540
  /**
606
- * Copies the values of another matrix into this one.
607
- * @param matrix The matrix to copy.
541
+ * Copy the values of another matrix into this one.
542
+ * @param matrix - The matrix to copy.
608
543
  * @returns This matrix.
609
544
  */
610
- public copy(matrix: Matrix2Like): this {
545
+ public copy(matrix: Matrix2Like) {
611
546
  return copy(matrix, this);
612
547
  }
613
548
 
614
549
  /**
615
- * The Frobenius norm of this matrix.
550
+ * Get the Frobenius norm of this matrix.
616
551
  * @see [Matrix norm](https://en.wikipedia.org/wiki/Matrix_norm)
617
552
  */
618
- public get frob(): number {
553
+ public get frob() {
619
554
  return frob(this);
620
555
  }
621
556
 
622
557
  /**
623
- * Multiplies this matrix by another.
624
- * @param matrix The other matrix.
625
- * @returns The product of the matrices.
626
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
627
- */
628
- public multiply(matrix: Matrix2Like): Matrix2;
629
-
630
- /**
631
- * Multiplies this matrix by another.
632
- * @param matrix The other matrix.
633
- * @param out The matrix to store the result in.
558
+ * Multiply this matrix by another.
559
+ * @param matrix - The other matrix.
560
+ * @param out - The matrix to store the result in.
634
561
  * @returns The product of the matrices.
635
562
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
636
563
  */
637
- public multiply<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T;
638
-
639
564
  public multiply<T extends Matrix2Like>(
640
565
  matrix: Matrix2Like,
641
- out: T = new Matrix2() as T
642
- ): T {
566
+ out = new Matrix2() as unknown as T
567
+ ) {
643
568
  return multiply(this, matrix, out);
644
569
  }
645
570
 
646
571
  /**
647
- * Multiplies this matrix by a scalar value.
648
- * @param scalar The scalar value.
649
- * @returns The product of the matrix and the scalar value.
650
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
651
- */
652
- public multiplyScalar(scalar: number): Matrix2;
653
-
654
- /**
655
- * Multiplies this matrix by a scalar value.
656
- * @param scalar The scalar value.
657
- * @param out The matrix to store the result in.
572
+ * Multiply this matrix by a scalar value.
573
+ * @param scalar - The scalar value.
574
+ * @param out - The matrix to store the result in.
658
575
  * @returns The product of the matrix and the scalar value.
659
576
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
660
577
  */
661
- public multiplyScalar<T extends Matrix2Like>(scalar: number, out: T): T;
662
-
663
578
  public multiplyScalar<T extends Matrix2Like>(
664
579
  scalar: number,
665
- out: T = new Matrix2() as T
666
- ): T {
580
+ out = new Matrix2() as unknown as T
581
+ ) {
667
582
  return multiplyScalar(this, scalar, out);
668
583
  }
669
584
 
670
585
  /**
671
- * Adds this matrix to another after multiplying the other by a scalar.
672
- * @param matrix The other matrix.
673
- * @param scalar The scalar.
674
- * @returns The sum.
675
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
676
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
677
- */
678
- public multiplyScalarAndAdd(matrix: Matrix2Like, scalar: number): Matrix2;
679
-
680
- /**
681
- * Adds this matrix to another after multiplying the other by a scalar.
682
- * @param matrix The other matrix.
683
- * @param scalar The scalar.
684
- * @param out The matrix to store the result in.
586
+ * Add this matrix to another after multiplying the other by a scalar.
587
+ * @param matrix - The other matrix.
588
+ * @param scalar - The scalar.
589
+ * @param out - The matrix to store the result in.
685
590
  * @returns The sum.
686
591
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
687
592
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
@@ -689,141 +594,87 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
689
594
  public multiplyScalarAndAdd<T extends Matrix2Like>(
690
595
  matrix: Matrix2Like,
691
596
  scalar: number,
692
- out: T
693
- ): T;
694
-
695
- public multiplyScalarAndAdd<T extends Matrix2Like>(
696
- matrix: Matrix2Like,
697
- scalar: number,
698
- out: T = new Matrix2() as T
699
- ): T {
597
+ out = new Matrix2() as unknown as T
598
+ ) {
700
599
  return multiplyScalarAndAdd(this, matrix, scalar, out);
701
600
  }
702
601
 
703
602
  /**
704
- * Subtracts another matrix from this one.
705
- * @param matrix The other matrix.
706
- * @returns The difference between the matrices.
707
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
708
- */
709
- public subtract(matrix: Matrix2Like): Matrix2;
710
-
711
- /**
712
- * Subtracts another matrix from this one.
713
- * @param matrix The other matrix.
714
- * @param out The matrix to store the result in.
603
+ * Subtract another matrix from this one.
604
+ * @param matrix - The other matrix.
605
+ * @param out - The matrix to store the result in.
715
606
  * @returns The difference between the matrices.
716
607
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
717
608
  */
718
- public subtract<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T;
719
-
720
609
  public subtract<T extends Matrix2Like>(
721
610
  matrix: Matrix2Like,
722
- out: T = new Matrix2() as T
723
- ): T {
611
+ out = new Matrix2() as unknown as T
612
+ ) {
724
613
  return subtract(this, matrix, out);
725
614
  }
726
615
 
727
616
  /**
728
- * Transposes this matrix.
729
- * @returns The transpose of this matrix.
730
- * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
731
- */
732
- public transpose(): Matrix2;
733
-
734
- /**
735
- * Transposes this matrix.
736
- * @param out The matrix to store the result in.
617
+ * Transpose this matrix.
618
+ * @param out - The matrix to store the result in.
737
619
  * @returns The transpose of this matrix.
738
620
  * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
739
621
  */
740
- public transpose<T extends Matrix2Like>(out: T): T;
741
-
742
- public transpose<T extends Matrix2Like>(out: T = new Matrix2() as T): T {
622
+ public transpose<T extends Matrix2Like>(out = new Matrix2() as unknown as T) {
743
623
  return transpose(this, out);
744
624
  }
745
625
 
746
626
  /**
747
- * The determinant of this matrix.
627
+ * Get the determinant of this matrix.
748
628
  * @see [Determinant](https://en.wikipedia.org/wiki/Determinant)
749
629
  */
750
- public get determinant(): number {
630
+ public get determinant() {
751
631
  return determinant(this);
752
632
  }
753
633
 
754
634
  /**
755
- * Resets this matrix to identity.
635
+ * Reset this matrix to identity.
756
636
  * @returns This matrix.
757
637
  * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
758
638
  */
759
- public identity(): this {
639
+ public identity() {
760
640
  return identity(this);
761
641
  }
762
642
 
763
643
  /**
764
- * Inverts this matrix.
765
- * @returns The inverted matrix.
766
- * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
767
- */
768
- public invert(): Matrix2;
769
-
770
- /**
771
- * Inverts this matrix.
772
- * @param out The matrix to store the result in.
644
+ * Invert this matrix.
645
+ * @param out - The matrix to store the result in.
773
646
  * @returns The inverted matrix.
774
647
  * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
775
648
  */
776
- public invert<T extends Matrix2Like>(out: T): T;
777
-
778
- public invert<T extends Matrix2Like>(out: T = new Matrix2() as T): T {
649
+ public invert<T extends Matrix2Like>(out = new Matrix2() as unknown as T) {
779
650
  return invert(this, out);
780
651
  }
781
652
 
782
653
  /**
783
- * Rotates this matrix by the given angle.
784
- * @param radians The angle in radians.
785
- * @returns The rotated matrix.
786
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
787
- */
788
- public rotate(radians: number): Matrix2;
789
-
790
- /**
791
- * Rotates this matrix by the given angle.
792
- * @param radians The angle in radians.
793
- * @param out The matrix to store the result in.
654
+ * Rotate this matrix by the given angle.
655
+ * @param r - The angle in radians.
656
+ * @param out - The matrix to store the result in.
794
657
  * @returns The rotated matrix.
795
658
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
796
659
  */
797
- public rotate<T extends Matrix2Like>(radians: number, out: T): T;
798
-
799
660
  public rotate<T extends Matrix2Like>(
800
- radians: number,
801
- out: T = new Matrix2() as T
802
- ): T {
803
- return rotate(this, radians, out);
661
+ r: number,
662
+ out = new Matrix2() as unknown as T
663
+ ) {
664
+ return rotate(this, r, out);
804
665
  }
805
666
 
806
667
  /**
807
- * Scales this matrix by the given vector.
808
- * @param v The scaling vector.
668
+ * Scale this matrix by the given vector.
669
+ * @param vector - The scaling vector.
670
+ * @param out - The matrix to store the result in.
809
671
  * @returns The scaled matrix.
810
672
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
811
673
  */
812
- public scale(v: Vector2Like): Matrix2;
813
-
814
- /**
815
- * Scales this matrix by the given vector.
816
- * @param vector The scaling vector.
817
- * @param out The matrix to store the result in.
818
- * @returns The scaled matrix.
819
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
820
- */
821
- public scale<T extends Matrix2Like>(vector: Vector2Like, out: T): T;
822
-
823
674
  public scale<T extends Matrix2Like>(
824
675
  vector: Vector2Like,
825
- out: T = new Matrix2() as T
826
- ): T {
676
+ out = new Matrix2() as unknown as T
677
+ ) {
827
678
  return scale(this, vector, out);
828
679
  }
829
680
  }