@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,40 +1,62 @@
1
- import type { Matrix4Like } from "#Matrix4";
2
- import type { QuaternionLike } from "#Quaternion";
3
- import type SquareMatrix from "#SquareMatrix";
4
- import type { Vector2Like } from "#Vector2";
5
- import epsilon from "#epsilon";
6
- import SingularMatrixError from "#SingularMatrixError";
1
+ import type { Matrix4Like } from "./Matrix4.js";
2
+ import type { MatrixLike } from "./Matrix.js";
3
+ import type { QuaternionLike } from "./Quaternion.js";
4
+ import SingularMatrixError from "../utility/SingularMatrixError.js";
5
+ import type SquareMatrix from "./SquareMatrix.js";
6
+ import type { Vector2Like } from "./Vector2.js";
7
+ import epsilon from "../utility/epsilon.js";
7
8
 
8
9
  /**
9
10
  * Numbers arranged into three columns and three rows.
10
11
  * @see [Matrix](https://en.wikipedia.org/wiki/Matrix_(mathematics))
11
12
  */
12
- export type Matrix3Like =
13
- | Matrix3
14
- | [number, number, number, number, number, number, number, number, number];
13
+ export interface Matrix3Like extends MatrixLike {
14
+ /** The value in the first column and first row. */
15
+ 0: number;
16
+
17
+ /** The value in the first column and second row. */
18
+ 1: number;
19
+
20
+ /** The value in the first column and third row. */
21
+ 2: number;
22
+
23
+ /** The value in the second column and first row. */
24
+ 3: number;
25
+
26
+ /** The value in the second column and second row. */
27
+ 4: number;
28
+
29
+ /** The value in the second column and third row. */
30
+ 5: number;
31
+
32
+ /** The value in the third column and first row. */
33
+ 6: number;
34
+
35
+ /** The value in the third column and second row. */
36
+ 7: number;
37
+
38
+ /** The value in the third column and third row. */
39
+ 8: number;
40
+ }
15
41
 
16
42
  /**
17
43
  * Creates a 3x3 matrix-like object.
18
44
  * @returns A 3x3 matrix-like object.
19
45
  */
20
- export function createMatrix3Like(): Matrix3Like {
21
- return new Float32Array(9) as Matrix3Like;
46
+ export function createMatrix3Like() {
47
+ return new Float32Array(9) as unknown as Matrix3Like;
22
48
  }
23
49
 
24
50
  /**
25
- * Creates a transformation matrix that represents a rotation by the given
26
- * angle around the Z-axis.
27
- * @param radians The angle in radians.
28
- * @param out The matrix to store the result in.
51
+ * Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
52
+ * @param r - The angle in radians.
53
+ * @param out - The matrix to store the result in.
29
54
  * @returns The transformation matrix.
30
55
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
31
56
  */
32
- export function fromRotation<T extends Matrix3Like>(
33
- radians: number,
34
- out: T
35
- ): T {
36
- const s: number = Math.sin(radians);
37
- const c: number = Math.cos(radians);
57
+ export function fromRotation<T extends Matrix3Like>(r: number, out: T) {
58
+ const s = Math.sin(r);
59
+ const c = Math.cos(r);
38
60
 
39
61
  out[0] = c;
40
62
  out[1] = s;
@@ -49,17 +71,16 @@ export function fromRotation<T extends Matrix3Like>(
49
71
  }
50
72
 
51
73
  /**
52
- * Creates a transformation matrix that represents a scaling by the given
53
- * vector.
54
- * @param vector The scaling vector.
55
- * @param out The matrix to store the result in.
74
+ * Create a transformation matrix that represents a scaling by the given vector.
75
+ * @param vector - The scaling vector.
76
+ * @param out - The matrix to store the result in.
56
77
  * @returns The transformation matrix.
57
78
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
58
79
  */
59
80
  export function fromScaling<T extends Matrix3Like>(
60
81
  vector: Vector2Like,
61
82
  out: T
62
- ): T {
83
+ ) {
63
84
  out[0] = vector[0];
64
85
  out[1] = 0;
65
86
  out[2] = 0;
@@ -73,17 +94,16 @@ export function fromScaling<T extends Matrix3Like>(
73
94
  }
74
95
 
75
96
  /**
76
- * Creates a transformation matrix that represents a translation by the given
77
- * vector.
78
- * @param vector The translation vector.
79
- * @param out The matrix to store the result in.
97
+ * Create a transformation matrix that represents a translation by the given vector.
98
+ * @param vector - The translation vector.
99
+ * @param out - The matrix to store the result in.
80
100
  * @returns The transformation matrix.
81
101
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
82
102
  */
83
103
  export function fromTranslation<T extends Matrix3Like>(
84
104
  vector: Vector2Like,
85
105
  out: T
86
- ): T {
106
+ ) {
87
107
  out[0] = 1;
88
108
  out[1] = 0;
89
109
  out[2] = 0;
@@ -97,10 +117,9 @@ export function fromTranslation<T extends Matrix3Like>(
97
117
  }
98
118
 
99
119
  /**
100
- * Creates a transformation matrix that represents a rotation by the given
101
- * quaternion.
102
- * @param quaternion The quaternion.
103
- * @param out The matrix to store the result in.
120
+ * Create a transformation matrix that represents a rotation by the given quaternion.
121
+ * @param quaternion - The quaternion.
122
+ * @param out - The matrix to store the result in.
104
123
  * @returns The transformation matrix.
105
124
  * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
106
125
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
@@ -108,24 +127,24 @@ export function fromTranslation<T extends Matrix3Like>(
108
127
  export function fromQuaternion<T extends Matrix3Like>(
109
128
  quaternion: QuaternionLike,
110
129
  out: T
111
- ): T {
112
- const x: number = quaternion[0];
113
- const y: number = quaternion[1];
114
- const z: number = quaternion[2];
115
- const w: number = quaternion[3];
116
-
117
- const x2: number = x + x;
118
- const y2: number = y + y;
119
- const z2: number = z + z;
120
- const xx: number = x * x2;
121
- const yx: number = y * x2;
122
- const yy: number = y * y2;
123
- const zx: number = z * x2;
124
- const zy: number = z * y2;
125
- const zz: number = z * z2;
126
- const wx: number = w * x2;
127
- const wy: number = w * y2;
128
- const wz: number = w * z2;
130
+ ) {
131
+ const x = quaternion[0];
132
+ const y = quaternion[1];
133
+ const z = quaternion[2];
134
+ const w = quaternion[3];
135
+
136
+ const x2 = x + x;
137
+ const y2 = y + y;
138
+ const z2 = z + z;
139
+ const xx = x * x2;
140
+ const yx = y * x2;
141
+ const yy = y * y2;
142
+ const zx = z * x2;
143
+ const zy = z * y2;
144
+ const zz = z * z2;
145
+ const wx = w * x2;
146
+ const wy = w * y2;
147
+ const wz = w * z2;
129
148
 
130
149
  out[0] = 1 - yy - zz;
131
150
  out[3] = yx - wz;
@@ -140,71 +159,70 @@ export function fromQuaternion<T extends Matrix3Like>(
140
159
  }
141
160
 
142
161
  /**
143
- * Calculates a three-by-three normal (inverse transpose) matrix from a
144
- * four-by-four matrix.
145
- * @param matrix The four-by-four matrix.
146
- * @param out The matrix to store the result in.
162
+ * Calculate a three-by-three normal (inverse transpose) matrix from a four-by-four matrix.
163
+ * @param matrix - The four-by-four matrix.
164
+ * @param out - The matrix to store the result in.
147
165
  * @returns The normal matrix.
148
166
  * @see [Normal matrix](https://en.wikipedia.org/wiki/Normal_matrix)
149
167
  */
150
168
  export function normalFromMatrix4<T extends Matrix3Like>(
151
169
  matrix: Matrix4Like,
152
170
  out: T
153
- ): T {
154
- const a00: number = matrix[0];
155
- const a01: number = matrix[1];
156
- const a02: number = matrix[2];
157
- const a03: number = matrix[3];
158
- const a10: number = matrix[4];
159
- const a11: number = matrix[5];
160
- const a12: number = matrix[6];
161
- const a13: number = matrix[7];
162
- const a20: number = matrix[8];
163
- const a21: number = matrix[9];
164
- const a22: number = matrix[10];
165
- const a23: number = matrix[11];
166
- const a30: number = matrix[12];
167
- const a31: number = matrix[13];
168
- const a32: number = matrix[14];
169
- const a33: number = matrix[15];
170
-
171
- const b00: number = a00 * a11 - a01 * a10;
172
- const b01: number = a00 * a12 - a02 * a10;
173
- const b02: number = a00 * a13 - a03 * a10;
174
- const b03: number = a01 * a12 - a02 * a11;
175
- const b04: number = a01 * a13 - a03 * a11;
176
- const b05: number = a02 * a13 - a03 * a12;
177
- const b06: number = a20 * a31 - a21 * a30;
178
- const b07: number = a20 * a32 - a22 * a30;
179
- const b08: number = a20 * a33 - a23 * a30;
180
- const b09: number = a21 * a32 - a22 * a31;
181
- const b10: number = a21 * a33 - a23 * a31;
182
- const b11: number = a22 * a33 - a23 * a32;
183
-
184
- let determinant: number =
171
+ ) {
172
+ const a00 = matrix[0];
173
+ const a01 = matrix[1];
174
+ const a02 = matrix[2];
175
+ const a03 = matrix[3];
176
+ const a10 = matrix[4];
177
+ const a11 = matrix[5];
178
+ const a12 = matrix[6];
179
+ const a13 = matrix[7];
180
+ const a20 = matrix[8];
181
+ const a21 = matrix[9];
182
+ const a22 = matrix[10];
183
+ const a23 = matrix[11];
184
+ const a30 = matrix[12];
185
+ const a31 = matrix[13];
186
+ const a32 = matrix[14];
187
+ const a33 = matrix[15];
188
+
189
+ const b00 = a00 * a11 - a01 * a10;
190
+ const b01 = a00 * a12 - a02 * a10;
191
+ const b02 = a00 * a13 - a03 * a10;
192
+ const b03 = a01 * a12 - a02 * a11;
193
+ const b04 = a01 * a13 - a03 * a11;
194
+ const b05 = a02 * a13 - a03 * a12;
195
+ const b06 = a20 * a31 - a21 * a30;
196
+ const b07 = a20 * a32 - a22 * a30;
197
+ const b08 = a20 * a33 - a23 * a30;
198
+ const b09 = a21 * a32 - a22 * a31;
199
+ const b10 = a21 * a33 - a23 * a31;
200
+ const b11 = a22 * a33 - a23 * a32;
201
+
202
+ let det =
185
203
  b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
186
- if (!determinant) {
204
+ if (!det) {
187
205
  throw new SingularMatrixError();
188
206
  }
189
- determinant = 1 / determinant;
190
-
191
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * determinant;
192
- out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * determinant;
193
- out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * determinant;
194
- out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * determinant;
195
- out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * determinant;
196
- out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * determinant;
197
- out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * determinant;
198
- out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * determinant;
199
- out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * determinant;
207
+ det = 1 / det;
208
+
209
+ out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
210
+ out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
211
+ out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
212
+ out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
213
+ out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
214
+ out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
215
+ out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
216
+ out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
217
+ out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
200
218
  return out;
201
219
  }
202
220
 
203
221
  /**
204
- * Generates a two-dimensional projection matrix with the given bounds.
205
- * @param width The width of the projection.
206
- * @param height The height of the projection.
207
- * @param out The matrix to store the result in.
222
+ * Generate a two-dimensional projection matrix with the given bounds.
223
+ * @param width - The width of the projection.
224
+ * @param height - The height of the projection.
225
+ * @param out - The matrix to store the result in.
208
226
  * @returns The projection matrix.
209
227
  * @see [Camera matrix](https://en.wikipedia.org/wiki/Camera_matrix)
210
228
  * @see [3D projection](https://en.wikipedia.org/wiki/3D_projection)
@@ -213,7 +231,7 @@ export function projection<T extends Matrix3Like>(
213
231
  width: number,
214
232
  height: number,
215
233
  out: T
216
- ): T {
234
+ ) {
217
235
  out[0] = 2 / width;
218
236
  out[1] = 0;
219
237
  out[2] = 0;
@@ -227,16 +245,15 @@ export function projection<T extends Matrix3Like>(
227
245
  }
228
246
 
229
247
  /**
230
- * Creates a three-by-three matrix from the upper-left corner of a four-by-four
231
- * matrix.
232
- * @param matrix The four-by-four matrix.
233
- * @param out The matrix to store the result in.
248
+ * Create a three-by-three matrix from the upper-left corner of a four-by-four matrix.
249
+ * @param matrix - The four-by-four matrix.
250
+ * @param out - The matrix to store the result in.
234
251
  * @returns The three-by-three matrix.
235
252
  */
236
253
  export function fromMatrix4<T extends Matrix3Like>(
237
254
  matrix: Matrix4Like,
238
255
  out: T
239
- ): T {
256
+ ) {
240
257
  out[0] = matrix[0];
241
258
  out[1] = matrix[1];
242
259
  out[2] = matrix[2];
@@ -250,17 +267,17 @@ export function fromMatrix4<T extends Matrix3Like>(
250
267
  }
251
268
 
252
269
  /**
253
- * Creates a two-by-two matrix with the given values.
254
- * @param c0r0 The value in the first column and first row.
255
- * @param c0r1 The value in the first column and second row.
256
- * @param c0r2 The value in the first column and third row.
257
- * @param c1r0 The value in the second column and first row.
258
- * @param c1r1 The value in the second column and second row.
259
- * @param c1r2 The value in the second column and third row.
260
- * @param c2r0 The value in the third column and first row.
261
- * @param c2r1 The value in the third column and second row.
262
- * @param c2r2 The value in the third column and third row.
263
- * @param out The matrix to store the result in.
270
+ * Create a two-by-two matrix with the given values.
271
+ * @param c0r0 - The value in the first column and first row.
272
+ * @param c0r1 - The value in the first column and second row.
273
+ * @param c0r2 - The value in the first column and third row.
274
+ * @param c1r0 - The value in the second column and first row.
275
+ * @param c1r1 - The value in the second column and second row.
276
+ * @param c1r2 - The value in the second column and third row.
277
+ * @param c2r0 - The value in the third column and first row.
278
+ * @param c2r1 - The value in the third column and second row.
279
+ * @param c2r2 - The value in the third column and third row.
280
+ * @param out - The matrix to store the result in.
264
281
  * @returns The matrix.
265
282
  */
266
283
  export function fromValues<T extends Matrix3Like>(
@@ -274,7 +291,7 @@ export function fromValues<T extends Matrix3Like>(
274
291
  c2r1: number,
275
292
  c2r2: number,
276
293
  out: T
277
- ): T {
294
+ ) {
278
295
  out[0] = c0r0;
279
296
  out[1] = c0r1;
280
297
  out[2] = c0r2;
@@ -288,31 +305,31 @@ export function fromValues<T extends Matrix3Like>(
288
305
  }
289
306
 
290
307
  /**
291
- * Determines whether two matrices are roughly equivalent.
292
- * @param a The first matrix.
293
- * @param b The second matrix.
294
- * @returns Whether the matrices are equivalent.
308
+ * Determine whether or not two matrices are roughly equivalent.
309
+ * @param a - The first matrix.
310
+ * @param b - The second matrix.
311
+ * @returns Whether or not the matrices are equivalent.
295
312
  */
296
- export function equals(a: Matrix3Like, b: Matrix3Like): boolean {
297
- const a0: number = a[0];
298
- const a1: number = a[1];
299
- const a2: number = a[2];
300
- const a3: number = a[3];
301
- const a4: number = a[4];
302
- const a5: number = a[5];
303
- const a6: number = a[6];
304
- const a7: number = a[7];
305
- const a8: number = a[8];
306
-
307
- const b0: number = b[0];
308
- const b1: number = b[1];
309
- const b2: number = b[2];
310
- const b3: number = b[3];
311
- const b4: number = b[4];
312
- const b5: number = b[5];
313
- const b6: number = b[6];
314
- const b7: number = b[7];
315
- const b8: number = b[8];
313
+ export function equals(a: Matrix3Like, b: Matrix3Like) {
314
+ const a0 = a[0];
315
+ const a1 = a[1];
316
+ const a2 = a[2];
317
+ const a3 = a[3];
318
+ const a4 = a[4];
319
+ const a5 = a[5];
320
+ const a6 = a[6];
321
+ const a7 = a[7];
322
+ const a8 = a[8];
323
+
324
+ const b0 = b[0];
325
+ const b1 = b[1];
326
+ const b2 = b[2];
327
+ const b3 = b[3];
328
+ const b4 = b[4];
329
+ const b5 = b[5];
330
+ const b6 = b[6];
331
+ const b7 = b[7];
332
+ const b8 = b[8];
316
333
 
317
334
  return (
318
335
  Math.abs(a0 - b0) <= epsilon * Math.max(1, Math.abs(a0), Math.abs(b0)) &&
@@ -328,30 +345,30 @@ export function equals(a: Matrix3Like, b: Matrix3Like): boolean {
328
345
  }
329
346
 
330
347
  /**
331
- * Determines whether two matrices are exactly equivalent.
332
- * @param a The first matrix.
333
- * @param b The second matrix.
334
- * @returns Whether the matrices are equivalent.
348
+ * Determine whether or not two matrices are exactly equivalent.
349
+ * @param a - The first matrix.
350
+ * @param b - The second matrix.
351
+ * @returns Whether or not the matrices are equivalent.
335
352
  */
336
- export function exactEquals(a: Matrix3Like, b: Matrix3Like): boolean {
353
+ export function exactEquals(a: Matrix3Like, b: Matrix3Like) {
337
354
  return (
338
- a[0] == b[0] &&
339
- a[1] == b[1] &&
340
- a[2] == b[2] &&
341
- a[3] == b[3] &&
342
- a[4] == b[4] &&
343
- a[5] == b[5] &&
344
- a[6] == b[6] &&
345
- a[7] == b[7] &&
346
- a[8] == b[8]
355
+ a[0] === b[0] &&
356
+ a[1] === b[1] &&
357
+ a[2] === b[2] &&
358
+ a[3] === b[3] &&
359
+ a[4] === b[4] &&
360
+ a[5] === b[5] &&
361
+ a[6] === b[6] &&
362
+ a[7] === b[7] &&
363
+ a[8] === b[8]
347
364
  );
348
365
  }
349
366
 
350
367
  /**
351
- * Adds two matrices.
352
- * @param a The augend.
353
- * @param b The addend.
354
- * @param out The matrix to store the result in.
368
+ * Add two matrices.
369
+ * @param a - The augend.
370
+ * @param b - The addend.
371
+ * @param out - The matrix to store the result in.
355
372
  * @returns The sum.
356
373
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
357
374
  */
@@ -359,7 +376,7 @@ export function add<T extends Matrix3Like>(
359
376
  a: Matrix3Like,
360
377
  b: Matrix3Like,
361
378
  out: T
362
- ): T {
379
+ ) {
363
380
  out[0] = a[0] + b[0];
364
381
  out[1] = a[1] + b[1];
365
382
  out[2] = a[2] + b[2];
@@ -373,22 +390,22 @@ export function add<T extends Matrix3Like>(
373
390
  }
374
391
 
375
392
  /**
376
- * Calculates the adjugate of a matrix.
377
- * @param matrix The matrix.
378
- * @param out The matrix to store the result in.
393
+ * Calculate the adjugate of a matrix.
394
+ * @param matrix - The matrix.
395
+ * @param out - The matrix to store the result in.
379
396
  * @returns The adjugate of the matrix.
380
397
  * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
381
398
  */
382
- export function adjoint<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T {
383
- const a00: number = matrix[0];
384
- const a01: number = matrix[1];
385
- const a02: number = matrix[2];
386
- const a10: number = matrix[3];
387
- const a11: number = matrix[4];
388
- const a12: number = matrix[5];
389
- const a20: number = matrix[6];
390
- const a21: number = matrix[7];
391
- const a22: number = matrix[8];
399
+ export function adjoint<T extends Matrix3Like>(matrix: Matrix3Like, out: T) {
400
+ const a00 = matrix[0];
401
+ const a01 = matrix[1];
402
+ const a02 = matrix[2];
403
+ const a10 = matrix[3];
404
+ const a11 = matrix[4];
405
+ const a12 = matrix[5];
406
+ const a20 = matrix[6];
407
+ const a21 = matrix[7];
408
+ const a22 = matrix[8];
392
409
 
393
410
  out[0] = a11 * a22 - a12 * a21;
394
411
  out[1] = a02 * a21 - a01 * a22;
@@ -403,12 +420,12 @@ export function adjoint<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T {
403
420
  }
404
421
 
405
422
  /**
406
- * Copies the values of one matrix into another.
407
- * @param matrix The matrix to copy.
408
- * @param out The matrix to store the result in.
423
+ * Copy the values of one matrix into another.
424
+ * @param matrix - The matrix to copy.
425
+ * @param out - The matrix to store the result in.
409
426
  * @returns This matrix.
410
427
  */
411
- export function copy<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T {
428
+ export function copy<T extends Matrix3Like>(matrix: Matrix3Like, out: T) {
412
429
  out[0] = matrix[0];
413
430
  out[1] = matrix[1];
414
431
  out[2] = matrix[2];
@@ -422,30 +439,30 @@ export function copy<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T {
422
439
  }
423
440
 
424
441
  /**
425
- * Calculates the Frobenius norm of a matrix.
426
- * @param matrix The matrix.
442
+ * Calculate the Frobenius norm of a matrix.
443
+ * @param matrix - The matrix.
427
444
  * @returns The Frobenius norm.
428
445
  * @see [Matrix norm](https://en.wikipedia.org/wiki/Matrix_norm)
429
446
  */
430
- export function frob(matrix: Matrix3Like): number {
447
+ export function frob(matrix: Matrix3Like) {
431
448
  return Math.hypot(
432
- matrix[0] as number,
433
- matrix[1] as number,
434
- matrix[2] as number,
435
- matrix[3] as number,
436
- matrix[4] as number,
437
- matrix[5] as number,
438
- matrix[6] as number,
439
- matrix[7] as number,
440
- matrix[8] as number
449
+ matrix[0],
450
+ matrix[1],
451
+ matrix[2],
452
+ matrix[3],
453
+ matrix[4],
454
+ matrix[5],
455
+ matrix[6],
456
+ matrix[7],
457
+ matrix[8]
441
458
  );
442
459
  }
443
460
 
444
461
  /**
445
- * Multiplies two matrices.
446
- * @param a The multiplicand.
447
- * @param b The multiplier.
448
- * @param out The matrix to store the result in.
462
+ * Multiply two matrices.
463
+ * @param a - The multiplicand.
464
+ * @param b - The multiplier.
465
+ * @param out - The matrix to store the result in.
449
466
  * @returns The product of the matrices.
450
467
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
451
468
  */
@@ -453,26 +470,26 @@ export function multiply<T extends Matrix3Like>(
453
470
  a: Matrix3Like,
454
471
  b: Matrix3Like,
455
472
  out: T
456
- ): T {
457
- const a00: number = a[0];
458
- const a01: number = a[1];
459
- const a02: number = a[2];
460
- const a10: number = a[3];
461
- const a11: number = a[4];
462
- const a12: number = a[5];
463
- const a20: number = a[6];
464
- const a21: number = a[7];
465
- const a22: number = a[8];
466
-
467
- const b00: number = b[0];
468
- const b01: number = b[1];
469
- const b02: number = b[2];
470
- const b10: number = b[3];
471
- const b11: number = b[4];
472
- const b12: number = b[5];
473
- const b20: number = b[6];
474
- const b21: number = b[7];
475
- const b22: number = b[8];
473
+ ) {
474
+ const a00 = a[0];
475
+ const a01 = a[1];
476
+ const a02 = a[2];
477
+ const a10 = a[3];
478
+ const a11 = a[4];
479
+ const a12 = a[5];
480
+ const a20 = a[6];
481
+ const a21 = a[7];
482
+ const a22 = a[8];
483
+
484
+ const b00 = b[0];
485
+ const b01 = b[1];
486
+ const b02 = b[2];
487
+ const b10 = b[3];
488
+ const b11 = b[4];
489
+ const b12 = b[5];
490
+ const b20 = b[6];
491
+ const b21 = b[7];
492
+ const b22 = b[8];
476
493
 
477
494
  out[0] = b00 * a00 + b01 * a10 + b02 * a20;
478
495
  out[1] = b00 * a01 + b01 * a11 + b02 * a21;
@@ -487,10 +504,10 @@ export function multiply<T extends Matrix3Like>(
487
504
  }
488
505
 
489
506
  /**
490
- * Multiplies a matrix by a scalar value.
491
- * @param matrix The multiplicand.
492
- * @param scalar The multiplier.
493
- * @param out The matrix to store the result in.
507
+ * Multiply a matrix by a scalar value.
508
+ * @param matrix - The multiplicand.
509
+ * @param scalar - The multiplier.
510
+ * @param out - The matrix to store the result in.
494
511
  * @returns The product.
495
512
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
496
513
  */
@@ -498,7 +515,7 @@ export function multiplyScalar<T extends Matrix3Like>(
498
515
  matrix: Matrix3Like,
499
516
  scalar: number,
500
517
  out: T
501
- ): T {
518
+ ) {
502
519
  out[0] = matrix[0] * scalar;
503
520
  out[1] = matrix[1] * scalar;
504
521
  out[2] = matrix[2] * scalar;
@@ -512,11 +529,11 @@ export function multiplyScalar<T extends Matrix3Like>(
512
529
  }
513
530
 
514
531
  /**
515
- * Adds a matrix to another after multiplying the other by a scalar.
516
- * @param a The augend.
517
- * @param b The addend.
518
- * @param scalar The multiplier.
519
- * @param out The matrix to store the result in.
532
+ * Add a matrix to another after multiplying the other by a scalar.
533
+ * @param a - The augend.
534
+ * @param b - The addend.
535
+ * @param scalar - The multiplier.
536
+ * @param out - The matrix to store the result in.
520
537
  * @returns The sum.
521
538
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
522
539
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
@@ -526,7 +543,7 @@ export function multiplyScalarAndAdd<T extends Matrix3Like>(
526
543
  b: Matrix3Like,
527
544
  scalar: number,
528
545
  out: T
529
- ): T {
546
+ ) {
530
547
  out[0] = a[0] + b[0] * scalar;
531
548
  out[1] = a[1] + b[1] * scalar;
532
549
  out[2] = a[2] + b[2] * scalar;
@@ -540,10 +557,10 @@ export function multiplyScalarAndAdd<T extends Matrix3Like>(
540
557
  }
541
558
 
542
559
  /**
543
- * Subtracts two matrices.
544
- * @param a The minuend.
545
- * @param b The subtrahend.
546
- * @param out The matrix to store the result in.
560
+ * Subtract two matrices.
561
+ * @param a - The minuend.
562
+ * @param b - The subtrahend.
563
+ * @param out - The matrix to store the result in.
547
564
  * @returns The difference.
548
565
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
549
566
  */
@@ -551,7 +568,7 @@ export function subtract<T extends Matrix3Like>(
551
568
  a: Matrix3Like,
552
569
  b: Matrix3Like,
553
570
  out: T
554
- ): T {
571
+ ) {
555
572
  out[0] = a[0] - b[0];
556
573
  out[1] = a[1] - b[1];
557
574
  out[2] = a[2] - b[2];
@@ -565,20 +582,17 @@ export function subtract<T extends Matrix3Like>(
565
582
  }
566
583
 
567
584
  /**
568
- * Transposes a matrix.
569
- * @param matrix The matrix.
570
- * @param out The matrix to store the result in.
585
+ * Transpose a matrix.
586
+ * @param matrix - The matrix.
587
+ * @param out - The matrix to store the result in.
571
588
  * @returns The transpose of the matrix.
572
589
  * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
573
590
  */
574
- export function transpose<T extends Matrix3Like>(
575
- matrix: Matrix3Like,
576
- out: T
577
- ): T {
578
- if (out == (matrix as unknown as T)) {
579
- const a01: number = matrix[1];
580
- const a02: number = matrix[2];
581
- const a12: number = matrix[5];
591
+ export function transpose<T extends Matrix3Like>(matrix: Matrix3Like, out: T) {
592
+ if (out === matrix) {
593
+ const a01 = matrix[1];
594
+ const a02 = matrix[2];
595
+ const a12 = matrix[5];
582
596
  out[1] = matrix[3];
583
597
  out[2] = matrix[6];
584
598
  out[3] = a01;
@@ -600,21 +614,21 @@ export function transpose<T extends Matrix3Like>(
600
614
  }
601
615
 
602
616
  /**
603
- * Calculates the determinant of a matrix.
604
- * @param matrix The matrix.
617
+ * Calculate the determinant of a matrix.
618
+ * @param matrix - The matrix.
605
619
  * @returns The determinant.
606
620
  * @see [Determinant](https://en.wikipedia.org/wiki/Determinant)
607
621
  */
608
- export function determinant(matrix: Matrix3Like): number {
609
- const a00: number = matrix[0];
610
- const a01: number = matrix[1];
611
- const a02: number = matrix[2];
612
- const a10: number = matrix[3];
613
- const a11: number = matrix[4];
614
- const a12: number = matrix[5];
615
- const a20: number = matrix[6];
616
- const a21: number = matrix[7];
617
- const a22: number = matrix[8];
622
+ export function determinant(matrix: Matrix3Like) {
623
+ const a00 = matrix[0];
624
+ const a01 = matrix[1];
625
+ const a02 = matrix[2];
626
+ const a10 = matrix[3];
627
+ const a11 = matrix[4];
628
+ const a12 = matrix[5];
629
+ const a20 = matrix[6];
630
+ const a21 = matrix[7];
631
+ const a22 = matrix[8];
618
632
 
619
633
  return (
620
634
  a00 * (a22 * a11 - a12 * a21) +
@@ -624,12 +638,12 @@ export function determinant(matrix: Matrix3Like): number {
624
638
  }
625
639
 
626
640
  /**
627
- * Resets a matrix to identity.
628
- * @param out The matrix to store the result in.
641
+ * Reset a matrix to identity.
642
+ * @param out - The matrix to store the result in.
629
643
  * @returns The matrix.
630
644
  * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
631
645
  */
632
- export function identity<T extends Matrix3Like>(out: T): T {
646
+ export function identity<T extends Matrix3Like>(out: T) {
633
647
  out[0] = 1;
634
648
  out[1] = 0;
635
649
  out[2] = 0;
@@ -643,50 +657,50 @@ export function identity<T extends Matrix3Like>(out: T): T {
643
657
  }
644
658
 
645
659
  /**
646
- * Inverts a matrix.
647
- * @param matrix The matrix.
648
- * @param out The matrix to store the result in.
660
+ * Invert a matrix.
661
+ * @param matrix - The matrix.
662
+ * @param out - The matrix to store the result in.
649
663
  * @returns The inverted matrix.
650
664
  * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
651
665
  */
652
- export function invert<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T {
653
- const a00: number = matrix[0];
654
- const a01: number = matrix[1];
655
- const a02: number = matrix[2];
656
- const a10: number = matrix[3];
657
- const a11: number = matrix[4];
658
- const a12: number = matrix[5];
659
- const a20: number = matrix[6];
660
- const a21: number = matrix[7];
661
- const a22: number = matrix[8];
662
-
663
- const b01: number = a22 * a11 - a12 * a21;
664
- const b11: number = -a22 * a10 + a12 * a20;
665
- const b21: number = a21 * a10 - a11 * a20;
666
-
667
- let determinant: number = a00 * b01 + a01 * b11 + a02 * b21;
668
- if (!determinant) {
666
+ export function invert<T extends Matrix3Like>(matrix: Matrix3Like, out: T) {
667
+ const a00 = matrix[0];
668
+ const a01 = matrix[1];
669
+ const a02 = matrix[2];
670
+ const a10 = matrix[3];
671
+ const a11 = matrix[4];
672
+ const a12 = matrix[5];
673
+ const a20 = matrix[6];
674
+ const a21 = matrix[7];
675
+ const a22 = matrix[8];
676
+
677
+ const b01 = a22 * a11 - a12 * a21;
678
+ const b11 = -a22 * a10 + a12 * a20;
679
+ const b21 = a21 * a10 - a11 * a20;
680
+
681
+ let det = a00 * b01 + a01 * b11 + a02 * b21;
682
+ if (!det) {
669
683
  throw new SingularMatrixError();
670
684
  }
671
- determinant = 1 / determinant;
672
-
673
- out[0] = b01 * determinant;
674
- out[1] = (-a22 * a01 + a02 * a21) * determinant;
675
- out[2] = (a12 * a01 - a02 * a11) * determinant;
676
- out[3] = b11 * determinant;
677
- out[4] = (a22 * a00 - a02 * a20) * determinant;
678
- out[5] = (-a12 * a00 + a02 * a10) * determinant;
679
- out[6] = b21 * determinant;
680
- out[7] = (-a21 * a00 + a01 * a20) * determinant;
681
- out[8] = (a11 * a00 - a01 * a10) * determinant;
685
+ det = 1 / det;
686
+
687
+ out[0] = b01 * det;
688
+ out[1] = (-a22 * a01 + a02 * a21) * det;
689
+ out[2] = (a12 * a01 - a02 * a11) * det;
690
+ out[3] = b11 * det;
691
+ out[4] = (a22 * a00 - a02 * a20) * det;
692
+ out[5] = (-a12 * a00 + a02 * a10) * det;
693
+ out[6] = b21 * det;
694
+ out[7] = (-a21 * a00 + a01 * a20) * det;
695
+ out[8] = (a11 * a00 - a01 * a10) * det;
682
696
  return out;
683
697
  }
684
698
 
685
699
  /**
686
- * Rotates a matrix by the given angle around the Z-axis.
687
- * @param matrix The matrix.
688
- * @param radians The angle in radians.
689
- * @param out The matrix to store the result in.
700
+ * Rotate a matrix by the given angle around the Z-axis.
701
+ * @param matrix - The matrix.
702
+ * @param radians - The angle in radians.
703
+ * @param out - The matrix to store the result in.
690
704
  * @returns The rotated matrix.
691
705
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
692
706
  */
@@ -694,19 +708,19 @@ export function rotate<T extends Matrix3Like>(
694
708
  matrix: Matrix3Like,
695
709
  radians: number,
696
710
  out: T
697
- ): T {
698
- const a00: number = matrix[0];
699
- const a01: number = matrix[1];
700
- const a02: number = matrix[2];
701
- const a10: number = matrix[3];
702
- const a11: number = matrix[4];
703
- const a12: number = matrix[5];
704
- const a20: number = matrix[6];
705
- const a21: number = matrix[7];
706
- const a22: number = matrix[8];
707
-
708
- const s: number = Math.sin(radians);
709
- const c: number = Math.cos(radians);
711
+ ) {
712
+ const a00 = matrix[0];
713
+ const a01 = matrix[1];
714
+ const a02 = matrix[2];
715
+ const a10 = matrix[3];
716
+ const a11 = matrix[4];
717
+ const a12 = matrix[5];
718
+ const a20 = matrix[6];
719
+ const a21 = matrix[7];
720
+ const a22 = matrix[8];
721
+
722
+ const s = Math.sin(radians);
723
+ const c = Math.cos(radians);
710
724
 
711
725
  out[0] = c * a00 + s * a10;
712
726
  out[1] = c * a01 + s * a11;
@@ -721,10 +735,10 @@ export function rotate<T extends Matrix3Like>(
721
735
  }
722
736
 
723
737
  /**
724
- * Scales a matrix by the given vector.
725
- * @param matrix The matrix.
726
- * @param vector The scaling vector.
727
- * @param out The matrix to store the result in.
738
+ * Scale a matrix by the given vector.
739
+ * @param matrix - The matrix.
740
+ * @param vector - The scaling vector.
741
+ * @param out - The matrix to store the result in.
728
742
  * @returns The scaled matrix.
729
743
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
730
744
  */
@@ -732,9 +746,9 @@ export function scale<T extends Matrix3Like>(
732
746
  matrix: Matrix3Like,
733
747
  vector: Vector2Like,
734
748
  out: T
735
- ): T {
736
- const x: number = vector[0];
737
- const y: number = vector[1];
749
+ ) {
750
+ const x = vector[0];
751
+ const y = vector[1];
738
752
 
739
753
  out[0] = matrix[0] * x;
740
754
  out[1] = matrix[1] * x;
@@ -749,10 +763,10 @@ export function scale<T extends Matrix3Like>(
749
763
  }
750
764
 
751
765
  /**
752
- * Translates a matrix by the given vector.
753
- * @param matrix The matrix.
754
- * @param vector The translation vector.
755
- * @param out The matrix to store the result in.
766
+ * Translate a matrix by the given vector.
767
+ * @param matrix - The matrix.
768
+ * @param vector - The translation vector.
769
+ * @param out - The matrix to store the result in.
756
770
  * @returns The translated matrix.
757
771
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
758
772
  */
@@ -760,19 +774,19 @@ export function translate<T extends Matrix3Like>(
760
774
  matrix: Matrix3Like,
761
775
  vector: Vector2Like,
762
776
  out: T
763
- ): T {
764
- const a00: number = matrix[0];
765
- const a01: number = matrix[1];
766
- const a02: number = matrix[2];
767
- const a10: number = matrix[3];
768
- const a11: number = matrix[4];
769
- const a12: number = matrix[5];
770
- const a20: number = matrix[6];
771
- const a21: number = matrix[7];
772
- const a22: number = matrix[8];
773
-
774
- const x: number = vector[0];
775
- const y: number = vector[1];
777
+ ) {
778
+ const a00 = matrix[0];
779
+ const a01 = matrix[1];
780
+ const a02 = matrix[2];
781
+ const a10 = matrix[3];
782
+ const a11 = matrix[4];
783
+ const a12 = matrix[5];
784
+ const a20 = matrix[6];
785
+ const a21 = matrix[7];
786
+ const a22 = matrix[8];
787
+
788
+ const x = vector[0];
789
+ const y = vector[1];
776
790
 
777
791
  out[0] = a00;
778
792
  out[1] = a01;
@@ -790,166 +804,86 @@ export function translate<T extends Matrix3Like>(
790
804
  * A three-by-three matrix.
791
805
  * @see [Matrix](https://en.wikipedia.org/wiki/Matrix_(mathematics))
792
806
  */
793
- export default class Matrix3 extends Float32Array implements SquareMatrix {
807
+ export default class Matrix3
808
+ extends Float32Array
809
+ implements SquareMatrix, Matrix3Like
810
+ {
794
811
  /**
795
- * Creates a transformation matrix that represents a rotation by the given
796
- * angle around the Z-axis.
797
- * @param radians The angle in radians.
812
+ * Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
813
+ * @param r - The angle in radians.
814
+ * @param out - The matrix to store the result in.
798
815
  * @returns The transformation matrix.
799
816
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
800
817
  */
801
- public static fromRotation(radians: number): Matrix3;
802
-
803
- /**
804
- * Creates a transformation matrix that represents a rotation by the given
805
- * angle around the Z-axis.
806
- * @param radians The angle in radians.
807
- * @param out The matrix to store the result in.
808
- * @returns The transformation matrix.
809
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
810
- */
811
- public static fromRotation<T extends Matrix3Like>(radians: number, out: T): T;
812
-
813
818
  public static fromRotation<T extends Matrix3Like>(
814
- radians: number,
815
- out: T = new Matrix3() as T
816
- ): T {
817
- return fromRotation(radians, out);
819
+ r: number,
820
+ out = new Matrix3() as unknown as T
821
+ ) {
822
+ return fromRotation(r, out);
818
823
  }
819
824
 
820
825
  /**
821
- * Creates a transformation matrix that represents a scaling by the given
822
- * vector.
823
- * @param vector The scaling vector.
824
- * @returns The transformation matrix.
825
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
826
- */
827
- public static fromScaling(vector: Vector2Like): Matrix3;
828
-
829
- /**
830
- * Creates a transformation matrix that represents a scaling by the given
831
- * vector.
832
- * @param vector The scaling vector.
833
- * @param out The matrix to store the result in.
826
+ * Create a transformation matrix that represents a scaling by the given vector.
827
+ * @param vector - The scaling vector.
828
+ * @param out - The matrix to store the result in.
834
829
  * @returns The transformation matrix.
835
830
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
836
831
  */
837
832
  public static fromScaling<T extends Matrix3Like>(
838
833
  vector: Vector2Like,
839
- out: T
840
- ): T;
841
-
842
- public static fromScaling<T extends Matrix3Like>(
843
- vector: Vector2Like,
844
- out: T = new Matrix3() as T
845
- ): T {
834
+ out = new Matrix3() as unknown as T
835
+ ) {
846
836
  return fromScaling(vector, out);
847
837
  }
848
838
 
849
839
  /**
850
- * Creates a transformation matrix that represents a translation by the
851
- * given vector.
852
- * @param vector The translation vector.
840
+ * Create a transformation matrix that represents a translation by the given vector.
841
+ * @param vector - The translation vector.
842
+ * @param out - The matrix to store the result in.
853
843
  * @returns The transformation matrix.
854
844
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
855
845
  */
856
- public static fromTranslation(vector: Vector2Like): Matrix3;
857
-
858
- /**
859
- * Creates a transformation matrix that represents a translation by the
860
- * given vector.
861
- * @param vector The translation vector.
862
- * @param out The matrix to store the result in.
863
- * @returns The transformation matrix.
864
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
865
- */
866
- public static fromTranslation<T extends Matrix3Like>(
867
- vector: Vector2Like,
868
- out: T
869
- ): T;
870
-
871
846
  public static fromTranslation<T extends Matrix3Like>(
872
847
  vector: Vector2Like,
873
- out: T = new Matrix3() as T
874
- ): T {
848
+ out = new Matrix3() as unknown as T
849
+ ) {
875
850
  return fromTranslation(vector, out);
876
851
  }
877
852
 
878
853
  /**
879
- * Creates a transformation matrix that represents a rotation by the given
880
- * quaternion.
881
- * @param quaternion The quaternion.
854
+ * Create a transformation matrix that represents a rotation by the given quaternion.
855
+ * @param quaternion - The quaternion.
856
+ * @param out - The matrix to store the result in.
882
857
  * @returns The transformation matrix.
883
858
  * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
884
859
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
885
860
  */
886
- public static fromQuaternion(quaternion: QuaternionLike): Matrix3;
887
-
888
- /**
889
- * Creates a transformation matrix that represents a rotation by the given
890
- * quaternion.
891
- * @param quaternion The quaternion.
892
- * @param out The matrix to store the result in.
893
- * @returns The transformation matrix.
894
- * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
895
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
896
- */
897
- public static fromQuaternion<T extends Matrix3Like>(
898
- quaternion: QuaternionLike,
899
- out: T
900
- ): T;
901
-
902
861
  public static fromQuaternion<T extends Matrix3Like>(
903
862
  quaternion: QuaternionLike,
904
- out: T = new Matrix3() as T
905
- ): T {
863
+ out = new Matrix3() as unknown as T
864
+ ) {
906
865
  return fromQuaternion(quaternion, out);
907
866
  }
908
867
 
909
868
  /**
910
- * Calculates a three-by-three normal (inverse transpose) matrix from a
911
- * four-by-four matrix.
912
- * @param matrix The four-by-four matrix.
913
- * @returns The normal matrix.
914
- * @see [Normal matrix](https://en.wikipedia.org/wiki/Normal_matrix)
915
- */
916
- public static normalFromMatrix4(matrix: Matrix4Like): Matrix3;
917
-
918
- /**
919
- * Calculates a three-by-three normal (inverse transpose) matrix from a
920
- * four-by-four matrix.
921
- * @param matrix The four-by-four matrix.
922
- * @param out The matrix to store the result in.
869
+ * Calculate a three-by-three normal (inverse transpose) matrix from a four-by-four matrix.
870
+ * @param matrix - The four-by-four matrix.
871
+ * @param out - The matrix to store the result in.
923
872
  * @returns The normal matrix.
924
873
  * @see [Normal matrix](https://en.wikipedia.org/wiki/Normal_matrix)
925
874
  */
926
875
  public static normalFromMatrix4<T extends Matrix3Like>(
927
876
  matrix: Matrix4Like,
928
- out: T
929
- ): T;
930
-
931
- public static normalFromMatrix4<T extends Matrix3Like>(
932
- matrix: Matrix4Like,
933
- out: T = new Matrix3() as T
934
- ): T {
877
+ out = new Matrix3() as unknown as T
878
+ ) {
935
879
  return normalFromMatrix4(matrix, out);
936
880
  }
937
881
 
938
882
  /**
939
- * Generates a two-dimensional projection matrix with the given bounds.
940
- * @param width The width of the projection.
941
- * @param height The height of the projection.
942
- * @returns The projection matrix.
943
- * @see [Camera matrix](https://en.wikipedia.org/wiki/Camera_matrix)
944
- * @see [3D projection](https://en.wikipedia.org/wiki/3D_projection)
945
- */
946
- public static projection(width: number, height: number): Matrix3;
947
-
948
- /**
949
- * Generates a two-dimensional projection matrix with the given bounds.
950
- * @param width The width of the projection.
951
- * @param height The height of the projection.
952
- * @param out The matrix to store the result in.
883
+ * Generate a two-dimensional projection matrix with the given bounds.
884
+ * @param width - The width of the projection.
885
+ * @param height - The height of the projection.
886
+ * @param out - The matrix to store the result in.
953
887
  * @returns The projection matrix.
954
888
  * @see [Camera matrix](https://en.wikipedia.org/wiki/Camera_matrix)
955
889
  * @see [3D projection](https://en.wikipedia.org/wiki/3D_projection)
@@ -957,81 +891,36 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
957
891
  public static projection<T extends Matrix3Like>(
958
892
  width: number,
959
893
  height: number,
960
- out: T
961
- ): T;
962
-
963
- public static projection<T extends Matrix3Like>(
964
- width: number,
965
- height: number,
966
- out: T = new Matrix3() as T
967
- ): T {
894
+ out = new Matrix3() as unknown as T
895
+ ) {
968
896
  return projection(width, height, out);
969
897
  }
970
898
 
971
899
  /**
972
- * Creates a three-by-three matrix from the upper-left corner of a
973
- * four-by-four matrix.
974
- * @param matrix The four-by-four matrix.
975
- * @returns The three-by-three matrix.
976
- */
977
- public static fromMatrix4(matrix: Matrix4Like): Matrix3;
978
-
979
- /**
980
- * Creates a three-by-three matrix from the upper-left corner of a
981
- * four-by-four matrix.
982
- * @param matrix The four-by-four matrix.
983
- * @param out The matrix to store the result in.
900
+ * Create a three-by-three matrix from the upper-left corner of a four-by-four matrix.
901
+ * @param matrix - The four-by-four matrix.
902
+ * @param out - The matrix to store the result in.
984
903
  * @returns The three-by-three matrix.
985
904
  */
986
905
  public static fromMatrix4<T extends Matrix3Like>(
987
906
  matrix: Matrix4Like,
988
- out: T
989
- ): T;
990
-
991
- public static fromMatrix4<T extends Matrix3Like>(
992
- matrix: Matrix4Like,
993
- out: T = new Matrix3() as T
994
- ): T {
907
+ out = new Matrix3() as unknown as T
908
+ ) {
995
909
  return fromMatrix4(matrix, out);
996
910
  }
997
911
 
998
912
  /**
999
- * Creates a two-by-two matrix with the given values.
1000
- * @param c0r0 The value in the first column and first row.
1001
- * @param c0r1 The value in the first column and second row.
1002
- * @param c0r2 The value in the first column and third row.
1003
- * @param c1r0 The value in the second column and first row.
1004
- * @param c1r1 The value in the second column and second row.
1005
- * @param c1r2 The value in the second column and third row.
1006
- * @param c2r0 The value in the third column and first row.
1007
- * @param c2r1 The value in the third column and second row.
1008
- * @param c2r2 The value in the third column and third row.
1009
- * @returns The matrix.
1010
- */
1011
- public static fromValues(
1012
- c0r0: number,
1013
- c0r1: number,
1014
- c0r2: number,
1015
- c1r0: number,
1016
- c1r1: number,
1017
- c1r2: number,
1018
- c2r0: number,
1019
- c2r1: number,
1020
- c2r2: number
1021
- ): Matrix3;
1022
-
1023
- /**
1024
- * Creates a two-by-two matrix with the given values.
1025
- * @param c0r0 The value in the first column and first row.
1026
- * @param c0r1 The value in the first column and second row.
1027
- * @param c0r2 The value in the first column and third row.
1028
- * @param c1r0 The value in the second column and first row.
1029
- * @param c1r1 The value in the second column and second row.
1030
- * @param c1r2 The value in the second column and third row.
1031
- * @param c2r0 The value in the third column and first row.
1032
- * @param c2r1 The value in the third column and second row.
1033
- * @param c2r2 The value in the third column and third row.
1034
- * @param out The matrix to store the result in.
913
+ * Create a two-by-two matrix with the given values.
914
+ * @param c0r0 - The value in the first column and first row.
915
+ * @param c0r1 - The value in the first column and second row.
916
+ * @param c0r2 - The value in the first column and third row.
917
+ * @param c1r0 - The value in the second column and first row.
918
+ * @param c1r1 - The value in the second column and second row.
919
+ * @param c1r2 - The value in the second column and third row.
920
+ * @param c2r0 - The value in the third column and first row.
921
+ * @param c2r1 - The value in the third column and second row.
922
+ * @param c2r2 - The value in the third column and third row.
923
+ * @param out - The matrix to store the result in.
1035
924
  * @returns The matrix.
1036
925
  */
1037
926
  public static fromValues<T extends Matrix3Like>(
@@ -1044,21 +933,8 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1044
933
  c2r0: number,
1045
934
  c2r1: number,
1046
935
  c2r2: number,
1047
- out: T
1048
- ): T;
1049
-
1050
- public static fromValues<T extends Matrix3Like>(
1051
- c0r0: number,
1052
- c0r1: number,
1053
- c0r2: number,
1054
- c1r0: number,
1055
- c1r1: number,
1056
- c1r2: number,
1057
- c2r0: number,
1058
- c2r1: number,
1059
- c2r2: number,
1060
- out: T = new Matrix3() as T
1061
- ): T {
936
+ out = new Matrix3() as unknown as T
937
+ ) {
1062
938
  return fromValues(
1063
939
  c0r0,
1064
940
  c0r1,
@@ -1074,7 +950,7 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1074
950
  }
1075
951
 
1076
952
  /**
1077
- * Creates a three-by-three identity matrix.
953
+ * Create a three-by-three identity matrix.
1078
954
  * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
1079
955
  */
1080
956
  public constructor() {
@@ -1088,6 +964,33 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1088
964
  this.height = 3;
1089
965
  }
1090
966
 
967
+ /** The value in the first column and first row. */
968
+ public 0: number;
969
+
970
+ /** The value in the first column and second row. */
971
+ public 1: number;
972
+
973
+ /** The value in the first column and third row. */
974
+ public 2: number;
975
+
976
+ /** The value in the second column and first row. */
977
+ public 3: number;
978
+
979
+ /** The value in the second column and second row. */
980
+ public 4: number;
981
+
982
+ /** The value in the second column and third row. */
983
+ public 5: number;
984
+
985
+ /** The value in the third column and first row. */
986
+ public 6: number;
987
+
988
+ /** The value in the third column and second row. */
989
+ public 7: number;
990
+
991
+ /** The value in the third column and third row. */
992
+ public 8: number;
993
+
1091
994
  /** The number of columns in this matrix. */
1092
995
  public readonly width: 3;
1093
996
 
@@ -1095,163 +998,106 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1095
998
  public readonly height: 3;
1096
999
 
1097
1000
  /**
1098
- * Determines whether this matrix is roughly equivalent to another.
1099
- * @param matrix The other matrix.
1100
- * @returns Whether the matrices are equivalent.
1001
+ * Determine whether or not this matrix is roughly equivalent to another.
1002
+ * @param matrix - The other matrix.
1003
+ * @returns Whether or not the matrices are equivalent.
1101
1004
  */
1102
- public equals(matrix: Matrix3Like): boolean {
1005
+ public equals(matrix: Matrix3Like) {
1103
1006
  return equals(this, matrix);
1104
1007
  }
1105
1008
 
1106
1009
  /**
1107
- * Determines whether this matrix is exactly equivalent to another.
1108
- * @param matrix The other matrix.
1109
- * @returns Whether the matrices are equivalent.
1010
+ * Determine whether or not this matrix is exactly equivalent to another.
1011
+ * @param matrix - The other matrix.
1012
+ * @returns Whether or not the matrices are equivalent.
1110
1013
  */
1111
- public exactEquals(matrix: Matrix3Like): boolean {
1014
+ public exactEquals(matrix: Matrix3Like) {
1112
1015
  return exactEquals(this, matrix);
1113
1016
  }
1114
1017
 
1115
1018
  /**
1116
- * Adds two matrices of the same size.
1117
- * @param matrix The other matrix.
1019
+ * Add two matrices of the same size.
1020
+ * @param matrix - The other matrix.
1021
+ * @param out - The matrix to store the result in.
1118
1022
  * @returns The sum of the matrices.
1119
1023
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
1120
1024
  */
1121
- public add(matrix: Matrix3Like): Matrix3;
1122
-
1123
- /**
1124
- * Adds two matrices of the same size.
1125
- * @param matrix The other matrix.
1126
- * @param out The matrix to store the result in.
1127
- * @returns The sum of the matrices.
1128
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
1129
- */
1130
- public add<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T;
1131
-
1132
1025
  public add<T extends Matrix3Like>(
1133
1026
  matrix: Matrix3Like,
1134
- out: T = new Matrix3() as T
1135
- ): T {
1027
+ out = new Matrix3() as unknown as T
1028
+ ) {
1136
1029
  return add(this, matrix, out);
1137
1030
  }
1138
1031
 
1139
1032
  /**
1140
- * Calculates the adjugate of this matrix.
1141
- * @returns The adjugate of this matrix.
1142
- * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
1143
- */
1144
- public adjoint(): Matrix3;
1145
-
1146
- /**
1147
- * Calculates the adjugate of this matrix.
1148
- * @param out The matrix to store the result in.
1033
+ * Calculate the adjugate of this matrix.
1034
+ * @param out - The matrix to store the result in.
1149
1035
  * @returns The adjugate of this matrix.
1150
1036
  * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
1151
1037
  */
1152
- public adjoint<T extends Matrix3Like>(out: T): T;
1153
-
1154
- public adjoint<T extends Matrix3Like>(out: T = new Matrix3() as T): T {
1038
+ public adjoint<T extends Matrix3Like>(out = new Matrix3() as unknown as T) {
1155
1039
  return adjoint(this, out);
1156
1040
  }
1157
1041
 
1158
1042
  /**
1159
- * Creates a copy of this matrix.
1043
+ * Copy the values from this matrix to another one.
1044
+ * @param out - The matrix to store the result in.
1160
1045
  * @returns The copy.
1161
1046
  */
1162
- public clone(): Matrix3;
1163
-
1164
- /**
1165
- * Copies the values from this matrix to another one.
1166
- * @param out The matrix to store the result in.
1167
- * @returns The copy.
1168
- */
1169
- public clone<T extends Matrix3Like>(out: T): T;
1170
-
1171
- public clone<T extends Matrix3Like>(out: T = new Matrix3() as T): T {
1047
+ public clone<T extends Matrix3Like>(out = new Matrix3() as unknown as T) {
1172
1048
  return copy(this, out);
1173
1049
  }
1174
1050
 
1175
1051
  /**
1176
- * Copies the values of another matrix into this one.
1177
- * @param matrix The matrix to copy.
1052
+ * Copy the values of another matrix into this one.
1053
+ * @param matrix - The matrix to copy.
1178
1054
  * @returns This matrix.
1179
1055
  */
1180
- public copy(matrix: Matrix3Like): this {
1056
+ public copy(matrix: Matrix3Like) {
1181
1057
  return copy(matrix, this);
1182
1058
  }
1183
1059
 
1184
1060
  /**
1185
- * The Frobenius norm of this matrix.
1061
+ * Get the Frobenius norm of this matrix.
1186
1062
  * @see [Matrix norm](https://en.wikipedia.org/wiki/Matrix_norm)
1187
1063
  */
1188
- public get frob(): number {
1064
+ public get frob() {
1189
1065
  return frob(this);
1190
1066
  }
1191
1067
 
1192
1068
  /**
1193
- * Multiplies this matrix by another.
1194
- * @param matrix The other matrix.
1195
- * @returns The product of the matrices.
1196
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
1197
- */
1198
- public multiply(matrix: Matrix3Like): Matrix3;
1199
-
1200
- /**
1201
- * Multiplies this matrix by another.
1202
- * @param matrix The other matrix.
1203
- * @param out The matrix to store the result in.
1069
+ * Multiply this matrix by another.
1070
+ * @param matrix - The other matrix.
1071
+ * @param out - The matrix to store the result in.
1204
1072
  * @returns The product of the matrices.
1205
1073
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
1206
1074
  */
1207
- public multiply<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T;
1208
-
1209
1075
  public multiply<T extends Matrix3Like>(
1210
1076
  matrix: Matrix3Like,
1211
- out: T = new Matrix3() as T
1212
- ): T {
1077
+ out = new Matrix3() as unknown as T
1078
+ ) {
1213
1079
  return multiply(this, matrix, out);
1214
1080
  }
1215
1081
 
1216
1082
  /**
1217
- * Multiplies this matrix by a scalar value.
1218
- * @param scalar The scalar value.
1083
+ * Multiply this matrix by a scalar value.
1084
+ * @param scalar - The scalar value.
1085
+ * @param out - The matrix to store the result in.
1219
1086
  * @returns The product of the matrix and the scalar value.
1220
1087
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
1221
1088
  */
1222
- public multiplyScalar(scalar: number): Matrix3;
1223
-
1224
- /**
1225
- * Multiplies this matrix by a scalar value.
1226
- * @param scalar The scalar value.
1227
- * @param out The matrix to store the result in.
1228
- * @returns The product of the matrix and the scalar value.
1229
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
1230
- */
1231
- public multiplyScalar<T extends Matrix3Like>(scalar: number, out: T): T;
1232
-
1233
1089
  public multiplyScalar<T extends Matrix3Like>(
1234
1090
  scalar: number,
1235
- out: T = new Matrix3() as T
1236
- ): T {
1091
+ out = new Matrix3() as unknown as T
1092
+ ) {
1237
1093
  return multiplyScalar(this, scalar, out);
1238
1094
  }
1239
1095
 
1240
1096
  /**
1241
- * Adds this matrix to another after multiplying the other by a scalar.
1242
- * @param matrix The other matrix.
1243
- * @param scalar The scalar.
1244
- * @returns The sum.
1245
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
1246
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
1247
- */
1248
- public multiplyScalarAndAdd(matrix: Matrix3Like, scalar: number): Matrix3;
1249
-
1250
- /**
1251
- * Adds this matrix to another after multiplying the other by a scalar.
1252
- * @param matrix The other matrix.
1253
- * @param scalar The scalar.
1254
- * @param out The matrix to store the result in.
1097
+ * Add this matrix to another after multiplying the other by a scalar.
1098
+ * @param matrix - The other matrix.
1099
+ * @param scalar - The scalar.
1100
+ * @param out - The matrix to store the result in.
1255
1101
  * @returns The sum.
1256
1102
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
1257
1103
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
@@ -1259,165 +1105,101 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1259
1105
  public multiplyScalarAndAdd<T extends Matrix3Like>(
1260
1106
  matrix: Matrix3Like,
1261
1107
  scalar: number,
1262
- out: T
1263
- ): T;
1264
-
1265
- public multiplyScalarAndAdd<T extends Matrix3Like>(
1266
- matrix: Matrix3Like,
1267
- scalar: number,
1268
- out: T = new Matrix3() as T
1269
- ): T {
1108
+ out = new Matrix3() as unknown as T
1109
+ ) {
1270
1110
  return multiplyScalarAndAdd(this, matrix, scalar, out);
1271
1111
  }
1272
1112
 
1273
1113
  /**
1274
- * Subtracts another matrix from this one.
1275
- * @param matrix The other matrix.
1276
- * @returns The difference between the matrices.
1277
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
1278
- */
1279
- public subtract(matrix: Matrix3Like): Matrix3;
1280
-
1281
- /**
1282
- * Subtracts another matrix from this one.
1283
- * @param matrix The other matrix.
1284
- * @param out The matrix to store the result in.
1114
+ * Subtract another matrix from this one.
1115
+ * @param matrix - The other matrix.
1116
+ * @param out - The matrix to store the result in.
1285
1117
  * @returns The difference between the matrices.
1286
1118
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
1287
1119
  */
1288
- public subtract<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T;
1289
-
1290
1120
  public subtract<T extends Matrix3Like>(
1291
1121
  matrix: Matrix3Like,
1292
- out: T = new Matrix3() as T
1293
- ): T {
1122
+ out = new Matrix3() as unknown as T
1123
+ ) {
1294
1124
  return subtract(this, matrix, out);
1295
1125
  }
1296
1126
 
1297
1127
  /**
1298
- * Transposes this matrix.
1128
+ * Transpose this matrix.
1129
+ * @param out - The matrix to store the result in.
1299
1130
  * @returns The transpose of this matrix.
1300
1131
  * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
1301
1132
  */
1302
- public transpose(): Matrix3;
1303
-
1304
- /**
1305
- * Transposes this matrix.
1306
- * @param out The matrix to store the result in.
1307
- * @returns The transpose of this matrix.
1308
- * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
1309
- */
1310
- public transpose<T extends Matrix3Like>(out: T): T;
1311
-
1312
- public transpose<T extends Matrix3Like>(out: T = new Matrix3() as T): T {
1133
+ public transpose<T extends Matrix3Like>(out = new Matrix3() as unknown as T) {
1313
1134
  return transpose(this, out);
1314
1135
  }
1315
1136
 
1316
1137
  /**
1317
- * The determinant of this matrix.
1138
+ * Get the determinant of this matrix.
1318
1139
  * @see [Determinant](https://en.wikipedia.org/wiki/Determinant)
1319
1140
  */
1320
- public get determinant(): number {
1141
+ public get determinant() {
1321
1142
  return determinant(this);
1322
1143
  }
1323
1144
 
1324
1145
  /**
1325
- * Resets this matrix to identity.
1146
+ * Reset this matrix to identity.
1326
1147
  * @returns This matrix.
1327
1148
  * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
1328
1149
  */
1329
- public identity(): this {
1150
+ public identity() {
1330
1151
  return identity(this);
1331
1152
  }
1332
1153
 
1333
1154
  /**
1334
- * Inverts this matrix.
1335
- * @returns The inverted matrix.
1336
- * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
1337
- */
1338
- public invert(): Matrix3;
1339
-
1340
- /**
1341
- * Inverts this matrix.
1342
- * @param out The matrix to store the result in.
1155
+ * Invert this matrix.
1156
+ * @param out - The matrix to store the result in.
1343
1157
  * @returns The inverted matrix.
1344
1158
  * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
1345
1159
  */
1346
- public invert<T extends Matrix3Like>(out: T): T;
1347
-
1348
- public invert<T extends Matrix3Like>(out: T = new Matrix3() as T): T {
1160
+ public invert<T extends Matrix3Like>(out = new Matrix3() as unknown as T) {
1349
1161
  return invert(this, out);
1350
1162
  }
1351
1163
 
1352
1164
  /**
1353
- * Rotates this matrix by the given angle around the Z-axis.
1354
- * @param radians The angle in radians.
1165
+ * Rotate this matrix by the given angle around the Z-axis.
1166
+ * @param r - The angle in radians.
1167
+ * @param out - The matrix to store the result in.
1355
1168
  * @returns The rotated matrix.
1356
1169
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
1357
1170
  */
1358
- public rotate(radians: number): Matrix3;
1359
-
1360
- /**
1361
- * Rotates this matrix by the given angle around the Z-axis.
1362
- * @param radians The angle in radians.
1363
- * @param out The matrix to store the result in.
1364
- * @returns The rotated matrix.
1365
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
1366
- */
1367
- public rotate<T extends Matrix3Like>(radians: number, out: T): T;
1368
-
1369
1171
  public rotate<T extends Matrix3Like>(
1370
- radians: number,
1371
- out: T = new Matrix3() as T
1372
- ): T {
1373
- return rotate(this, radians, out);
1172
+ r: number,
1173
+ out = new Matrix3() as unknown as T
1174
+ ) {
1175
+ return rotate(this, r, out);
1374
1176
  }
1375
1177
 
1376
1178
  /**
1377
- * Scales this matrix by the given vector.
1378
- * @param vector The scaling vector.
1379
- * @returns The scaled matrix.
1380
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
1381
- */
1382
- public scale(vector: Vector2Like): Matrix3;
1383
-
1384
- /**
1385
- * Scales this matrix by the given vector.
1386
- * @param vector The scaling vector.
1387
- * @param out The matrix to store the result in.
1179
+ * Scale this matrix by the given vector.
1180
+ * @param vector - The scaling vector.
1181
+ * @param out - The matrix to store the result in.
1388
1182
  * @returns The scaled matrix.
1389
1183
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
1390
1184
  */
1391
- public scale<T extends Matrix3Like>(vector: Vector2Like, out: T): T;
1392
-
1393
1185
  public scale<T extends Matrix3Like>(
1394
1186
  vector: Vector2Like,
1395
- out: T = new Matrix3() as T
1396
- ): T {
1187
+ out = new Matrix3() as unknown as T
1188
+ ) {
1397
1189
  return scale(this, vector, out);
1398
1190
  }
1399
1191
 
1400
1192
  /**
1401
- * Translates this matrix by the given vector.
1402
- * @param vector The translation vector.
1193
+ * Translate this matrix by the given vector.
1194
+ * @param vector - The translation vector.
1195
+ * @param out - The matrix to store the result in.
1403
1196
  * @returns The translated matrix.
1404
1197
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
1405
1198
  */
1406
- public translate(vector: Vector2Like): Matrix3;
1407
-
1408
- /**
1409
- * Translates this matrix by the given vector.
1410
- * @param vector The translation vector.
1411
- * @param out The matrix to store the result in.
1412
- * @returns The translated matrix.
1413
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
1414
- */
1415
- public translate<T extends Matrix3Like>(vector: Vector2Like, out: T): T;
1416
-
1417
1199
  public translate<T extends Matrix3Like>(
1418
1200
  vector: Vector2Like,
1419
- out: T = new Matrix3() as T
1420
- ): T {
1201
+ out = new Matrix3() as unknown as T
1202
+ ) {
1421
1203
  return translate(this, vector, out);
1422
1204
  }
1423
1205
  }