@lakuna/umath 1.3.4 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +7 -9
  3. package/dist/algorithms/combinations.d.ts +7 -0
  4. package/dist/algorithms/combinations.d.ts.map +1 -1
  5. package/dist/algorithms/combinations.js +8 -1
  6. package/dist/algorithms/combinations.js.map +1 -1
  7. package/dist/algorithms/degreesToRadians.d.ts +7 -0
  8. package/dist/algorithms/degreesToRadians.d.ts.map +1 -1
  9. package/dist/algorithms/degreesToRadians.js +7 -0
  10. package/dist/algorithms/degreesToRadians.js.map +1 -1
  11. package/dist/algorithms/factorial.d.ts +6 -0
  12. package/dist/algorithms/factorial.d.ts.map +1 -1
  13. package/dist/algorithms/factorial.js +15 -5
  14. package/dist/algorithms/factorial.js.map +1 -1
  15. package/dist/algorithms/fibonacci.d.ts +6 -1
  16. package/dist/algorithms/fibonacci.d.ts.map +1 -1
  17. package/dist/algorithms/fibonacci.js +6 -1
  18. package/dist/algorithms/fibonacci.js.map +1 -1
  19. package/dist/algorithms/greatestCommonDivisor.d.ts +14 -0
  20. package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
  21. package/dist/algorithms/greatestCommonDivisor.js +7 -9
  22. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  23. package/dist/algorithms/hypergeometricPmf.d.ts +9 -0
  24. package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
  25. package/dist/algorithms/hypergeometricPmf.js +10 -1
  26. package/dist/algorithms/hypergeometricPmf.js.map +1 -1
  27. package/dist/algorithms/isPrime.d.ts +6 -0
  28. package/dist/algorithms/isPrime.d.ts.map +1 -1
  29. package/dist/algorithms/isPrime.js +8 -1
  30. package/dist/algorithms/isPrime.js.map +1 -1
  31. package/dist/algorithms/permutations.d.ts +7 -0
  32. package/dist/algorithms/permutations.d.ts.map +1 -1
  33. package/dist/algorithms/permutations.js +8 -1
  34. package/dist/algorithms/permutations.js.map +1 -1
  35. package/dist/algorithms/primeFactorization.d.ts +7 -1
  36. package/dist/algorithms/primeFactorization.d.ts.map +1 -1
  37. package/dist/algorithms/primeFactorization.js +10 -3
  38. package/dist/algorithms/primeFactorization.js.map +1 -1
  39. package/dist/algorithms/radiansToDegrees.d.ts +7 -0
  40. package/dist/algorithms/radiansToDegrees.d.ts.map +1 -1
  41. package/dist/algorithms/radiansToDegrees.js +7 -0
  42. package/dist/algorithms/radiansToDegrees.js.map +1 -1
  43. package/dist/algorithms/summation.d.ts +8 -0
  44. package/dist/algorithms/summation.d.ts.map +1 -1
  45. package/dist/algorithms/summation.js +9 -0
  46. package/dist/algorithms/summation.js.map +1 -1
  47. package/dist/index.d.ts +32 -33
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +27 -27
  50. package/dist/index.js.map +1 -1
  51. package/dist/linalg/DualQuaternion.d.ts +460 -83
  52. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  53. package/dist/linalg/DualQuaternion.js +514 -133
  54. package/dist/linalg/DualQuaternion.js.map +1 -1
  55. package/dist/linalg/Matrix.d.ts +80 -12
  56. package/dist/linalg/Matrix.d.ts.map +1 -1
  57. package/dist/linalg/Matrix2.d.ts +337 -52
  58. package/dist/linalg/Matrix2.d.ts.map +1 -1
  59. package/dist/linalg/Matrix2.js +345 -61
  60. package/dist/linalg/Matrix2.js.map +1 -1
  61. package/dist/linalg/Matrix3.d.ts +470 -72
  62. package/dist/linalg/Matrix3.d.ts.map +1 -1
  63. package/dist/linalg/Matrix3.js +488 -94
  64. package/dist/linalg/Matrix3.js.map +1 -1
  65. package/dist/linalg/Matrix4.d.ts +842 -137
  66. package/dist/linalg/Matrix4.d.ts.map +1 -1
  67. package/dist/linalg/Matrix4.js +896 -175
  68. package/dist/linalg/Matrix4.js.map +1 -1
  69. package/dist/linalg/Quaternion.d.ts +395 -70
  70. package/dist/linalg/Quaternion.d.ts.map +1 -1
  71. package/dist/linalg/Quaternion.js +416 -70
  72. package/dist/linalg/Quaternion.js.map +1 -1
  73. package/dist/linalg/SlowMatrix.d.ts +79 -9
  74. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  75. package/dist/linalg/SlowMatrix.js +147 -27
  76. package/dist/linalg/SlowMatrix.js.map +1 -1
  77. package/dist/linalg/SlowSquareMatrix.d.ts +58 -3
  78. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  79. package/dist/linalg/SlowSquareMatrix.js +111 -21
  80. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  81. package/dist/linalg/SquareMatrix.d.ts +26 -3
  82. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  83. package/dist/linalg/Vector.d.ts +148 -24
  84. package/dist/linalg/Vector.d.ts.map +1 -1
  85. package/dist/linalg/Vector2.d.ts +484 -84
  86. package/dist/linalg/Vector2.d.ts.map +1 -1
  87. package/dist/linalg/Vector2.js +487 -71
  88. package/dist/linalg/Vector2.js.map +1 -1
  89. package/dist/linalg/Vector3.d.ts +582 -98
  90. package/dist/linalg/Vector3.d.ts.map +1 -1
  91. package/dist/linalg/Vector3.js +625 -134
  92. package/dist/linalg/Vector3.js.map +1 -1
  93. package/dist/linalg/Vector4.d.ts +450 -75
  94. package/dist/linalg/Vector4.d.ts.map +1 -1
  95. package/dist/linalg/Vector4.js +447 -62
  96. package/dist/linalg/Vector4.js.map +1 -1
  97. package/dist/types/AxisAngle.d.ts +4 -1
  98. package/dist/types/AxisAngle.d.ts.map +1 -1
  99. package/dist/types/FieldOfView.d.ts +5 -0
  100. package/dist/types/FieldOfView.d.ts.map +1 -1
  101. package/dist/utility/BigNumber.d.ts +41 -8
  102. package/dist/utility/BigNumber.d.ts.map +1 -1
  103. package/dist/utility/BigNumber.js +47 -5
  104. package/dist/utility/BigNumber.js.map +1 -1
  105. package/dist/utility/MagnitudeError.d.ts +5 -0
  106. package/dist/utility/MagnitudeError.d.ts.map +1 -1
  107. package/dist/utility/MagnitudeError.js +6 -1
  108. package/dist/utility/MagnitudeError.js.map +1 -1
  109. package/dist/utility/MatrixSizeError.d.ts +5 -0
  110. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  111. package/dist/utility/MatrixSizeError.js +5 -0
  112. package/dist/utility/MatrixSizeError.js.map +1 -1
  113. package/dist/utility/PartialMatrixError.d.ts +5 -0
  114. package/dist/utility/PartialMatrixError.d.ts.map +1 -1
  115. package/dist/utility/PartialMatrixError.js +5 -0
  116. package/dist/utility/PartialMatrixError.js.map +1 -1
  117. package/dist/utility/SingularMatrixError.d.ts +8 -0
  118. package/dist/utility/SingularMatrixError.d.ts.map +1 -1
  119. package/dist/utility/SingularMatrixError.js +8 -0
  120. package/dist/utility/SingularMatrixError.js.map +1 -1
  121. package/dist/utility/epsilon.d.ts +1 -0
  122. package/dist/utility/epsilon.d.ts.map +1 -1
  123. package/dist/utility/epsilon.js +1 -0
  124. package/dist/utility/epsilon.js.map +1 -1
  125. package/package.json +20 -51
  126. package/src/algorithms/combinations.ts +4 -4
  127. package/src/algorithms/degreesToRadians.ts +3 -3
  128. package/src/algorithms/factorial.ts +13 -8
  129. package/src/algorithms/fibonacci.ts +3 -3
  130. package/src/algorithms/greatestCommonDivisor.ts +15 -19
  131. package/src/algorithms/hypergeometricPmf.ts +5 -6
  132. package/src/algorithms/isPrime.ts +4 -4
  133. package/src/algorithms/permutations.ts +4 -4
  134. package/src/algorithms/primeFactorization.ts +9 -9
  135. package/src/algorithms/radiansToDegrees.ts +3 -3
  136. package/src/algorithms/summation.ts +5 -5
  137. package/src/index.ts +35 -33
  138. package/src/linalg/DualQuaternion.ts +558 -804
  139. package/src/linalg/Matrix.ts +35 -36
  140. package/src/linalg/Matrix2.ts +277 -413
  141. package/src/linalg/Matrix3.ts +532 -737
  142. package/src/linalg/Matrix4.ts +1078 -1604
  143. package/src/linalg/Quaternion.ts +415 -690
  144. package/src/linalg/SlowMatrix.ts +118 -69
  145. package/src/linalg/SlowSquareMatrix.ts +85 -56
  146. package/src/linalg/SquareMatrix.ts +7 -7
  147. package/src/linalg/Vector.ts +71 -70
  148. package/src/linalg/Vector2.ts +380 -576
  149. package/src/linalg/Vector3.ts +544 -840
  150. package/src/linalg/Vector4.ts +383 -549
  151. package/src/types/AxisAngle.ts +1 -1
  152. package/src/utility/BigNumber.ts +33 -42
  153. package/src/utility/MagnitudeError.ts +4 -4
  154. package/src/utility/MatrixSizeError.ts +2 -3
  155. package/src/utility/PartialMatrixError.ts +2 -3
  156. package/src/utility/SingularMatrixError.ts +2 -2
  157. package/src/utility/epsilon.ts +1 -4
  158. package/dist/types/IntegerRepresentation.d.ts +0 -2
  159. package/dist/types/IntegerRepresentation.d.ts.map +0 -1
  160. package/dist/types/IntegerRepresentation.js +0 -2
  161. package/dist/types/IntegerRepresentation.js.map +0 -1
  162. 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;
22
- }
46
+ export const createMatrix3Like = () => {
47
+ return new Float32Array(9) as unknown as Matrix3Like;
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 const fromRotation = <T extends Matrix3Like>(r: number, out: T): 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;
@@ -46,20 +68,19 @@ export function fromRotation<T extends Matrix3Like>(
46
68
  out[7] = 0;
47
69
  out[8] = 1;
48
70
  return out;
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
- export function fromScaling<T extends Matrix3Like>(
80
+ export const fromScaling = <T extends Matrix3Like>(
60
81
  vector: Vector2Like,
61
82
  out: T
62
- ): T {
83
+ ): T => {
63
84
  out[0] = vector[0];
64
85
  out[1] = 0;
65
86
  out[2] = 0;
@@ -70,20 +91,19 @@ export function fromScaling<T extends Matrix3Like>(
70
91
  out[7] = 0;
71
92
  out[8] = 1;
72
93
  return out;
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
- export function fromTranslation<T extends Matrix3Like>(
103
+ export const fromTranslation = <T extends Matrix3Like>(
84
104
  vector: Vector2Like,
85
105
  out: T
86
- ): T {
106
+ ): T => {
87
107
  out[0] = 1;
88
108
  out[1] = 0;
89
109
  out[2] = 0;
@@ -94,38 +114,37 @@ export function fromTranslation<T extends Matrix3Like>(
94
114
  out[7] = vector[1];
95
115
  out[8] = 1;
96
116
  return out;
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)
107
126
  */
108
- export function fromQuaternion<T extends Matrix3Like>(
127
+ export const 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
+ ): T => {
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;
@@ -137,83 +156,82 @@ export function fromQuaternion<T extends Matrix3Like>(
137
156
  out[5] = zy + wx;
138
157
  out[8] = 1 - xx - yy;
139
158
  return out;
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
- export function normalFromMatrix4<T extends Matrix3Like>(
168
+ export const 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
+ ): T => {
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)
211
229
  */
212
- export function projection<T extends Matrix3Like>(
230
+ export const projection = <T extends Matrix3Like>(
213
231
  width: number,
214
232
  height: number,
215
233
  out: T
216
- ): T {
234
+ ): T => {
217
235
  out[0] = 2 / width;
218
236
  out[1] = 0;
219
237
  out[2] = 0;
@@ -224,19 +242,18 @@ export function projection<T extends Matrix3Like>(
224
242
  out[7] = 1;
225
243
  out[8] = 1;
226
244
  return out;
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
- export function fromMatrix4<T extends Matrix3Like>(
253
+ export const fromMatrix4 = <T extends Matrix3Like>(
237
254
  matrix: Matrix4Like,
238
255
  out: T
239
- ): T {
256
+ ): T => {
240
257
  out[0] = matrix[0];
241
258
  out[1] = matrix[1];
242
259
  out[2] = matrix[2];
@@ -247,23 +264,23 @@ export function fromMatrix4<T extends Matrix3Like>(
247
264
  out[7] = matrix[9];
248
265
  out[8] = matrix[10];
249
266
  return out;
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
- export function fromValues<T extends Matrix3Like>(
283
+ export const fromValues = <T extends Matrix3Like>(
267
284
  c0r0: number,
268
285
  c0r1: number,
269
286
  c0r2: number,
@@ -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
+ ): T => {
278
295
  out[0] = c0r0;
279
296
  out[1] = c0r1;
280
297
  out[2] = c0r2;
@@ -285,34 +302,34 @@ export function fromValues<T extends Matrix3Like>(
285
302
  out[7] = c2r1;
286
303
  out[8] = c2r2;
287
304
  return out;
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 const equals = (a: Matrix3Like, b: Matrix3Like): boolean => {
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)) &&
@@ -325,41 +342,41 @@ export function equals(a: Matrix3Like, b: Matrix3Like): boolean {
325
342
  Math.abs(a7 - b7) <= epsilon * Math.max(1, Math.abs(a7), Math.abs(b7)) &&
326
343
  Math.abs(a8 - b8) <= epsilon * Math.max(1, Math.abs(a8), Math.abs(b8))
327
344
  );
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 const exactEquals = (a: Matrix3Like, b: Matrix3Like): boolean => {
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
  */
358
- export function add<T extends Matrix3Like>(
375
+ export const add = <T extends Matrix3Like>(
359
376
  a: Matrix3Like,
360
377
  b: Matrix3Like,
361
378
  out: T
362
- ): T {
379
+ ): T => {
363
380
  out[0] = a[0] + b[0];
364
381
  out[1] = a[1] + b[1];
365
382
  out[2] = a[2] + b[2];
@@ -370,25 +387,28 @@ export function add<T extends Matrix3Like>(
370
387
  out[7] = a[7] + b[7];
371
388
  out[8] = a[8] + b[8];
372
389
  return out;
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 const adjoint = <T extends Matrix3Like>(
400
+ matrix: Matrix3Like,
401
+ out: T
402
+ ): T => {
403
+ const a00 = matrix[0];
404
+ const a01 = matrix[1];
405
+ const a02 = matrix[2];
406
+ const a10 = matrix[3];
407
+ const a11 = matrix[4];
408
+ const a12 = matrix[5];
409
+ const a20 = matrix[6];
410
+ const a21 = matrix[7];
411
+ const a22 = matrix[8];
392
412
 
393
413
  out[0] = a11 * a22 - a12 * a21;
394
414
  out[1] = a02 * a21 - a01 * a22;
@@ -400,15 +420,15 @@ export function adjoint<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T {
400
420
  out[7] = a01 * a20 - a00 * a21;
401
421
  out[8] = a00 * a11 - a01 * a10;
402
422
  return out;
403
- }
423
+ };
404
424
 
405
425
  /**
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.
426
+ * Copy the values of one matrix into another.
427
+ * @param matrix - The matrix to copy.
428
+ * @param out - The matrix to store the result in.
409
429
  * @returns This matrix.
410
430
  */
411
- export function copy<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T {
431
+ export const copy = <T extends Matrix3Like>(matrix: Matrix3Like, out: T): T => {
412
432
  out[0] = matrix[0];
413
433
  out[1] = matrix[1];
414
434
  out[2] = matrix[2];
@@ -419,60 +439,60 @@ export function copy<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T {
419
439
  out[7] = matrix[7];
420
440
  out[8] = matrix[8];
421
441
  return out;
422
- }
442
+ };
423
443
 
424
444
  /**
425
- * Calculates the Frobenius norm of a matrix.
426
- * @param matrix The matrix.
445
+ * Calculate the Frobenius norm of a matrix.
446
+ * @param matrix - The matrix.
427
447
  * @returns The Frobenius norm.
428
448
  * @see [Matrix norm](https://en.wikipedia.org/wiki/Matrix_norm)
429
449
  */
430
- export function frob(matrix: Matrix3Like): number {
450
+ export const frob = (matrix: Matrix3Like): number => {
431
451
  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
452
+ matrix[0],
453
+ matrix[1],
454
+ matrix[2],
455
+ matrix[3],
456
+ matrix[4],
457
+ matrix[5],
458
+ matrix[6],
459
+ matrix[7],
460
+ matrix[8]
441
461
  );
442
- }
462
+ };
443
463
 
444
464
  /**
445
- * Multiplies two matrices.
446
- * @param a The multiplicand.
447
- * @param b The multiplier.
448
- * @param out The matrix to store the result in.
465
+ * Multiply two matrices.
466
+ * @param a - The multiplicand.
467
+ * @param b - The multiplier.
468
+ * @param out - The matrix to store the result in.
449
469
  * @returns The product of the matrices.
450
470
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
451
471
  */
452
- export function multiply<T extends Matrix3Like>(
472
+ export const multiply = <T extends Matrix3Like>(
453
473
  a: Matrix3Like,
454
474
  b: Matrix3Like,
455
475
  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];
476
+ ): T => {
477
+ const a00 = a[0];
478
+ const a01 = a[1];
479
+ const a02 = a[2];
480
+ const a10 = a[3];
481
+ const a11 = a[4];
482
+ const a12 = a[5];
483
+ const a20 = a[6];
484
+ const a21 = a[7];
485
+ const a22 = a[8];
486
+
487
+ const b00 = b[0];
488
+ const b01 = b[1];
489
+ const b02 = b[2];
490
+ const b10 = b[3];
491
+ const b11 = b[4];
492
+ const b12 = b[5];
493
+ const b20 = b[6];
494
+ const b21 = b[7];
495
+ const b22 = b[8];
476
496
 
477
497
  out[0] = b00 * a00 + b01 * a10 + b02 * a20;
478
498
  out[1] = b00 * a01 + b01 * a11 + b02 * a21;
@@ -484,21 +504,21 @@ export function multiply<T extends Matrix3Like>(
484
504
  out[7] = b20 * a01 + b21 * a11 + b22 * a21;
485
505
  out[8] = b20 * a02 + b21 * a12 + b22 * a22;
486
506
  return out;
487
- }
507
+ };
488
508
 
489
509
  /**
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.
510
+ * Multiply a matrix by a scalar value.
511
+ * @param matrix - The multiplicand.
512
+ * @param scalar - The multiplier.
513
+ * @param out - The matrix to store the result in.
494
514
  * @returns The product.
495
515
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
496
516
  */
497
- export function multiplyScalar<T extends Matrix3Like>(
517
+ export const multiplyScalar = <T extends Matrix3Like>(
498
518
  matrix: Matrix3Like,
499
519
  scalar: number,
500
520
  out: T
501
- ): T {
521
+ ): T => {
502
522
  out[0] = matrix[0] * scalar;
503
523
  out[1] = matrix[1] * scalar;
504
524
  out[2] = matrix[2] * scalar;
@@ -509,24 +529,24 @@ export function multiplyScalar<T extends Matrix3Like>(
509
529
  out[7] = matrix[7] * scalar;
510
530
  out[8] = matrix[8] * scalar;
511
531
  return out;
512
- }
532
+ };
513
533
 
514
534
  /**
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.
535
+ * Add a matrix to another after multiplying the other by a scalar.
536
+ * @param a - The augend.
537
+ * @param b - The addend.
538
+ * @param scalar - The multiplier.
539
+ * @param out - The matrix to store the result in.
520
540
  * @returns The sum.
521
541
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
522
542
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
523
543
  */
524
- export function multiplyScalarAndAdd<T extends Matrix3Like>(
544
+ export const multiplyScalarAndAdd = <T extends Matrix3Like>(
525
545
  a: Matrix3Like,
526
546
  b: Matrix3Like,
527
547
  scalar: number,
528
548
  out: T
529
- ): T {
549
+ ): T => {
530
550
  out[0] = a[0] + b[0] * scalar;
531
551
  out[1] = a[1] + b[1] * scalar;
532
552
  out[2] = a[2] + b[2] * scalar;
@@ -537,21 +557,21 @@ export function multiplyScalarAndAdd<T extends Matrix3Like>(
537
557
  out[7] = a[7] + b[7] * scalar;
538
558
  out[8] = a[8] + b[8] * scalar;
539
559
  return out;
540
- }
560
+ };
541
561
 
542
562
  /**
543
- * Subtracts two matrices.
544
- * @param a The minuend.
545
- * @param b The subtrahend.
546
- * @param out The matrix to store the result in.
563
+ * Subtract two matrices.
564
+ * @param a - The minuend.
565
+ * @param b - The subtrahend.
566
+ * @param out - The matrix to store the result in.
547
567
  * @returns The difference.
548
568
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
549
569
  */
550
- export function subtract<T extends Matrix3Like>(
570
+ export const subtract = <T extends Matrix3Like>(
551
571
  a: Matrix3Like,
552
572
  b: Matrix3Like,
553
573
  out: T
554
- ): T {
574
+ ): T => {
555
575
  out[0] = a[0] - b[0];
556
576
  out[1] = a[1] - b[1];
557
577
  out[2] = a[2] - b[2];
@@ -562,23 +582,23 @@ export function subtract<T extends Matrix3Like>(
562
582
  out[7] = a[7] - b[7];
563
583
  out[8] = a[8] - b[8];
564
584
  return out;
565
- }
585
+ };
566
586
 
567
587
  /**
568
- * Transposes a matrix.
569
- * @param matrix The matrix.
570
- * @param out The matrix to store the result in.
588
+ * Transpose a matrix.
589
+ * @param matrix - The matrix.
590
+ * @param out - The matrix to store the result in.
571
591
  * @returns The transpose of the matrix.
572
592
  * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
573
593
  */
574
- export function transpose<T extends Matrix3Like>(
594
+ export const transpose = <T extends Matrix3Like>(
575
595
  matrix: Matrix3Like,
576
596
  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];
597
+ ): T => {
598
+ if (out === matrix) {
599
+ const a01 = matrix[1];
600
+ const a02 = matrix[2];
601
+ const a12 = matrix[5];
582
602
  out[1] = matrix[3];
583
603
  out[2] = matrix[6];
584
604
  out[3] = a01;
@@ -597,39 +617,39 @@ export function transpose<T extends Matrix3Like>(
597
617
  out[8] = matrix[8];
598
618
  }
599
619
  return out;
600
- }
620
+ };
601
621
 
602
622
  /**
603
- * Calculates the determinant of a matrix.
604
- * @param matrix The matrix.
623
+ * Calculate the determinant of a matrix.
624
+ * @param matrix - The matrix.
605
625
  * @returns The determinant.
606
626
  * @see [Determinant](https://en.wikipedia.org/wiki/Determinant)
607
627
  */
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];
628
+ export const determinant = (matrix: Matrix3Like): number => {
629
+ const a00 = matrix[0];
630
+ const a01 = matrix[1];
631
+ const a02 = matrix[2];
632
+ const a10 = matrix[3];
633
+ const a11 = matrix[4];
634
+ const a12 = matrix[5];
635
+ const a20 = matrix[6];
636
+ const a21 = matrix[7];
637
+ const a22 = matrix[8];
618
638
 
619
639
  return (
620
640
  a00 * (a22 * a11 - a12 * a21) +
621
641
  a01 * (-a22 * a10 + a12 * a20) +
622
642
  a02 * (a21 * a10 - a11 * a20)
623
643
  );
624
- }
644
+ };
625
645
 
626
646
  /**
627
- * Resets a matrix to identity.
628
- * @param out The matrix to store the result in.
647
+ * Reset a matrix to identity.
648
+ * @param out - The matrix to store the result in.
629
649
  * @returns The matrix.
630
650
  * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
631
651
  */
632
- export function identity<T extends Matrix3Like>(out: T): T {
652
+ export const identity = <T extends Matrix3Like>(out: T): T => {
633
653
  out[0] = 1;
634
654
  out[1] = 0;
635
655
  out[2] = 0;
@@ -640,73 +660,76 @@ export function identity<T extends Matrix3Like>(out: T): T {
640
660
  out[7] = 0;
641
661
  out[8] = 1;
642
662
  return out;
643
- }
663
+ };
644
664
 
645
665
  /**
646
- * Inverts a matrix.
647
- * @param matrix The matrix.
648
- * @param out The matrix to store the result in.
666
+ * Invert a matrix.
667
+ * @param matrix - The matrix.
668
+ * @param out - The matrix to store the result in.
649
669
  * @returns The inverted matrix.
650
670
  * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
651
671
  */
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) {
672
+ export const invert = <T extends Matrix3Like>(
673
+ matrix: Matrix3Like,
674
+ out: T
675
+ ): T => {
676
+ const a00 = matrix[0];
677
+ const a01 = matrix[1];
678
+ const a02 = matrix[2];
679
+ const a10 = matrix[3];
680
+ const a11 = matrix[4];
681
+ const a12 = matrix[5];
682
+ const a20 = matrix[6];
683
+ const a21 = matrix[7];
684
+ const a22 = matrix[8];
685
+
686
+ const b01 = a22 * a11 - a12 * a21;
687
+ const b11 = -a22 * a10 + a12 * a20;
688
+ const b21 = a21 * a10 - a11 * a20;
689
+
690
+ let det = a00 * b01 + a01 * b11 + a02 * b21;
691
+ if (!det) {
669
692
  throw new SingularMatrixError();
670
693
  }
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;
694
+ det = 1 / det;
695
+
696
+ out[0] = b01 * det;
697
+ out[1] = (-a22 * a01 + a02 * a21) * det;
698
+ out[2] = (a12 * a01 - a02 * a11) * det;
699
+ out[3] = b11 * det;
700
+ out[4] = (a22 * a00 - a02 * a20) * det;
701
+ out[5] = (-a12 * a00 + a02 * a10) * det;
702
+ out[6] = b21 * det;
703
+ out[7] = (-a21 * a00 + a01 * a20) * det;
704
+ out[8] = (a11 * a00 - a01 * a10) * det;
682
705
  return out;
683
- }
706
+ };
684
707
 
685
708
  /**
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.
709
+ * Rotate a matrix by the given angle around the Z-axis.
710
+ * @param matrix - The matrix.
711
+ * @param radians - The angle in radians.
712
+ * @param out - The matrix to store the result in.
690
713
  * @returns The rotated matrix.
691
714
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
692
715
  */
693
- export function rotate<T extends Matrix3Like>(
716
+ export const rotate = <T extends Matrix3Like>(
694
717
  matrix: Matrix3Like,
695
718
  radians: number,
696
719
  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);
720
+ ): T => {
721
+ const a00 = matrix[0];
722
+ const a01 = matrix[1];
723
+ const a02 = matrix[2];
724
+ const a10 = matrix[3];
725
+ const a11 = matrix[4];
726
+ const a12 = matrix[5];
727
+ const a20 = matrix[6];
728
+ const a21 = matrix[7];
729
+ const a22 = matrix[8];
730
+
731
+ const s = Math.sin(radians);
732
+ const c = Math.cos(radians);
710
733
 
711
734
  out[0] = c * a00 + s * a10;
712
735
  out[1] = c * a01 + s * a11;
@@ -718,23 +741,23 @@ export function rotate<T extends Matrix3Like>(
718
741
  out[7] = a21;
719
742
  out[8] = a22;
720
743
  return out;
721
- }
744
+ };
722
745
 
723
746
  /**
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.
747
+ * Scale a matrix by the given vector.
748
+ * @param matrix - The matrix.
749
+ * @param vector - The scaling vector.
750
+ * @param out - The matrix to store the result in.
728
751
  * @returns The scaled matrix.
729
752
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
730
753
  */
731
- export function scale<T extends Matrix3Like>(
754
+ export const scale = <T extends Matrix3Like>(
732
755
  matrix: Matrix3Like,
733
756
  vector: Vector2Like,
734
757
  out: T
735
- ): T {
736
- const x: number = vector[0];
737
- const y: number = vector[1];
758
+ ): T => {
759
+ const x = vector[0];
760
+ const y = vector[1];
738
761
 
739
762
  out[0] = matrix[0] * x;
740
763
  out[1] = matrix[1] * x;
@@ -746,33 +769,33 @@ export function scale<T extends Matrix3Like>(
746
769
  out[7] = matrix[7];
747
770
  out[8] = matrix[8];
748
771
  return out;
749
- }
772
+ };
750
773
 
751
774
  /**
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.
775
+ * Translate a matrix by the given vector.
776
+ * @param matrix - The matrix.
777
+ * @param vector - The translation vector.
778
+ * @param out - The matrix to store the result in.
756
779
  * @returns The translated matrix.
757
780
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
758
781
  */
759
- export function translate<T extends Matrix3Like>(
782
+ export const translate = <T extends Matrix3Like>(
760
783
  matrix: Matrix3Like,
761
784
  vector: Vector2Like,
762
785
  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];
786
+ ): T => {
787
+ const a00 = matrix[0];
788
+ const a01 = matrix[1];
789
+ const a02 = matrix[2];
790
+ const a10 = matrix[3];
791
+ const a11 = matrix[4];
792
+ const a12 = matrix[5];
793
+ const a20 = matrix[6];
794
+ const a21 = matrix[7];
795
+ const a22 = matrix[8];
796
+
797
+ const x = vector[0];
798
+ const y = vector[1];
776
799
 
777
800
  out[0] = a00;
778
801
  out[1] = a01;
@@ -784,254 +807,129 @@ export function translate<T extends Matrix3Like>(
784
807
  out[7] = x * a01 + y * a11 + a21;
785
808
  out[8] = x * a02 + y * a12 + a22;
786
809
  return out;
787
- }
810
+ };
788
811
 
789
812
  /**
790
813
  * A three-by-three matrix.
791
814
  * @see [Matrix](https://en.wikipedia.org/wiki/Matrix_(mathematics))
792
815
  */
793
- export default class Matrix3 extends Float32Array implements SquareMatrix {
794
- /**
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.
798
- * @returns The transformation matrix.
799
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
800
- */
801
- public static fromRotation(radians: number): Matrix3;
802
-
816
+ export default class Matrix3
817
+ extends Float32Array
818
+ implements SquareMatrix, Matrix3Like
819
+ {
803
820
  /**
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.
821
+ * Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
822
+ * @param r - The angle in radians.
823
+ * @param out - The matrix to store the result in.
808
824
  * @returns The transformation matrix.
809
825
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
810
826
  */
811
- public static fromRotation<T extends Matrix3Like>(radians: number, out: T): T;
812
-
813
827
  public static fromRotation<T extends Matrix3Like>(
814
- radians: number,
815
- out: T = new Matrix3() as T
828
+ r: number,
829
+ out = new Matrix3() as unknown as T
816
830
  ): T {
817
- return fromRotation(radians, out);
831
+ return fromRotation(r, out);
818
832
  }
819
833
 
820
834
  /**
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.
835
+ * Create a transformation matrix that represents a scaling by the given vector.
836
+ * @param vector - The scaling vector.
837
+ * @param out - The matrix to store the result in.
834
838
  * @returns The transformation matrix.
835
839
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
836
840
  */
837
841
  public static fromScaling<T extends Matrix3Like>(
838
842
  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
843
+ out = new Matrix3() as unknown as T
845
844
  ): T {
846
845
  return fromScaling(vector, out);
847
846
  }
848
847
 
849
848
  /**
850
- * Creates a transformation matrix that represents a translation by the
851
- * given vector.
852
- * @param vector The translation vector.
849
+ * Create a transformation matrix that represents a translation by the given vector.
850
+ * @param vector - The translation vector.
851
+ * @param out - The matrix to store the result in.
853
852
  * @returns The transformation matrix.
854
853
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
855
854
  */
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
855
  public static fromTranslation<T extends Matrix3Like>(
872
856
  vector: Vector2Like,
873
- out: T = new Matrix3() as T
857
+ out = new Matrix3() as unknown as T
874
858
  ): T {
875
859
  return fromTranslation(vector, out);
876
860
  }
877
861
 
878
862
  /**
879
- * Creates a transformation matrix that represents a rotation by the given
880
- * quaternion.
881
- * @param quaternion The quaternion.
882
- * @returns The transformation matrix.
883
- * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
884
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
885
- */
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.
863
+ * Create a transformation matrix that represents a rotation by the given quaternion.
864
+ * @param quaternion - The quaternion.
865
+ * @param out - The matrix to store the result in.
893
866
  * @returns The transformation matrix.
894
867
  * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
895
868
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
896
869
  */
897
870
  public static fromQuaternion<T extends Matrix3Like>(
898
871
  quaternion: QuaternionLike,
899
- out: T
900
- ): T;
901
-
902
- public static fromQuaternion<T extends Matrix3Like>(
903
- quaternion: QuaternionLike,
904
- out: T = new Matrix3() as T
872
+ out = new Matrix3() as unknown as T
905
873
  ): T {
906
874
  return fromQuaternion(quaternion, out);
907
875
  }
908
876
 
909
877
  /**
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.
878
+ * Calculate a three-by-three normal (inverse transpose) matrix from a four-by-four matrix.
879
+ * @param matrix - The four-by-four matrix.
880
+ * @param out - The matrix to store the result in.
923
881
  * @returns The normal matrix.
924
882
  * @see [Normal matrix](https://en.wikipedia.org/wiki/Normal_matrix)
925
883
  */
926
884
  public static normalFromMatrix4<T extends Matrix3Like>(
927
885
  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
886
+ out = new Matrix3() as unknown as T
934
887
  ): T {
935
888
  return normalFromMatrix4(matrix, out);
936
889
  }
937
890
 
938
891
  /**
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.
892
+ * Generate a two-dimensional projection matrix with the given bounds.
893
+ * @param width - The width of the projection.
894
+ * @param height - The height of the projection.
895
+ * @param out - The matrix to store the result in.
942
896
  * @returns The projection matrix.
943
897
  * @see [Camera matrix](https://en.wikipedia.org/wiki/Camera_matrix)
944
898
  * @see [3D projection](https://en.wikipedia.org/wiki/3D_projection)
945
899
  */
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.
953
- * @returns The projection matrix.
954
- * @see [Camera matrix](https://en.wikipedia.org/wiki/Camera_matrix)
955
- * @see [3D projection](https://en.wikipedia.org/wiki/3D_projection)
956
- */
957
- public static projection<T extends Matrix3Like>(
958
- width: number,
959
- height: number,
960
- out: T
961
- ): T;
962
-
963
900
  public static projection<T extends Matrix3Like>(
964
901
  width: number,
965
902
  height: number,
966
- out: T = new Matrix3() as T
903
+ out = new Matrix3() as unknown as T
967
904
  ): T {
968
905
  return projection(width, height, out);
969
906
  }
970
907
 
971
908
  /**
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.
909
+ * Create a three-by-three matrix from the upper-left corner of a four-by-four matrix.
910
+ * @param matrix - The four-by-four matrix.
911
+ * @param out - The matrix to store the result in.
975
912
  * @returns The three-by-three matrix.
976
913
  */
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.
984
- * @returns The three-by-three matrix.
985
- */
986
- public static fromMatrix4<T extends Matrix3Like>(
987
- matrix: Matrix4Like,
988
- out: T
989
- ): T;
990
-
991
914
  public static fromMatrix4<T extends Matrix3Like>(
992
915
  matrix: Matrix4Like,
993
- out: T = new Matrix3() as T
916
+ out = new Matrix3() as unknown as T
994
917
  ): T {
995
918
  return fromMatrix4(matrix, out);
996
919
  }
997
920
 
998
921
  /**
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.
922
+ * Create a two-by-two matrix with the given values.
923
+ * @param c0r0 - The value in the first column and first row.
924
+ * @param c0r1 - The value in the first column and second row.
925
+ * @param c0r2 - The value in the first column and third row.
926
+ * @param c1r0 - The value in the second column and first row.
927
+ * @param c1r1 - The value in the second column and second row.
928
+ * @param c1r2 - The value in the second column and third row.
929
+ * @param c2r0 - The value in the third column and first row.
930
+ * @param c2r1 - The value in the third column and second row.
931
+ * @param c2r2 - The value in the third column and third row.
932
+ * @param out - The matrix to store the result in.
1035
933
  * @returns The matrix.
1036
934
  */
1037
935
  public static fromValues<T extends Matrix3Like>(
@@ -1044,20 +942,7 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1044
942
  c2r0: number,
1045
943
  c2r1: number,
1046
944
  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
945
+ out = new Matrix3() as unknown as T
1061
946
  ): T {
1062
947
  return fromValues(
1063
948
  c0r0,
@@ -1074,7 +959,7 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1074
959
  }
1075
960
 
1076
961
  /**
1077
- * Creates a three-by-three identity matrix.
962
+ * Create a three-by-three identity matrix.
1078
963
  * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
1079
964
  */
1080
965
  public constructor() {
@@ -1088,6 +973,33 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1088
973
  this.height = 3;
1089
974
  }
1090
975
 
976
+ /** The value in the first column and first row. */
977
+ public 0: number;
978
+
979
+ /** The value in the first column and second row. */
980
+ public 1: number;
981
+
982
+ /** The value in the first column and third row. */
983
+ public 2: number;
984
+
985
+ /** The value in the second column and first row. */
986
+ public 3: number;
987
+
988
+ /** The value in the second column and second row. */
989
+ public 4: number;
990
+
991
+ /** The value in the second column and third row. */
992
+ public 5: number;
993
+
994
+ /** The value in the third column and first row. */
995
+ public 6: number;
996
+
997
+ /** The value in the third column and second row. */
998
+ public 7: number;
999
+
1000
+ /** The value in the third column and third row. */
1001
+ public 8: number;
1002
+
1091
1003
  /** The number of columns in this matrix. */
1092
1004
  public readonly width: 3;
1093
1005
 
@@ -1095,86 +1007,61 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1095
1007
  public readonly height: 3;
1096
1008
 
1097
1009
  /**
1098
- * Determines whether this matrix is roughly equivalent to another.
1099
- * @param matrix The other matrix.
1100
- * @returns Whether the matrices are equivalent.
1010
+ * Determine whether or not this matrix is roughly equivalent to another.
1011
+ * @param matrix - The other matrix.
1012
+ * @returns Whether or not the matrices are equivalent.
1101
1013
  */
1102
1014
  public equals(matrix: Matrix3Like): boolean {
1103
1015
  return equals(this, matrix);
1104
1016
  }
1105
1017
 
1106
1018
  /**
1107
- * Determines whether this matrix is exactly equivalent to another.
1108
- * @param matrix The other matrix.
1109
- * @returns Whether the matrices are equivalent.
1019
+ * Determine whether or not this matrix is exactly equivalent to another.
1020
+ * @param matrix - The other matrix.
1021
+ * @returns Whether or not the matrices are equivalent.
1110
1022
  */
1111
1023
  public exactEquals(matrix: Matrix3Like): boolean {
1112
1024
  return exactEquals(this, matrix);
1113
1025
  }
1114
1026
 
1115
1027
  /**
1116
- * Adds two matrices of the same size.
1117
- * @param matrix The other matrix.
1028
+ * Add two matrices of the same size.
1029
+ * @param matrix - The other matrix.
1030
+ * @param out - The matrix to store the result in.
1118
1031
  * @returns The sum of the matrices.
1119
1032
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
1120
1033
  */
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
1034
  public add<T extends Matrix3Like>(
1133
1035
  matrix: Matrix3Like,
1134
- out: T = new Matrix3() as T
1036
+ out = new Matrix3() as unknown as T
1135
1037
  ): T {
1136
1038
  return add(this, matrix, out);
1137
1039
  }
1138
1040
 
1139
1041
  /**
1140
- * Calculates the adjugate of this matrix.
1042
+ * Calculate the adjugate of this matrix.
1043
+ * @param out - The matrix to store the result in.
1141
1044
  * @returns The adjugate of this matrix.
1142
1045
  * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
1143
1046
  */
1144
- public adjoint(): Matrix3;
1145
-
1146
- /**
1147
- * Calculates the adjugate of this matrix.
1148
- * @param out The matrix to store the result in.
1149
- * @returns The adjugate of this matrix.
1150
- * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
1151
- */
1152
- public adjoint<T extends Matrix3Like>(out: T): T;
1153
-
1154
- public adjoint<T extends Matrix3Like>(out: T = new Matrix3() as T): T {
1047
+ public adjoint<T extends Matrix3Like>(
1048
+ out = new Matrix3() as unknown as T
1049
+ ): T {
1155
1050
  return adjoint(this, out);
1156
1051
  }
1157
1052
 
1158
1053
  /**
1159
- * Creates a copy of this matrix.
1054
+ * Copy the values from this matrix to another one.
1055
+ * @param out - The matrix to store the result in.
1160
1056
  * @returns The copy.
1161
1057
  */
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 {
1058
+ public clone<T extends Matrix3Like>(out = new Matrix3() as unknown as T): T {
1172
1059
  return copy(this, out);
1173
1060
  }
1174
1061
 
1175
1062
  /**
1176
- * Copies the values of another matrix into this one.
1177
- * @param matrix The matrix to copy.
1063
+ * Copy the values of another matrix into this one.
1064
+ * @param matrix - The matrix to copy.
1178
1065
  * @returns This matrix.
1179
1066
  */
1180
1067
  public copy(matrix: Matrix3Like): this {
@@ -1182,7 +1069,7 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1182
1069
  }
1183
1070
 
1184
1071
  /**
1185
- * The Frobenius norm of this matrix.
1072
+ * Get the Frobenius norm of this matrix.
1186
1073
  * @see [Matrix norm](https://en.wikipedia.org/wiki/Matrix_norm)
1187
1074
  */
1188
1075
  public get frob(): number {
@@ -1190,131 +1077,78 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1190
1077
  }
1191
1078
 
1192
1079
  /**
1193
- * Multiplies this matrix by another.
1194
- * @param matrix The other matrix.
1080
+ * Multiply this matrix by another.
1081
+ * @param matrix - The other matrix.
1082
+ * @param out - The matrix to store the result in.
1195
1083
  * @returns The product of the matrices.
1196
1084
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
1197
1085
  */
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.
1204
- * @returns The product of the matrices.
1205
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
1206
- */
1207
- public multiply<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T;
1208
-
1209
1086
  public multiply<T extends Matrix3Like>(
1210
1087
  matrix: Matrix3Like,
1211
- out: T = new Matrix3() as T
1088
+ out = new Matrix3() as unknown as T
1212
1089
  ): T {
1213
1090
  return multiply(this, matrix, out);
1214
1091
  }
1215
1092
 
1216
1093
  /**
1217
- * Multiplies this matrix by a scalar value.
1218
- * @param scalar The scalar value.
1094
+ * Multiply this matrix by a scalar value.
1095
+ * @param scalar - The scalar value.
1096
+ * @param out - The matrix to store the result in.
1219
1097
  * @returns The product of the matrix and the scalar value.
1220
1098
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
1221
1099
  */
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
1100
  public multiplyScalar<T extends Matrix3Like>(
1234
1101
  scalar: number,
1235
- out: T = new Matrix3() as T
1102
+ out = new Matrix3() as unknown as T
1236
1103
  ): T {
1237
1104
  return multiplyScalar(this, scalar, out);
1238
1105
  }
1239
1106
 
1240
1107
  /**
1241
- * Adds this matrix to another after multiplying the other by a scalar.
1242
- * @param matrix The other matrix.
1243
- * @param scalar The scalar.
1108
+ * Add this matrix to another after multiplying the other by a scalar.
1109
+ * @param matrix - The other matrix.
1110
+ * @param scalar - The scalar.
1111
+ * @param out - The matrix to store the result in.
1244
1112
  * @returns The sum.
1245
1113
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
1246
1114
  * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
1247
1115
  */
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.
1255
- * @returns The sum.
1256
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
1257
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
1258
- */
1259
- public multiplyScalarAndAdd<T extends Matrix3Like>(
1260
- matrix: Matrix3Like,
1261
- scalar: number,
1262
- out: T
1263
- ): T;
1264
-
1265
1116
  public multiplyScalarAndAdd<T extends Matrix3Like>(
1266
1117
  matrix: Matrix3Like,
1267
1118
  scalar: number,
1268
- out: T = new Matrix3() as T
1119
+ out = new Matrix3() as unknown as T
1269
1120
  ): T {
1270
1121
  return multiplyScalarAndAdd(this, matrix, scalar, out);
1271
1122
  }
1272
1123
 
1273
1124
  /**
1274
- * Subtracts another matrix from this one.
1275
- * @param matrix The other matrix.
1125
+ * Subtract another matrix from this one.
1126
+ * @param matrix - The other matrix.
1127
+ * @param out - The matrix to store the result in.
1276
1128
  * @returns The difference between the matrices.
1277
1129
  * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
1278
1130
  */
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.
1285
- * @returns The difference between the matrices.
1286
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
1287
- */
1288
- public subtract<T extends Matrix3Like>(matrix: Matrix3Like, out: T): T;
1289
-
1290
1131
  public subtract<T extends Matrix3Like>(
1291
1132
  matrix: Matrix3Like,
1292
- out: T = new Matrix3() as T
1133
+ out = new Matrix3() as unknown as T
1293
1134
  ): T {
1294
1135
  return subtract(this, matrix, out);
1295
1136
  }
1296
1137
 
1297
1138
  /**
1298
- * Transposes this matrix.
1139
+ * Transpose this matrix.
1140
+ * @param out - The matrix to store the result in.
1299
1141
  * @returns The transpose of this matrix.
1300
1142
  * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
1301
1143
  */
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 {
1144
+ public transpose<T extends Matrix3Like>(
1145
+ out = new Matrix3() as unknown as T
1146
+ ): T {
1313
1147
  return transpose(this, out);
1314
1148
  }
1315
1149
 
1316
1150
  /**
1317
- * The determinant of this matrix.
1151
+ * Get the determinant of this matrix.
1318
1152
  * @see [Determinant](https://en.wikipedia.org/wiki/Determinant)
1319
1153
  */
1320
1154
  public get determinant(): number {
@@ -1322,7 +1156,7 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1322
1156
  }
1323
1157
 
1324
1158
  /**
1325
- * Resets this matrix to identity.
1159
+ * Reset this matrix to identity.
1326
1160
  * @returns This matrix.
1327
1161
  * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
1328
1162
  */
@@ -1331,92 +1165,53 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
1331
1165
  }
1332
1166
 
1333
1167
  /**
1334
- * Inverts this matrix.
1168
+ * Invert this matrix.
1169
+ * @param out - The matrix to store the result in.
1335
1170
  * @returns The inverted matrix.
1336
1171
  * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
1337
1172
  */
1338
- public invert(): Matrix3;
1339
-
1340
- /**
1341
- * Inverts this matrix.
1342
- * @param out The matrix to store the result in.
1343
- * @returns The inverted matrix.
1344
- * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
1345
- */
1346
- public invert<T extends Matrix3Like>(out: T): T;
1347
-
1348
- public invert<T extends Matrix3Like>(out: T = new Matrix3() as T): T {
1173
+ public invert<T extends Matrix3Like>(out = new Matrix3() as unknown as T): T {
1349
1174
  return invert(this, out);
1350
1175
  }
1351
1176
 
1352
1177
  /**
1353
- * Rotates this matrix by the given angle around the Z-axis.
1354
- * @param radians The angle in radians.
1178
+ * Rotate this matrix by the given angle around the Z-axis.
1179
+ * @param r - The angle in radians.
1180
+ * @param out - The matrix to store the result in.
1355
1181
  * @returns The rotated matrix.
1356
1182
  * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
1357
1183
  */
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
1184
  public rotate<T extends Matrix3Like>(
1370
- radians: number,
1371
- out: T = new Matrix3() as T
1185
+ r: number,
1186
+ out = new Matrix3() as unknown as T
1372
1187
  ): T {
1373
- return rotate(this, radians, out);
1188
+ return rotate(this, r, out);
1374
1189
  }
1375
1190
 
1376
1191
  /**
1377
- * Scales this matrix by the given vector.
1378
- * @param vector The scaling vector.
1192
+ * Scale this matrix by the given vector.
1193
+ * @param vector - The scaling vector.
1194
+ * @param out - The matrix to store the result in.
1379
1195
  * @returns The scaled matrix.
1380
1196
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
1381
1197
  */
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.
1388
- * @returns The scaled matrix.
1389
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
1390
- */
1391
- public scale<T extends Matrix3Like>(vector: Vector2Like, out: T): T;
1392
-
1393
1198
  public scale<T extends Matrix3Like>(
1394
1199
  vector: Vector2Like,
1395
- out: T = new Matrix3() as T
1200
+ out = new Matrix3() as unknown as T
1396
1201
  ): T {
1397
1202
  return scale(this, vector, out);
1398
1203
  }
1399
1204
 
1400
1205
  /**
1401
- * Translates this matrix by the given vector.
1402
- * @param vector The translation vector.
1206
+ * Translate this matrix by the given vector.
1207
+ * @param vector - The translation vector.
1208
+ * @param out - The matrix to store the result in.
1403
1209
  * @returns The translated matrix.
1404
1210
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
1405
1211
  */
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
1212
  public translate<T extends Matrix3Like>(
1418
1213
  vector: Vector2Like,
1419
- out: T = new Matrix3() as T
1214
+ out = new Matrix3() as unknown as T
1420
1215
  ): T {
1421
1216
  return translate(this, vector, out);
1422
1217
  }