@lakuna/umath 1.3.8 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -0
  3. package/dist/algorithms/approx.d.ts +9 -0
  4. package/dist/algorithms/approx.d.ts.map +1 -0
  5. package/dist/algorithms/approx.js +12 -0
  6. package/dist/algorithms/approx.js.map +1 -0
  7. package/dist/algorithms/approxRelative.d.ts +9 -0
  8. package/dist/algorithms/approxRelative.d.ts.map +1 -0
  9. package/dist/algorithms/approxRelative.js +12 -0
  10. package/dist/algorithms/approxRelative.js.map +1 -0
  11. package/dist/algorithms/combinations.d.ts +2 -1
  12. package/dist/algorithms/combinations.d.ts.map +1 -1
  13. package/dist/algorithms/combinations.js +2 -1
  14. package/dist/algorithms/combinations.js.map +1 -1
  15. package/dist/algorithms/degreesToRadians.d.ts +3 -2
  16. package/dist/algorithms/degreesToRadians.d.ts.map +1 -1
  17. package/dist/algorithms/degreesToRadians.js +5 -3
  18. package/dist/algorithms/degreesToRadians.js.map +1 -1
  19. package/dist/algorithms/factorial.d.ts +2 -1
  20. package/dist/algorithms/factorial.d.ts.map +1 -1
  21. package/dist/algorithms/factorial.js +2 -1
  22. package/dist/algorithms/factorial.js.map +1 -1
  23. package/dist/algorithms/fibonacci.d.ts +2 -1
  24. package/dist/algorithms/fibonacci.d.ts.map +1 -1
  25. package/dist/algorithms/fibonacci.js +6 -2
  26. package/dist/algorithms/fibonacci.js.map +1 -1
  27. package/dist/algorithms/greatestCommonDivisor.d.ts +4 -2
  28. package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
  29. package/dist/algorithms/greatestCommonDivisor.js +5 -2
  30. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  31. package/dist/algorithms/hypergeometricPmf.d.ts +3 -2
  32. package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
  33. package/dist/algorithms/hypergeometricPmf.js +3 -2
  34. package/dist/algorithms/hypergeometricPmf.js.map +1 -1
  35. package/dist/algorithms/isPrime.d.ts +2 -1
  36. package/dist/algorithms/isPrime.d.ts.map +1 -1
  37. package/dist/algorithms/isPrime.js +2 -1
  38. package/dist/algorithms/isPrime.js.map +1 -1
  39. package/dist/algorithms/permutations.d.ts +2 -1
  40. package/dist/algorithms/permutations.d.ts.map +1 -1
  41. package/dist/algorithms/permutations.js +2 -1
  42. package/dist/algorithms/permutations.js.map +1 -1
  43. package/dist/algorithms/primeFactorization.d.ts +2 -1
  44. package/dist/algorithms/primeFactorization.d.ts.map +1 -1
  45. package/dist/algorithms/primeFactorization.js +4 -4
  46. package/dist/algorithms/primeFactorization.js.map +1 -1
  47. package/dist/algorithms/radiansToDegrees.d.ts +3 -2
  48. package/dist/algorithms/radiansToDegrees.d.ts.map +1 -1
  49. package/dist/algorithms/radiansToDegrees.js +5 -3
  50. package/dist/algorithms/radiansToDegrees.js.map +1 -1
  51. package/dist/algorithms/summation.d.ts +2 -1
  52. package/dist/algorithms/summation.d.ts.map +1 -1
  53. package/dist/algorithms/summation.js +2 -1
  54. package/dist/algorithms/summation.js.map +1 -1
  55. package/dist/linalg/DualQuaternion.d.ts +102 -32
  56. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  57. package/dist/linalg/DualQuaternion.js +249 -275
  58. package/dist/linalg/DualQuaternion.js.map +1 -1
  59. package/dist/linalg/Matrix.d.ts +14 -10
  60. package/dist/linalg/Matrix.d.ts.map +1 -1
  61. package/dist/linalg/Matrix2.d.ts +74 -51
  62. package/dist/linalg/Matrix2.d.ts.map +1 -1
  63. package/dist/linalg/Matrix2.js +96 -169
  64. package/dist/linalg/Matrix2.js.map +1 -1
  65. package/dist/linalg/Matrix3.d.ts +122 -72
  66. package/dist/linalg/Matrix3.d.ts.map +1 -1
  67. package/dist/linalg/Matrix3.js +205 -358
  68. package/dist/linalg/Matrix3.js.map +1 -1
  69. package/dist/linalg/Matrix4.d.ts +267 -150
  70. package/dist/linalg/Matrix4.d.ts.map +1 -1
  71. package/dist/linalg/Matrix4.js +553 -864
  72. package/dist/linalg/Matrix4.js.map +1 -1
  73. package/dist/linalg/Quaternion.d.ts +252 -34
  74. package/dist/linalg/Quaternion.d.ts.map +1 -1
  75. package/dist/linalg/Quaternion.js +436 -166
  76. package/dist/linalg/Quaternion.js.map +1 -1
  77. package/dist/linalg/SlowMatrix.d.ts +10 -9
  78. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  79. package/dist/linalg/SlowMatrix.js +10 -9
  80. package/dist/linalg/SlowMatrix.js.map +1 -1
  81. package/dist/linalg/SlowSquareMatrix.d.ts +10 -9
  82. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  83. package/dist/linalg/SlowSquareMatrix.js +10 -9
  84. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  85. package/dist/linalg/SquareMatrix.d.ts +6 -5
  86. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  87. package/dist/linalg/Vector.d.ts +8 -4
  88. package/dist/linalg/Vector.d.ts.map +1 -1
  89. package/dist/linalg/Vector2.d.ts +82 -31
  90. package/dist/linalg/Vector2.d.ts.map +1 -1
  91. package/dist/linalg/Vector2.js +112 -154
  92. package/dist/linalg/Vector2.js.map +1 -1
  93. package/dist/linalg/Vector3.d.ts +93 -41
  94. package/dist/linalg/Vector3.d.ts.map +1 -1
  95. package/dist/linalg/Vector3.js +171 -282
  96. package/dist/linalg/Vector3.js.map +1 -1
  97. package/dist/linalg/Vector4.d.ts +71 -21
  98. package/dist/linalg/Vector4.d.ts.map +1 -1
  99. package/dist/linalg/Vector4.js +121 -195
  100. package/dist/linalg/Vector4.js.map +1 -1
  101. package/dist/types/AxisAngle.d.ts +4 -1
  102. package/dist/types/AxisAngle.d.ts.map +1 -1
  103. package/dist/types/FieldOfView.d.ts +4 -1
  104. package/dist/types/FieldOfView.d.ts.map +1 -1
  105. package/dist/utility/BigNumber.d.ts +4 -1
  106. package/dist/utility/BigNumber.d.ts.map +1 -1
  107. package/dist/utility/BigNumber.js +4 -1
  108. package/dist/utility/BigNumber.js.map +1 -1
  109. package/dist/utility/MagnitudeError.d.ts +4 -1
  110. package/dist/utility/MagnitudeError.d.ts.map +1 -1
  111. package/dist/utility/MagnitudeError.js +4 -1
  112. package/dist/utility/MagnitudeError.js.map +1 -1
  113. package/dist/utility/MatrixSizeError.d.ts +4 -1
  114. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  115. package/dist/utility/MatrixSizeError.js +4 -1
  116. package/dist/utility/MatrixSizeError.js.map +1 -1
  117. package/dist/utility/PartialMatrixError.d.ts +4 -1
  118. package/dist/utility/PartialMatrixError.d.ts.map +1 -1
  119. package/dist/utility/PartialMatrixError.js +4 -1
  120. package/dist/utility/PartialMatrixError.js.map +1 -1
  121. package/dist/utility/SingularMatrixError.d.ts +2 -1
  122. package/dist/utility/SingularMatrixError.d.ts.map +1 -1
  123. package/dist/utility/SingularMatrixError.js +2 -1
  124. package/dist/utility/SingularMatrixError.js.map +1 -1
  125. package/dist/utility/epsilon.d.ts +4 -1
  126. package/dist/utility/epsilon.d.ts.map +1 -1
  127. package/dist/utility/epsilon.js +4 -1
  128. package/dist/utility/epsilon.js.map +1 -1
  129. package/package.json +14 -18
  130. package/src/algorithms/approx.ts +12 -0
  131. package/src/algorithms/approxRelative.ts +12 -0
  132. package/src/algorithms/combinations.ts +2 -1
  133. package/src/algorithms/degreesToRadians.ts +6 -3
  134. package/src/algorithms/factorial.ts +3 -1
  135. package/src/algorithms/fibonacci.ts +7 -2
  136. package/src/algorithms/greatestCommonDivisor.ts +9 -4
  137. package/src/algorithms/hypergeometricPmf.ts +3 -2
  138. package/src/algorithms/isPrime.ts +2 -1
  139. package/src/algorithms/permutations.ts +2 -1
  140. package/src/algorithms/primeFactorization.ts +5 -3
  141. package/src/algorithms/radiansToDegrees.ts +6 -3
  142. package/src/algorithms/summation.ts +2 -1
  143. package/src/linalg/DualQuaternion.ts +430 -292
  144. package/src/linalg/Matrix.ts +14 -10
  145. package/src/linalg/Matrix2.ts +143 -185
  146. package/src/linalg/Matrix3.ts +421 -385
  147. package/src/linalg/Matrix4.ts +1147 -952
  148. package/src/linalg/Quaternion.ts +706 -188
  149. package/src/linalg/SlowMatrix.ts +10 -9
  150. package/src/linalg/SlowSquareMatrix.ts +10 -9
  151. package/src/linalg/SquareMatrix.ts +6 -5
  152. package/src/linalg/Vector.ts +8 -4
  153. package/src/linalg/Vector2.ts +146 -173
  154. package/src/linalg/Vector3.ts +293 -326
  155. package/src/linalg/Vector4.ts +227 -215
  156. package/src/types/AxisAngle.ts +4 -1
  157. package/src/types/FieldOfView.ts +4 -1
  158. package/src/utility/BigNumber.ts +6 -3
  159. package/src/utility/MagnitudeError.ts +4 -1
  160. package/src/utility/MatrixSizeError.ts +4 -1
  161. package/src/utility/PartialMatrixError.ts +4 -1
  162. package/src/utility/SingularMatrixError.ts +2 -1
  163. package/src/utility/epsilon.ts +4 -1
@@ -1,78 +1,79 @@
1
1
  import SingularMatrixError from "../utility/SingularMatrixError.js";
2
- import epsilon from "../utility/epsilon.js";
2
+ import approxRelative from "../algorithms/approxRelative.js";
3
3
  /**
4
- * Creates a 3x3 matrix-like object.
5
- * @returns A 3x3 matrix-like object.
4
+ * Creates a three-by-three matrix-like object.
5
+ * @returns A three-by-three matrix-like object.
6
+ * @public
6
7
  */
7
8
  export const createMatrix3Like = () => {
8
9
  return new Float32Array(9);
9
10
  };
10
11
  /**
11
- * Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
12
+ * Create a three-by-three matrix with the given values.
13
+ * @param c0r0 - The value in the first column and first row.
14
+ * @param c0r1 - The value in the first column and second row.
15
+ * @param c0r2 - The value in the first column and third row.
16
+ * @param c1r0 - The value in the second column and first row.
17
+ * @param c1r1 - The value in the second column and second row.
18
+ * @param c1r2 - The value in the second column and third row.
19
+ * @param c2r0 - The value in the third column and first row.
20
+ * @param c2r1 - The value in the third column and second row.
21
+ * @param c2r2 - The value in the third column and third row.
22
+ * @param out - The matrix to store the result in.
23
+ * @returns The matrix.
24
+ * @public
25
+ */
26
+ export const fromValues = (c0r0, c0r1, c0r2, c1r0, c1r1, c1r2, c2r0, c2r1, c2r2, out) => {
27
+ out[0] = c0r0;
28
+ out[1] = c0r1;
29
+ out[2] = c0r2;
30
+ out[3] = c1r0;
31
+ out[4] = c1r1;
32
+ out[5] = c1r2;
33
+ out[6] = c2r0;
34
+ out[7] = c2r1;
35
+ out[8] = c2r2;
36
+ return out;
37
+ };
38
+ /**
39
+ * Create a transformation matrix that represents a rotation by the given angle around the Z-axis. Equivalent to (but faster than) `rotate(identity(out), r, out)`.
12
40
  * @param r - The angle in radians.
13
41
  * @param out - The matrix to store the result in.
14
42
  * @returns The transformation matrix.
15
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
43
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
44
+ * @public
16
45
  */
17
46
  export const fromRotation = (r, out) => {
18
47
  const s = Math.sin(r);
19
48
  const c = Math.cos(r);
20
- out[0] = c;
21
- out[1] = s;
22
- out[2] = 0;
23
- out[3] = -s;
24
- out[4] = c;
25
- out[5] = 0;
26
- out[6] = 0;
27
- out[7] = 0;
28
- out[8] = 1;
29
- return out;
49
+ return fromValues(c, s, 0, -s, c, 0, 0, 0, 1, out);
30
50
  };
31
51
  /**
32
- * Create a transformation matrix that represents a scaling by the given vector.
52
+ * Create a transformation matrix that represents a scaling by the given vector. Equivalent to (but faster than) `scale(identity(out), vector, out)`.
33
53
  * @param vector - The scaling vector.
34
54
  * @param out - The matrix to store the result in.
35
55
  * @returns The transformation matrix.
36
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
56
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
57
+ * @public
37
58
  */
38
- export const fromScaling = (vector, out) => {
39
- out[0] = vector[0];
40
- out[1] = 0;
41
- out[2] = 0;
42
- out[3] = 0;
43
- out[4] = vector[1];
44
- out[5] = 0;
45
- out[6] = 0;
46
- out[7] = 0;
47
- out[8] = 1;
48
- return out;
49
- };
59
+ export const fromScaling = (vector, out) => fromValues(vector[0], 0, 0, 0, vector[1], 0, 0, 0, 1, out);
50
60
  /**
51
- * Create a transformation matrix that represents a translation by the given vector.
61
+ * Create a transformation matrix that represents a translation by the given vector. Equivalent to (but faster than) `translate(identity(out), vector, out)`.
52
62
  * @param vector - The translation vector.
53
63
  * @param out - The matrix to store the result in.
54
64
  * @returns The transformation matrix.
55
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
65
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
66
+ * @public
56
67
  */
57
- export const fromTranslation = (vector, out) => {
58
- out[0] = 1;
59
- out[1] = 0;
60
- out[2] = 0;
61
- out[3] = 0;
62
- out[4] = 1;
63
- out[5] = 0;
64
- out[6] = vector[0];
65
- out[7] = vector[1];
66
- out[8] = 1;
67
- return out;
68
- };
68
+ export const fromTranslation = (vector, out) => fromValues(1, 0, 0, 0, 1, 0, vector[0], vector[1], 1, out);
69
69
  /**
70
70
  * Create a transformation matrix that represents a rotation by the given quaternion.
71
71
  * @param quaternion - The quaternion.
72
72
  * @param out - The matrix to store the result in.
73
73
  * @returns The transformation matrix.
74
- * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
75
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
74
+ * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
75
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
76
+ * @public
76
77
  */
77
78
  export const fromQuaternion = (quaternion, out) => {
78
79
  const x = quaternion[0];
@@ -91,23 +92,36 @@ export const fromQuaternion = (quaternion, out) => {
91
92
  const wx = w * x2;
92
93
  const wy = w * y2;
93
94
  const wz = w * z2;
94
- out[0] = 1 - yy - zz;
95
- out[3] = yx - wz;
96
- out[6] = zx + wy;
97
- out[1] = yx + wz;
98
- out[4] = 1 - xx - zz;
99
- out[7] = zy - wx;
100
- out[2] = zx - wy;
101
- out[5] = zy + wx;
102
- out[8] = 1 - xx - yy;
103
- return out;
95
+ return fromValues(1 - yy - zz, yx - wz, zx + wy, yx + wz, 1 - xx - zz, zy - wx, zx - wy, zy + wx, 1 - xx - yy, out);
96
+ };
97
+ /**
98
+ * Create a transformation matrix that represents a rotation by the given z-y'-x" (intrinsic) Tait-Bryan angles.
99
+ * @param z - The z (roll) angle.
100
+ * @param y - The y (pitch) angle.
101
+ * @param x - The x (yaw) angle.
102
+ * @param out - The matrix to store the result in.
103
+ * @returns The transformation matrix.
104
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
105
+ * @public
106
+ */
107
+ export const fromEuler = (z, y, x, out) => {
108
+ const cz = Math.cos(z);
109
+ const sz = Math.sin(z);
110
+ const sy = Math.sin(y);
111
+ const cy = Math.cos(y);
112
+ const sx = Math.sin(x);
113
+ const cx = Math.cos(x);
114
+ const sysz = sy * sz;
115
+ const cysz = cy * sz;
116
+ return fromValues(cz * cx, sysz * cx - cy * sx, cysz * cx + sy * sx, cz * sx, sysz * sx + cy * cx, cysz * sx - sy * cx, -sz, sy * cz, cy * cz, out);
104
117
  };
105
118
  /**
106
119
  * Calculate a three-by-three normal (inverse transpose) matrix from a four-by-four matrix.
107
120
  * @param matrix - The four-by-four matrix.
108
121
  * @param out - The matrix to store the result in.
109
122
  * @returns The normal matrix.
110
- * @see [Normal matrix](https://en.wikipedia.org/wiki/Normal_matrix)
123
+ * @see {@link https://en.wikipedia.org/wiki/Normal_matrix | Normal matrix}
124
+ * @public
111
125
  */
112
126
  export const normalFromMatrix4 = (matrix, out) => {
113
127
  const a00 = matrix[0];
@@ -143,16 +157,7 @@ export const normalFromMatrix4 = (matrix, out) => {
143
157
  throw new SingularMatrixError();
144
158
  }
145
159
  det = 1 / det;
146
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
147
- out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
148
- out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
149
- out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
150
- out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
151
- out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
152
- out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
153
- out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
154
- out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
155
- return out;
160
+ return fromValues((a11 * b11 - a12 * b10 + a13 * b09) * det, (a12 * b08 - a10 * b11 - a13 * b07) * det, (a10 * b10 - a11 * b08 + a13 * b06) * det, (a02 * b10 - a01 * b11 - a03 * b09) * det, (a00 * b11 - a02 * b08 + a03 * b07) * det, (a01 * b08 - a00 * b10 - a03 * b06) * det, (a31 * b05 - a32 * b04 + a33 * b03) * det, (a32 * b02 - a30 * b05 - a33 * b01) * det, (a30 * b04 - a31 * b02 + a33 * b00) * det, out);
156
161
  };
157
162
  /**
158
163
  * Generate a two-dimensional projection matrix with the given bounds.
@@ -160,143 +165,68 @@ export const normalFromMatrix4 = (matrix, out) => {
160
165
  * @param height - The height of the projection.
161
166
  * @param out - The matrix to store the result in.
162
167
  * @returns The projection matrix.
163
- * @see [Camera matrix](https://en.wikipedia.org/wiki/Camera_matrix)
164
- * @see [3D projection](https://en.wikipedia.org/wiki/3D_projection)
168
+ * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
169
+ * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
170
+ * @public
165
171
  */
166
- export const projection = (width, height, out) => {
167
- out[0] = 2 / width;
168
- out[1] = 0;
169
- out[2] = 0;
170
- out[3] = 0;
171
- out[4] = -2 / height;
172
- out[5] = 0;
173
- out[6] = -1;
174
- out[7] = 1;
175
- out[8] = 1;
176
- return out;
177
- };
172
+ export const projection = (width, height, out) => fromValues(2 / width, 0, 0, 0, -2 / height, 0, -1, 1, 1, out);
178
173
  /**
179
174
  * Create a three-by-three matrix from the upper-left corner of a four-by-four matrix.
180
175
  * @param matrix - The four-by-four matrix.
181
176
  * @param out - The matrix to store the result in.
182
177
  * @returns The three-by-three matrix.
178
+ * @public
183
179
  */
184
- export const fromMatrix4 = (matrix, out) => {
185
- out[0] = matrix[0];
186
- out[1] = matrix[1];
187
- out[2] = matrix[2];
188
- out[3] = matrix[4];
189
- out[4] = matrix[5];
190
- out[5] = matrix[6];
191
- out[6] = matrix[8];
192
- out[7] = matrix[9];
193
- out[8] = matrix[10];
194
- return out;
195
- };
196
- /**
197
- * Create a two-by-two matrix with the given values.
198
- * @param c0r0 - The value in the first column and first row.
199
- * @param c0r1 - The value in the first column and second row.
200
- * @param c0r2 - The value in the first column and third row.
201
- * @param c1r0 - The value in the second column and first row.
202
- * @param c1r1 - The value in the second column and second row.
203
- * @param c1r2 - The value in the second column and third row.
204
- * @param c2r0 - The value in the third column and first row.
205
- * @param c2r1 - The value in the third column and second row.
206
- * @param c2r2 - The value in the third column and third row.
207
- * @param out - The matrix to store the result in.
208
- * @returns The matrix.
209
- */
210
- export const fromValues = (c0r0, c0r1, c0r2, c1r0, c1r1, c1r2, c2r0, c2r1, c2r2, out) => {
211
- out[0] = c0r0;
212
- out[1] = c0r1;
213
- out[2] = c0r2;
214
- out[3] = c1r0;
215
- out[4] = c1r1;
216
- out[5] = c1r2;
217
- out[6] = c2r0;
218
- out[7] = c2r1;
219
- out[8] = c2r2;
220
- return out;
221
- };
180
+ export const fromMatrix4 = (matrix, out) => fromValues(matrix[0], matrix[1], matrix[2], matrix[4], matrix[5], matrix[6], matrix[8], matrix[9], matrix[10], out);
222
181
  /**
223
182
  * Determine whether or not two matrices are roughly equivalent.
224
183
  * @param a - The first matrix.
225
184
  * @param b - The second matrix.
226
185
  * @returns Whether or not the matrices are equivalent.
186
+ * @public
227
187
  */
228
- export const equals = (a, b) => {
229
- const a0 = a[0];
230
- const a1 = a[1];
231
- const a2 = a[2];
232
- const a3 = a[3];
233
- const a4 = a[4];
234
- const a5 = a[5];
235
- const a6 = a[6];
236
- const a7 = a[7];
237
- const a8 = a[8];
238
- const b0 = b[0];
239
- const b1 = b[1];
240
- const b2 = b[2];
241
- const b3 = b[3];
242
- const b4 = b[4];
243
- const b5 = b[5];
244
- const b6 = b[6];
245
- const b7 = b[7];
246
- const b8 = b[8];
247
- return (Math.abs(a0 - b0) <= epsilon * Math.max(1, Math.abs(a0), Math.abs(b0)) &&
248
- Math.abs(a1 - b1) <= epsilon * Math.max(1, Math.abs(a1), Math.abs(b1)) &&
249
- Math.abs(a2 - b2) <= epsilon * Math.max(1, Math.abs(a2), Math.abs(b2)) &&
250
- Math.abs(a3 - b3) <= epsilon * Math.max(1, Math.abs(a3), Math.abs(b3)) &&
251
- Math.abs(a4 - b4) <= epsilon * Math.max(1, Math.abs(a4), Math.abs(b4)) &&
252
- Math.abs(a5 - b5) <= epsilon * Math.max(1, Math.abs(a5), Math.abs(b5)) &&
253
- Math.abs(a6 - b6) <= epsilon * Math.max(1, Math.abs(a6), Math.abs(b6)) &&
254
- Math.abs(a7 - b7) <= epsilon * Math.max(1, Math.abs(a7), Math.abs(b7)) &&
255
- Math.abs(a8 - b8) <= epsilon * Math.max(1, Math.abs(a8), Math.abs(b8)));
256
- };
188
+ export const equals = (a, b) => approxRelative(a[0], b[0]) &&
189
+ approxRelative(a[1], b[1]) &&
190
+ approxRelative(a[2], b[2]) &&
191
+ approxRelative(a[3], b[3]) &&
192
+ approxRelative(a[4], b[4]) &&
193
+ approxRelative(a[5], b[5]) &&
194
+ approxRelative(a[6], b[6]) &&
195
+ approxRelative(a[7], b[7]) &&
196
+ approxRelative(a[8], b[8]);
257
197
  /**
258
198
  * Determine whether or not two matrices are exactly equivalent.
259
199
  * @param a - The first matrix.
260
200
  * @param b - The second matrix.
261
201
  * @returns Whether or not the matrices are equivalent.
202
+ * @public
262
203
  */
263
- export const exactEquals = (a, b) => {
264
- return (a[0] === b[0] &&
265
- a[1] === b[1] &&
266
- a[2] === b[2] &&
267
- a[3] === b[3] &&
268
- a[4] === b[4] &&
269
- a[5] === b[5] &&
270
- a[6] === b[6] &&
271
- a[7] === b[7] &&
272
- a[8] === b[8]);
273
- };
204
+ export const exactEquals = (a, b) => a[0] === b[0] &&
205
+ a[1] === b[1] &&
206
+ a[2] === b[2] &&
207
+ a[3] === b[3] &&
208
+ a[4] === b[4] &&
209
+ a[5] === b[5] &&
210
+ a[6] === b[6] &&
211
+ a[7] === b[7] &&
212
+ a[8] === b[8];
274
213
  /**
275
214
  * Add two matrices.
276
215
  * @param a - The augend.
277
216
  * @param b - The addend.
278
217
  * @param out - The matrix to store the result in.
279
218
  * @returns The sum.
280
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
219
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
220
+ * @public
281
221
  */
282
- export const add = (a, b, out) => {
283
- out[0] = a[0] + b[0];
284
- out[1] = a[1] + b[1];
285
- out[2] = a[2] + b[2];
286
- out[3] = a[3] + b[3];
287
- out[4] = a[4] + b[4];
288
- out[5] = a[5] + b[5];
289
- out[6] = a[6] + b[6];
290
- out[7] = a[7] + b[7];
291
- out[8] = a[8] + b[8];
292
- return out;
293
- };
222
+ export const add = (a, b, out) => fromValues(a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3], a[4] + b[4], a[5] + b[5], a[6] + b[6], a[7] + b[7], a[8] + b[8], out);
294
223
  /**
295
224
  * Calculate the adjugate of a matrix.
296
225
  * @param matrix - The matrix.
297
226
  * @param out - The matrix to store the result in.
298
227
  * @returns The adjugate of the matrix.
299
- * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
228
+ * @see {@link https://en.wikipedia.org/wiki/Adjugate_matrix | Adjugate matrix}
229
+ * @public
300
230
  */
301
231
  export const adjoint = (matrix, out) => {
302
232
  const a00 = matrix[0];
@@ -308,51 +238,52 @@ export const adjoint = (matrix, out) => {
308
238
  const a20 = matrix[6];
309
239
  const a21 = matrix[7];
310
240
  const a22 = matrix[8];
311
- out[0] = a11 * a22 - a12 * a21;
312
- out[1] = a02 * a21 - a01 * a22;
313
- out[2] = a01 * a12 - a02 * a11;
314
- out[3] = a12 * a20 - a10 * a22;
315
- out[4] = a00 * a22 - a02 * a20;
316
- out[5] = a02 * a10 - a00 * a12;
317
- out[6] = a10 * a21 - a11 * a20;
318
- out[7] = a01 * a20 - a00 * a21;
319
- out[8] = a00 * a11 - a01 * a10;
320
- return out;
241
+ return fromValues(a11 * a22 - a12 * a21, a02 * a21 - a01 * a22, a01 * a12 - a02 * a11, a12 * a20 - a10 * a22, a00 * a22 - a02 * a20, a02 * a10 - a00 * a12, a10 * a21 - a11 * a20, a01 * a20 - a00 * a21, a00 * a11 - a01 * a10, out);
321
242
  };
322
243
  /**
323
244
  * Copy the values of one matrix into another.
324
245
  * @param matrix - The matrix to copy.
325
246
  * @param out - The matrix to store the result in.
326
- * @returns This matrix.
247
+ * @returns The copy matrix.
248
+ * @public
327
249
  */
328
- export const copy = (matrix, out) => {
329
- out[0] = matrix[0];
330
- out[1] = matrix[1];
331
- out[2] = matrix[2];
332
- out[3] = matrix[3];
333
- out[4] = matrix[4];
334
- out[5] = matrix[5];
335
- out[6] = matrix[6];
336
- out[7] = matrix[7];
337
- out[8] = matrix[8];
338
- return out;
339
- };
250
+ export const copy = (matrix, out) => fromValues(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6], matrix[7], matrix[8], out);
340
251
  /**
341
252
  * Calculate the Frobenius norm of a matrix.
342
253
  * @param matrix - The matrix.
343
254
  * @returns The Frobenius norm.
344
- * @see [Matrix norm](https://en.wikipedia.org/wiki/Matrix_norm)
255
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
256
+ * @public
345
257
  */
346
258
  export const frob = (matrix) => {
347
- return Math.hypot(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6], matrix[7], matrix[8]);
259
+ const a00 = matrix[0];
260
+ const a01 = matrix[1];
261
+ const a02 = matrix[2];
262
+ const a10 = matrix[3];
263
+ const a11 = matrix[4];
264
+ const a12 = matrix[5];
265
+ const a20 = matrix[6];
266
+ const a21 = matrix[7];
267
+ const a22 = matrix[8];
268
+ // `Math.hypot` is slower.
269
+ return Math.sqrt(a00 * a00 +
270
+ a01 * a01 +
271
+ a02 * a02 +
272
+ a10 * a10 +
273
+ a11 * a11 +
274
+ a12 * a12 +
275
+ a20 * a20 +
276
+ a21 * a21 +
277
+ a22 * a22);
348
278
  };
349
279
  /**
350
280
  * Multiply two matrices.
351
- * @param a - The multiplicand.
352
- * @param b - The multiplier.
281
+ * @param a - The multiplier.
282
+ * @param b - The multiplicand.
353
283
  * @param out - The matrix to store the result in.
354
284
  * @returns The product of the matrices.
355
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
285
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
286
+ * @public
356
287
  */
357
288
  export const multiply = (a, b, out) => {
358
289
  const a00 = a[0];
@@ -373,16 +304,7 @@ export const multiply = (a, b, out) => {
373
304
  const b20 = b[6];
374
305
  const b21 = b[7];
375
306
  const b22 = b[8];
376
- out[0] = b00 * a00 + b01 * a10 + b02 * a20;
377
- out[1] = b00 * a01 + b01 * a11 + b02 * a21;
378
- out[2] = b00 * a02 + b01 * a12 + b02 * a22;
379
- out[3] = b10 * a00 + b11 * a10 + b12 * a20;
380
- out[4] = b10 * a01 + b11 * a11 + b12 * a21;
381
- out[5] = b10 * a02 + b11 * a12 + b12 * a22;
382
- out[6] = b20 * a00 + b21 * a10 + b22 * a20;
383
- out[7] = b20 * a01 + b21 * a11 + b22 * a21;
384
- out[8] = b20 * a02 + b21 * a12 + b22 * a22;
385
- return out;
307
+ return fromValues(b00 * a00 + b01 * a10 + b02 * a20, b00 * a01 + b01 * a11 + b02 * a21, b00 * a02 + b01 * a12 + b02 * a22, b10 * a00 + b11 * a10 + b12 * a20, b10 * a01 + b11 * a11 + b12 * a21, b10 * a02 + b11 * a12 + b12 * a22, b20 * a00 + b21 * a10 + b22 * a20, b20 * a01 + b21 * a11 + b22 * a21, b20 * a02 + b21 * a12 + b22 * a22, out);
386
308
  };
387
309
  /**
388
310
  * Multiply a matrix by a scalar value.
@@ -390,20 +312,10 @@ export const multiply = (a, b, out) => {
390
312
  * @param scalar - The multiplier.
391
313
  * @param out - The matrix to store the result in.
392
314
  * @returns The product.
393
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
315
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
316
+ * @public
394
317
  */
395
- export const multiplyScalar = (matrix, scalar, out) => {
396
- out[0] = matrix[0] * scalar;
397
- out[1] = matrix[1] * scalar;
398
- out[2] = matrix[2] * scalar;
399
- out[3] = matrix[3] * scalar;
400
- out[4] = matrix[4] * scalar;
401
- out[5] = matrix[5] * scalar;
402
- out[6] = matrix[6] * scalar;
403
- out[7] = matrix[7] * scalar;
404
- out[8] = matrix[8] * scalar;
405
- return out;
406
- };
318
+ export const multiplyScalar = (matrix, scalar, out) => fromValues(matrix[0] * scalar, matrix[1] * scalar, matrix[2] * scalar, matrix[3] * scalar, matrix[4] * scalar, matrix[5] * scalar, matrix[6] * scalar, matrix[7] * scalar, matrix[8] * scalar, out);
407
319
  /**
408
320
  * Add a matrix to another after multiplying the other by a scalar.
409
321
  * @param a - The augend.
@@ -411,47 +323,28 @@ export const multiplyScalar = (matrix, scalar, out) => {
411
323
  * @param scalar - The multiplier.
412
324
  * @param out - The matrix to store the result in.
413
325
  * @returns The sum.
414
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
415
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
326
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
327
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
328
+ * @public
416
329
  */
417
- export const multiplyScalarAndAdd = (a, b, scalar, out) => {
418
- out[0] = a[0] + b[0] * scalar;
419
- out[1] = a[1] + b[1] * scalar;
420
- out[2] = a[2] + b[2] * scalar;
421
- out[3] = a[3] + b[3] * scalar;
422
- out[4] = a[4] + b[4] * scalar;
423
- out[5] = a[5] + b[5] * scalar;
424
- out[6] = a[6] + b[6] * scalar;
425
- out[7] = a[7] + b[7] * scalar;
426
- out[8] = a[8] + b[8] * scalar;
427
- return out;
428
- };
330
+ export const multiplyScalarAndAdd = (a, b, scalar, out) => fromValues(a[0] + b[0] * scalar, a[1] + b[1] * scalar, a[2] + b[2] * scalar, a[3] + b[3] * scalar, a[4] + b[4] * scalar, a[5] + b[5] * scalar, a[6] + b[6] * scalar, a[7] + b[7] * scalar, a[8] + b[8] * scalar, out);
429
331
  /**
430
332
  * Subtract two matrices.
431
333
  * @param a - The minuend.
432
334
  * @param b - The subtrahend.
433
335
  * @param out - The matrix to store the result in.
434
336
  * @returns The difference.
435
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
337
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
338
+ * @public
436
339
  */
437
- export const subtract = (a, b, out) => {
438
- out[0] = a[0] - b[0];
439
- out[1] = a[1] - b[1];
440
- out[2] = a[2] - b[2];
441
- out[3] = a[3] - b[3];
442
- out[4] = a[4] - b[4];
443
- out[5] = a[5] - b[5];
444
- out[6] = a[6] - b[6];
445
- out[7] = a[7] - b[7];
446
- out[8] = a[8] - b[8];
447
- return out;
448
- };
340
+ export const subtract = (a, b, out) => fromValues(a[0] - b[0], a[1] - b[1], a[2] - b[2], a[3] - b[3], a[4] - b[4], a[5] - b[5], a[6] - b[6], a[7] - b[7], a[8] - b[8], out);
449
341
  /**
450
342
  * Transpose a matrix.
451
343
  * @param matrix - The matrix.
452
344
  * @param out - The matrix to store the result in.
453
345
  * @returns The transpose of the matrix.
454
- * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
346
+ * @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
347
+ * @public
455
348
  */
456
349
  export const transpose = (matrix, out) => {
457
350
  if (out === matrix) {
@@ -464,64 +357,43 @@ export const transpose = (matrix, out) => {
464
357
  out[5] = matrix[7];
465
358
  out[6] = a02;
466
359
  out[7] = a12;
360
+ return out;
467
361
  }
468
- else {
469
- out[0] = matrix[0];
470
- out[1] = matrix[3];
471
- out[2] = matrix[6];
472
- out[3] = matrix[1];
473
- out[4] = matrix[4];
474
- out[5] = matrix[7];
475
- out[6] = matrix[2];
476
- out[7] = matrix[5];
477
- out[8] = matrix[8];
478
- }
479
- return out;
362
+ return fromValues(matrix[0], matrix[3], matrix[6], matrix[1], matrix[4], matrix[7], matrix[2], matrix[5], matrix[8], out);
480
363
  };
481
364
  /**
482
365
  * Calculate the determinant of a matrix.
483
366
  * @param matrix - The matrix.
484
367
  * @returns The determinant.
485
- * @see [Determinant](https://en.wikipedia.org/wiki/Determinant)
368
+ * @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
369
+ * @public
486
370
  */
487
371
  export const determinant = (matrix) => {
488
- const a00 = matrix[0];
489
- const a01 = matrix[1];
490
- const a02 = matrix[2];
491
372
  const a10 = matrix[3];
492
373
  const a11 = matrix[4];
493
374
  const a12 = matrix[5];
494
375
  const a20 = matrix[6];
495
376
  const a21 = matrix[7];
496
377
  const a22 = matrix[8];
497
- return (a00 * (a22 * a11 - a12 * a21) +
498
- a01 * (-a22 * a10 + a12 * a20) +
499
- a02 * (a21 * a10 - a11 * a20));
378
+ return (matrix[0] * (a22 * a11 - a12 * a21) +
379
+ matrix[1] * (-a22 * a10 + a12 * a20) +
380
+ matrix[2] * (a21 * a10 - a11 * a20));
500
381
  };
501
382
  /**
502
383
  * Reset a matrix to identity.
503
384
  * @param out - The matrix to store the result in.
504
385
  * @returns The matrix.
505
- * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
386
+ * @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
387
+ * @public
506
388
  */
507
- export const identity = (out) => {
508
- out[0] = 1;
509
- out[1] = 0;
510
- out[2] = 0;
511
- out[3] = 0;
512
- out[4] = 1;
513
- out[5] = 0;
514
- out[6] = 0;
515
- out[7] = 0;
516
- out[8] = 1;
517
- return out;
518
- };
389
+ export const identity = (out) => fromValues(1, 0, 0, 0, 1, 0, 0, 0, 1, out);
519
390
  /**
520
391
  * Invert a matrix.
521
392
  * @param matrix - The matrix.
522
393
  * @param out - The matrix to store the result in.
523
394
  * @returns The inverted matrix.
524
- * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
395
+ * @see {@link https://en.wikipedia.org/wiki/Invertible_matrix | Invertible matrix}
396
+ * @public
525
397
  */
526
398
  export const invert = (matrix, out) => {
527
399
  const a00 = matrix[0];
@@ -541,16 +413,7 @@ export const invert = (matrix, out) => {
541
413
  throw new SingularMatrixError();
542
414
  }
543
415
  det = 1 / det;
544
- out[0] = b01 * det;
545
- out[1] = (-a22 * a01 + a02 * a21) * det;
546
- out[2] = (a12 * a01 - a02 * a11) * det;
547
- out[3] = b11 * det;
548
- out[4] = (a22 * a00 - a02 * a20) * det;
549
- out[5] = (-a12 * a00 + a02 * a10) * det;
550
- out[6] = b21 * det;
551
- out[7] = (-a21 * a00 + a01 * a20) * det;
552
- out[8] = (a11 * a00 - a01 * a10) * det;
553
- return out;
416
+ return fromValues(b01 * det, (-a22 * a01 + a02 * a21) * det, (a12 * a01 - a02 * a11) * det, b11 * det, (a22 * a00 - a02 * a20) * det, (-a12 * a00 + a02 * a10) * det, b21 * det, (-a21 * a00 + a01 * a20) * det, (a11 * a00 - a01 * a10) * det, out);
554
417
  };
555
418
  /**
556
419
  * Rotate a matrix by the given angle around the Z-axis.
@@ -558,7 +421,8 @@ export const invert = (matrix, out) => {
558
421
  * @param radians - The angle in radians.
559
422
  * @param out - The matrix to store the result in.
560
423
  * @returns The rotated matrix.
561
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
424
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
425
+ * @public
562
426
  */
563
427
  export const rotate = (matrix, radians, out) => {
564
428
  const a00 = matrix[0];
@@ -567,21 +431,9 @@ export const rotate = (matrix, radians, out) => {
567
431
  const a10 = matrix[3];
568
432
  const a11 = matrix[4];
569
433
  const a12 = matrix[5];
570
- const a20 = matrix[6];
571
- const a21 = matrix[7];
572
- const a22 = matrix[8];
573
434
  const s = Math.sin(radians);
574
435
  const c = Math.cos(radians);
575
- out[0] = c * a00 + s * a10;
576
- out[1] = c * a01 + s * a11;
577
- out[2] = c * a02 + s * a12;
578
- out[3] = c * a10 - s * a00;
579
- out[4] = c * a11 - s * a01;
580
- out[5] = c * a12 - s * a02;
581
- out[6] = a20;
582
- out[7] = a21;
583
- out[8] = a22;
584
- return out;
436
+ return fromValues(c * a00 + s * a10, c * a01 + s * a11, c * a02 + s * a12, c * a10 - s * a00, c * a11 - s * a01, c * a12 - s * a02, matrix[6], matrix[7], matrix[8], out);
585
437
  };
586
438
  /**
587
439
  * Scale a matrix by the given vector.
@@ -589,21 +441,13 @@ export const rotate = (matrix, radians, out) => {
589
441
  * @param vector - The scaling vector.
590
442
  * @param out - The matrix to store the result in.
591
443
  * @returns The scaled matrix.
592
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
444
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
445
+ * @public
593
446
  */
594
447
  export const scale = (matrix, vector, out) => {
595
448
  const x = vector[0];
596
449
  const y = vector[1];
597
- out[0] = matrix[0] * x;
598
- out[1] = matrix[1] * x;
599
- out[2] = matrix[2] * x;
600
- out[3] = matrix[3] * y;
601
- out[4] = matrix[4] * y;
602
- out[5] = matrix[5] * y;
603
- out[6] = matrix[6];
604
- out[7] = matrix[7];
605
- out[8] = matrix[8];
606
- return out;
450
+ return fromValues(matrix[0] * x, matrix[1] * x, matrix[2] * x, matrix[3] * y, matrix[4] * y, matrix[5] * y, matrix[6], matrix[7], matrix[8], out);
607
451
  };
608
452
  /**
609
453
  * Translate a matrix by the given vector.
@@ -611,7 +455,8 @@ export const scale = (matrix, vector, out) => {
611
455
  * @param vector - The translation vector.
612
456
  * @param out - The matrix to store the result in.
613
457
  * @returns The translated matrix.
614
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
458
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
459
+ * @public
615
460
  */
616
461
  export const translate = (matrix, vector, out) => {
617
462
  const a00 = matrix[0];
@@ -620,25 +465,14 @@ export const translate = (matrix, vector, out) => {
620
465
  const a10 = matrix[3];
621
466
  const a11 = matrix[4];
622
467
  const a12 = matrix[5];
623
- const a20 = matrix[6];
624
- const a21 = matrix[7];
625
- const a22 = matrix[8];
626
468
  const x = vector[0];
627
469
  const y = vector[1];
628
- out[0] = a00;
629
- out[1] = a01;
630
- out[2] = a02;
631
- out[3] = a10;
632
- out[4] = a11;
633
- out[5] = a12;
634
- out[6] = x * a00 + y * a10 + a20;
635
- out[7] = x * a01 + y * a11 + a21;
636
- out[8] = x * a02 + y * a12 + a22;
637
- return out;
470
+ return fromValues(a00, a01, a02, a10, a11, a12, x * a00 + y * a10 + matrix[6], x * a01 + y * a11 + matrix[7], x * a02 + y * a12 + matrix[8], out);
638
471
  };
639
472
  /**
640
473
  * A three-by-three matrix.
641
- * @see [Matrix](https://en.wikipedia.org/wiki/Matrix_(mathematics))
474
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_(mathematics) | Matrix}
475
+ * @public
642
476
  */
643
477
  export default class Matrix3 extends Float32Array {
644
478
  /**
@@ -646,7 +480,7 @@ export default class Matrix3 extends Float32Array {
646
480
  * @param r - The angle in radians.
647
481
  * @param out - The matrix to store the result in.
648
482
  * @returns The transformation matrix.
649
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
483
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
650
484
  */
651
485
  static fromRotation(r, out = new Matrix3()) {
652
486
  return fromRotation(r, out);
@@ -656,7 +490,7 @@ export default class Matrix3 extends Float32Array {
656
490
  * @param vector - The scaling vector.
657
491
  * @param out - The matrix to store the result in.
658
492
  * @returns The transformation matrix.
659
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
493
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
660
494
  */
661
495
  static fromScaling(vector, out = new Matrix3()) {
662
496
  return fromScaling(vector, out);
@@ -666,7 +500,7 @@ export default class Matrix3 extends Float32Array {
666
500
  * @param vector - The translation vector.
667
501
  * @param out - The matrix to store the result in.
668
502
  * @returns The transformation matrix.
669
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
503
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
670
504
  */
671
505
  static fromTranslation(vector, out = new Matrix3()) {
672
506
  return fromTranslation(vector, out);
@@ -676,18 +510,31 @@ export default class Matrix3 extends Float32Array {
676
510
  * @param quaternion - The quaternion.
677
511
  * @param out - The matrix to store the result in.
678
512
  * @returns The transformation matrix.
679
- * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
680
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
513
+ * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
514
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
681
515
  */
682
516
  static fromQuaternion(quaternion, out = new Matrix3()) {
683
517
  return fromQuaternion(quaternion, out);
684
518
  }
519
+ /**
520
+ * Create a transformation matrix that represents a rotation by the given z-y'-x" (intrinsic) Tait-Bryan angles.
521
+ * @param z - The z (roll) angle.
522
+ * @param y - The y (pitch) angle.
523
+ * @param x - The x (yaw) angle.
524
+ * @param out - The matrix to store the result in.
525
+ * @returns The transformation matrix.
526
+ * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
527
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
528
+ */
529
+ static fromEuler(z, y, x, out = new Matrix3()) {
530
+ return fromEuler(z, y, x, out);
531
+ }
685
532
  /**
686
533
  * Calculate a three-by-three normal (inverse transpose) matrix from a four-by-four matrix.
687
534
  * @param matrix - The four-by-four matrix.
688
535
  * @param out - The matrix to store the result in.
689
536
  * @returns The normal matrix.
690
- * @see [Normal matrix](https://en.wikipedia.org/wiki/Normal_matrix)
537
+ * @see {@link https://en.wikipedia.org/wiki/Normal_matrix | Normal matrix}
691
538
  */
692
539
  static normalFromMatrix4(matrix, out = new Matrix3()) {
693
540
  return normalFromMatrix4(matrix, out);
@@ -698,8 +545,8 @@ export default class Matrix3 extends Float32Array {
698
545
  * @param height - The height of the projection.
699
546
  * @param out - The matrix to store the result in.
700
547
  * @returns The projection matrix.
701
- * @see [Camera matrix](https://en.wikipedia.org/wiki/Camera_matrix)
702
- * @see [3D projection](https://en.wikipedia.org/wiki/3D_projection)
548
+ * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
549
+ * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
703
550
  */
704
551
  static projection(width, height, out = new Matrix3()) {
705
552
  return projection(width, height, out);
@@ -732,7 +579,7 @@ export default class Matrix3 extends Float32Array {
732
579
  }
733
580
  /**
734
581
  * Create a three-by-three identity matrix.
735
- * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
582
+ * @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
736
583
  */
737
584
  constructor() {
738
585
  super(9);
@@ -785,7 +632,7 @@ export default class Matrix3 extends Float32Array {
785
632
  * @param matrix - The other matrix.
786
633
  * @param out - The matrix to store the result in.
787
634
  * @returns The sum of the matrices.
788
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
635
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
789
636
  */
790
637
  add(matrix, out = new Matrix3()) {
791
638
  return add(this, matrix, out);
@@ -794,7 +641,7 @@ export default class Matrix3 extends Float32Array {
794
641
  * Calculate the adjugate of this matrix.
795
642
  * @param out - The matrix to store the result in.
796
643
  * @returns The adjugate of this matrix.
797
- * @see [Adjugate matrix](https://en.wikipedia.org/wiki/Adjugate_matrix)
644
+ * @see {@link https://en.wikipedia.org/wiki/Adjugate_matrix | Adjugate matrix}
798
645
  */
799
646
  adjoint(out = new Matrix3()) {
800
647
  return adjoint(this, out);
@@ -817,7 +664,7 @@ export default class Matrix3 extends Float32Array {
817
664
  }
818
665
  /**
819
666
  * Get the Frobenius norm of this matrix.
820
- * @see [Matrix norm](https://en.wikipedia.org/wiki/Matrix_norm)
667
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
821
668
  */
822
669
  get frob() {
823
670
  return frob(this);
@@ -827,7 +674,7 @@ export default class Matrix3 extends Float32Array {
827
674
  * @param matrix - The other matrix.
828
675
  * @param out - The matrix to store the result in.
829
676
  * @returns The product of the matrices.
830
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
677
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
831
678
  */
832
679
  multiply(matrix, out = new Matrix3()) {
833
680
  return multiply(this, matrix, out);
@@ -837,7 +684,7 @@ export default class Matrix3 extends Float32Array {
837
684
  * @param scalar - The scalar value.
838
685
  * @param out - The matrix to store the result in.
839
686
  * @returns The product of the matrix and the scalar value.
840
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
687
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
841
688
  */
842
689
  multiplyScalar(scalar, out = new Matrix3()) {
843
690
  return multiplyScalar(this, scalar, out);
@@ -848,8 +695,8 @@ export default class Matrix3 extends Float32Array {
848
695
  * @param scalar - The scalar.
849
696
  * @param out - The matrix to store the result in.
850
697
  * @returns The sum.
851
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
852
- * @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
698
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
699
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
853
700
  */
854
701
  multiplyScalarAndAdd(matrix, scalar, out = new Matrix3()) {
855
702
  return multiplyScalarAndAdd(this, matrix, scalar, out);
@@ -859,7 +706,7 @@ export default class Matrix3 extends Float32Array {
859
706
  * @param matrix - The other matrix.
860
707
  * @param out - The matrix to store the result in.
861
708
  * @returns The difference between the matrices.
862
- * @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
709
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
863
710
  */
864
711
  subtract(matrix, out = new Matrix3()) {
865
712
  return subtract(this, matrix, out);
@@ -868,14 +715,14 @@ export default class Matrix3 extends Float32Array {
868
715
  * Transpose this matrix.
869
716
  * @param out - The matrix to store the result in.
870
717
  * @returns The transpose of this matrix.
871
- * @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
718
+ * @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
872
719
  */
873
720
  transpose(out = new Matrix3()) {
874
721
  return transpose(this, out);
875
722
  }
876
723
  /**
877
724
  * Get the determinant of this matrix.
878
- * @see [Determinant](https://en.wikipedia.org/wiki/Determinant)
725
+ * @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
879
726
  */
880
727
  get determinant() {
881
728
  return determinant(this);
@@ -883,7 +730,7 @@ export default class Matrix3 extends Float32Array {
883
730
  /**
884
731
  * Reset this matrix to identity.
885
732
  * @returns This matrix.
886
- * @see [Identity matrix](https://en.wikipedia.org/wiki/Identity_matrix)
733
+ * @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
887
734
  */
888
735
  identity() {
889
736
  return identity(this);
@@ -892,7 +739,7 @@ export default class Matrix3 extends Float32Array {
892
739
  * Invert this matrix.
893
740
  * @param out - The matrix to store the result in.
894
741
  * @returns The inverted matrix.
895
- * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
742
+ * @see {@link https://en.wikipedia.org/wiki/Invertible_matrix | Invertible matrix}
896
743
  */
897
744
  invert(out = new Matrix3()) {
898
745
  return invert(this, out);
@@ -902,7 +749,7 @@ export default class Matrix3 extends Float32Array {
902
749
  * @param r - The angle in radians.
903
750
  * @param out - The matrix to store the result in.
904
751
  * @returns The rotated matrix.
905
- * @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
752
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
906
753
  */
907
754
  rotate(r, out = new Matrix3()) {
908
755
  return rotate(this, r, out);
@@ -912,7 +759,7 @@ export default class Matrix3 extends Float32Array {
912
759
  * @param vector - The scaling vector.
913
760
  * @param out - The matrix to store the result in.
914
761
  * @returns The scaled matrix.
915
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
762
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
916
763
  */
917
764
  scale(vector, out = new Matrix3()) {
918
765
  return scale(this, vector, out);
@@ -922,7 +769,7 @@ export default class Matrix3 extends Float32Array {
922
769
  * @param vector - The translation vector.
923
770
  * @param out - The matrix to store the result in.
924
771
  * @returns The translated matrix.
925
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
772
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
926
773
  */
927
774
  translate(vector, out = new Matrix3()) {
928
775
  return translate(this, vector, out);