@lakuna/umath 1.5.0 → 3.0.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 (101) hide show
  1. package/LICENSE +1 -1
  2. package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
  3. package/dist/algorithms/greatestCommonDivisor.js +14 -4
  4. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  5. package/dist/index.d.ts +15 -11
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +6 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/linalg/DualQuaternion.d.ts +131 -154
  10. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  11. package/dist/linalg/DualQuaternion.js +188 -203
  12. package/dist/linalg/DualQuaternion.js.map +1 -1
  13. package/dist/linalg/Matrix.d.ts +24 -24
  14. package/dist/linalg/Matrix.d.ts.map +1 -1
  15. package/dist/linalg/Matrix2.d.ts +74 -88
  16. package/dist/linalg/Matrix2.d.ts.map +1 -1
  17. package/dist/linalg/Matrix2.js +114 -124
  18. package/dist/linalg/Matrix2.js.map +1 -1
  19. package/dist/linalg/Matrix3.d.ts +118 -139
  20. package/dist/linalg/Matrix3.d.ts.map +1 -1
  21. package/dist/linalg/Matrix3.js +169 -201
  22. package/dist/linalg/Matrix3.js.map +1 -1
  23. package/dist/linalg/Matrix4.d.ts +217 -257
  24. package/dist/linalg/Matrix4.d.ts.map +1 -1
  25. package/dist/linalg/Matrix4.js +310 -374
  26. package/dist/linalg/Matrix4.js.map +1 -1
  27. package/dist/linalg/Quaternion.d.ts +120 -151
  28. package/dist/linalg/Quaternion.d.ts.map +1 -1
  29. package/dist/linalg/Quaternion.js +187 -204
  30. package/dist/linalg/Quaternion.js.map +1 -1
  31. package/dist/linalg/SlowMatrix.d.ts +5 -5
  32. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  33. package/dist/linalg/SlowMatrix.js +63 -89
  34. package/dist/linalg/SlowMatrix.js.map +1 -1
  35. package/dist/linalg/SlowSquareMatrix.d.ts +6 -6
  36. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  37. package/dist/linalg/SlowSquareMatrix.js +15 -15
  38. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  39. package/dist/linalg/SlowVector.d.ts +165 -0
  40. package/dist/linalg/SlowVector.d.ts.map +1 -0
  41. package/dist/linalg/SlowVector.js +369 -0
  42. package/dist/linalg/SlowVector.js.map +1 -0
  43. package/dist/linalg/SquareMatrix.d.ts +8 -8
  44. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  45. package/dist/linalg/Vector.d.ts +84 -84
  46. package/dist/linalg/Vector.d.ts.map +1 -1
  47. package/dist/linalg/Vector2.d.ts +115 -137
  48. package/dist/linalg/Vector2.d.ts.map +1 -1
  49. package/dist/linalg/Vector2.js +164 -188
  50. package/dist/linalg/Vector2.js.map +1 -1
  51. package/dist/linalg/Vector3.d.ts +141 -167
  52. package/dist/linalg/Vector3.d.ts.map +1 -1
  53. package/dist/linalg/Vector3.js +200 -237
  54. package/dist/linalg/Vector3.js.map +1 -1
  55. package/dist/linalg/Vector4.d.ts +111 -131
  56. package/dist/linalg/Vector4.d.ts.map +1 -1
  57. package/dist/linalg/Vector4.js +163 -187
  58. package/dist/linalg/Vector4.js.map +1 -1
  59. package/dist/types/AxisAngle.d.ts +2 -2
  60. package/dist/types/AxisAngle.d.ts.map +1 -1
  61. package/dist/types/FieldOfView.d.ts +2 -2
  62. package/dist/types/FieldOfView.d.ts.map +1 -1
  63. package/dist/utility/BigNumber.d.ts +21 -11
  64. package/dist/utility/BigNumber.d.ts.map +1 -1
  65. package/dist/utility/BigNumber.js +42 -31
  66. package/dist/utility/BigNumber.js.map +1 -1
  67. package/dist/utility/MatrixSizeError.d.ts +1 -1
  68. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  69. package/dist/utility/MatrixSizeError.js +1 -1
  70. package/dist/utility/MatrixSizeError.js.map +1 -1
  71. package/dist/utility/VectorSizeError.d.ts +12 -0
  72. package/dist/utility/VectorSizeError.d.ts.map +1 -0
  73. package/dist/utility/VectorSizeError.js +15 -0
  74. package/dist/utility/VectorSizeError.js.map +1 -0
  75. package/dist/utility/createAxisAngleLike.d.ts +10 -0
  76. package/dist/utility/createAxisAngleLike.d.ts.map +1 -0
  77. package/dist/utility/createAxisAngleLike.js +10 -0
  78. package/dist/utility/createAxisAngleLike.js.map +1 -0
  79. package/package.json +11 -11
  80. package/src/algorithms/greatestCommonDivisor.ts +19 -7
  81. package/src/index.ts +24 -13
  82. package/src/linalg/DualQuaternion.ts +224 -292
  83. package/src/linalg/Matrix.ts +28 -28
  84. package/src/linalg/Matrix2.ts +138 -180
  85. package/src/linalg/Matrix3.ts +211 -286
  86. package/src/linalg/Matrix4.ts +466 -584
  87. package/src/linalg/Quaternion.ts +221 -294
  88. package/src/linalg/SlowMatrix.ts +97 -95
  89. package/src/linalg/SlowSquareMatrix.ts +19 -18
  90. package/src/linalg/SlowVector.ts +450 -0
  91. package/src/linalg/SquareMatrix.ts +9 -9
  92. package/src/linalg/Vector.ts +90 -90
  93. package/src/linalg/Vector2.ts +181 -266
  94. package/src/linalg/Vector3.ts +230 -342
  95. package/src/linalg/Vector4.ts +183 -257
  96. package/src/types/AxisAngle.ts +3 -3
  97. package/src/types/FieldOfView.ts +3 -3
  98. package/src/utility/BigNumber.ts +63 -41
  99. package/src/utility/MatrixSizeError.ts +1 -1
  100. package/src/utility/VectorSizeError.ts +14 -0
  101. package/src/utility/createAxisAngleLike.ts +14 -0
@@ -1,19 +1,19 @@
1
- import Quaternion, { fromValues as quaternionFromValues } from "./Quaternion.js";
2
- import Vector3, { createVector3Like, fromValues as vector3FromValues } from "./Vector3.js";
3
- import MagnitudeError from "../utility/MagnitudeError.js";
4
- import SingularMatrixError from "../utility/SingularMatrixError.js";
5
1
  import approx from "../algorithms/approx.js";
6
2
  import approxRelative from "../algorithms/approxRelative.js";
7
3
  import degreesToRadians from "../algorithms/degreesToRadians.js";
8
4
  import epsilon from "../utility/epsilon.js";
5
+ import MagnitudeError from "../utility/MagnitudeError.js";
6
+ import SingularMatrixError from "../utility/SingularMatrixError.js";
7
+ import Quaternion, { fromValues as quaternionFromValues } from "./Quaternion.js";
8
+ import Vector3, { createVector3Like, fromValues as vector3FromValues } from "./Vector3.js";
9
9
  /**
10
10
  * Create a four-by-four matrix-like object.
11
11
  * @returns A four-by-four matrix-like object.
12
12
  * @public
13
13
  */
14
- export const createMatrix4Like = () => {
15
- return new Float32Array(16);
16
- };
14
+ export const createMatrix4Like = () =>
15
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
16
+ new Float32Array(16);
17
17
  /**
18
18
  * Create a four-by-four matrix with the given values.
19
19
  * @param c0r0 - The value in the first column and first row.
@@ -94,7 +94,7 @@ export const fromRotation = (radians, axis, out) => {
94
94
  let x = axis[0];
95
95
  let y = axis[1];
96
96
  let z = axis[2];
97
- let len = Math.sqrt(x * x + y * y + z * z);
97
+ let len = Math.hypot(x, y, z);
98
98
  if (len === 0) {
99
99
  throw new MagnitudeError();
100
100
  }
@@ -115,6 +115,7 @@ export const fromRotation = (radians, axis, out) => {
115
115
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
116
116
  * @public
117
117
  */
118
+ // eslint-disable-next-line @typescript-eslint/naming-convention
118
119
  export const fromXRotation = (radians, out) => {
119
120
  const s = Math.sin(radians);
120
121
  const c = Math.cos(radians);
@@ -128,6 +129,7 @@ export const fromXRotation = (radians, out) => {
128
129
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
129
130
  * @public
130
131
  */
132
+ // eslint-disable-next-line @typescript-eslint/naming-convention
131
133
  export const fromYRotation = (radians, out) => {
132
134
  const s = Math.sin(radians);
133
135
  const c = Math.cos(radians);
@@ -141,6 +143,7 @@ export const fromYRotation = (radians, out) => {
141
143
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
142
144
  * @public
143
145
  */
146
+ // eslint-disable-next-line @typescript-eslint/naming-convention
144
147
  export const fromZRotation = (radians, out) => {
145
148
  const s = Math.sin(radians);
146
149
  const c = Math.cos(radians);
@@ -516,14 +519,14 @@ export const lookAt = (eye, center, up, out) => {
516
519
  let z0 = eyex - centerx;
517
520
  let z1 = eyey - centery;
518
521
  let z2 = eyez - centerz;
519
- let len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); // `Math.hypot` is slower.
522
+ let len = 1 / Math.hypot(z0, z1, z2);
520
523
  z0 *= len;
521
524
  z1 *= len;
522
525
  z2 *= len;
523
526
  let x0 = upy * z2 - upz * z1;
524
527
  let x1 = upz * z0 - upx * z2;
525
528
  let x2 = upx * z1 - upy * z0;
526
- len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
529
+ len = Math.hypot(x0, x1, x2);
527
530
  if (len) {
528
531
  len = 1 / len;
529
532
  x0 *= len;
@@ -538,7 +541,7 @@ export const lookAt = (eye, center, up, out) => {
538
541
  let y0 = z1 * x2 - z2 * x1;
539
542
  let y1 = z2 * x0 - z0 * x2;
540
543
  let y2 = z0 * x1 - z1 * x0;
541
- len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
544
+ len = Math.hypot(y0, y1, y2);
542
545
  if (len) {
543
546
  len = 1 / len;
544
547
  y0 *= len;
@@ -701,41 +704,7 @@ export const copy = (matrix, out) => fromValues(matrix[0], matrix[1], matrix[2],
701
704
  * @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
702
705
  * @public
703
706
  */
704
- export const frob = (matrix) => {
705
- const a00 = matrix[0];
706
- const a01 = matrix[1];
707
- const a02 = matrix[2];
708
- const a03 = matrix[3];
709
- const a10 = matrix[4];
710
- const a11 = matrix[5];
711
- const a12 = matrix[6];
712
- const a13 = matrix[7];
713
- const a20 = matrix[8];
714
- const a21 = matrix[9];
715
- const a22 = matrix[10];
716
- const a23 = matrix[11];
717
- const a30 = matrix[12];
718
- const a31 = matrix[13];
719
- const a32 = matrix[14];
720
- const a33 = matrix[15];
721
- // `Math.hypot` is slower.
722
- return Math.sqrt(a00 * a00 +
723
- a01 * a01 +
724
- a02 * a02 +
725
- a03 * a03 +
726
- a10 * a10 +
727
- a11 * a11 +
728
- a12 * a12 +
729
- a13 * a13 +
730
- a20 * a20 +
731
- a21 * a21 +
732
- a22 * a22 +
733
- a23 * a23 +
734
- a30 * a30 +
735
- a31 * a31 +
736
- a32 * a32 +
737
- a33 * a33);
738
- };
707
+ export const frob = (matrix) => Math.hypot(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6], matrix[7], matrix[8], matrix[9], matrix[10], matrix[11], matrix[12], matrix[13], matrix[14], matrix[15]);
739
708
  /**
740
709
  * Multiply two matrices.
741
710
  * @param a - The multiplier.
@@ -982,7 +951,7 @@ export const rotate = (matrix, radians, axis, out) => {
982
951
  let x = axis[0];
983
952
  let y = axis[1];
984
953
  let z = axis[2];
985
- let len = Math.sqrt(x * x + y * y + z * z); // `Math.hypot` is slower.
954
+ let len = Math.hypot(x, y, z);
986
955
  if (len < epsilon) {
987
956
  return out;
988
957
  }
@@ -1207,19 +1176,7 @@ export const setTranslation = (matrix, translation, out) => {
1207
1176
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1208
1177
  * @public
1209
1178
  */
1210
- export const getScaling = (matrix, out) => {
1211
- const m11 = matrix[0];
1212
- const m12 = matrix[1];
1213
- const m13 = matrix[2];
1214
- const m21 = matrix[4];
1215
- const m22 = matrix[5];
1216
- const m23 = matrix[6];
1217
- const m31 = matrix[8];
1218
- const m32 = matrix[9];
1219
- const m33 = matrix[10];
1220
- // `Math.hypot` is slower.
1221
- return vector3FromValues(Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13), Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23), Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33), out);
1222
- };
1179
+ export const getScaling = (matrix, out) => vector3FromValues(Math.hypot(matrix[0], matrix[1], matrix[2]), Math.hypot(matrix[4], matrix[5], matrix[6]), Math.hypot(matrix[8], matrix[9], matrix[10]), out);
1223
1180
  /**
1224
1181
  * Get the rotational component of a transformation matrix.
1225
1182
  * @param matrix - The matrix.
@@ -1264,91 +1221,161 @@ export const getRotation = (matrix, out) => {
1264
1221
  * @public
1265
1222
  */
1266
1223
  export default class Matrix4 extends Float32Array {
1224
+ /** The value in the first column and first row. */
1225
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1226
+ 0;
1227
+ /** The value in the first column and second row. */
1228
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1229
+ 1;
1230
+ /** The value in the first column and third row. */
1231
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1232
+ 2;
1233
+ /** The value in the first column and fourth row. */
1234
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1235
+ 3;
1236
+ /** The value in the second column and first row. */
1237
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1238
+ 4;
1239
+ /** The value in the second column and second row. */
1240
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1241
+ 5;
1242
+ /** The value in the second column and third row. */
1243
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1244
+ 6;
1245
+ /** The value in the second column and fourth row. */
1246
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1247
+ 7;
1248
+ /** The value in the third column and first row. */
1249
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1250
+ 8;
1251
+ /** The value in the third column and second row. */
1252
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1253
+ 9;
1254
+ /** The value in the third column and third row. */
1255
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1256
+ 10;
1257
+ /** The value in the third column and fourth row. */
1258
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1259
+ 11;
1260
+ /** The value in the fourth column and first row. */
1261
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1262
+ 12;
1263
+ /** The value in the fourth column and second row. */
1264
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1265
+ 13;
1266
+ /** The value in the fourth column and third row. */
1267
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1268
+ 14;
1269
+ /** The value in the fourth column and fourth row. */
1270
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1271
+ 15;
1272
+ /** The number of rows in this matrix. */
1273
+ height;
1274
+ /** The number of columns in this matrix. */
1275
+ width;
1267
1276
  /**
1268
- * Create a transformation matrix that represents a translation by the given vector.
1269
- * @param vector - The translation vector.
1270
- * @param out - The matrix to store the result in.
1271
- * @returns The transformation matrix.
1277
+ * Get the determinant of this matrix.
1278
+ * @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
1279
+ */
1280
+ get determinant() {
1281
+ return determinant(this);
1282
+ }
1283
+ /**
1284
+ * Get the Frobenius norm of this matrix.
1285
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
1286
+ */
1287
+ get frob() {
1288
+ return frob(this);
1289
+ }
1290
+ /**
1291
+ * Get the scaling vector component of this transformation matrix.
1292
+ * @returns The rotation.
1293
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1294
+ */
1295
+ get rotation() {
1296
+ return getRotation(this, new Quaternion());
1297
+ }
1298
+ /**
1299
+ * Get the scaling vector component of this transformation matrix.
1300
+ * @returns The scaling.
1272
1301
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1273
1302
  */
1274
- static fromTranslation(vector, out = new Matrix4()) {
1275
- return fromTranslation(vector, out);
1303
+ get scaling() {
1304
+ return getScaling(this, new Vector3());
1276
1305
  }
1277
1306
  /**
1278
- * Create a transformation matrix that represents a scaling by the given vector.
1279
- * @param vector - The scaling vector.
1280
- * @param out - The matrix to store the result in.
1281
- * @returns The transformation matrix.
1307
+ * The translation vector component of this transformation matrix.
1282
1308
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1283
1309
  */
1284
- static fromScaling(vector, out = new Matrix4()) {
1285
- return fromScaling(vector, out);
1310
+ get translation() {
1311
+ return getTranslation(this, new Vector3());
1286
1312
  }
1287
1313
  /**
1288
- * Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
1289
- * @param r - The angle in radians.
1290
- * @param axis - The axis to rotate around.
1291
- * @param out - The matrix to store the result in.
1292
- * @returns The transformation matrix.
1293
- * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1314
+ * Create a four-by-four identity matrix.
1315
+ * @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
1294
1316
  */
1295
- static fromRotation(r, axis, out = new Matrix4()) {
1296
- return fromRotation(r, axis, out);
1317
+ constructor() {
1318
+ super(16);
1319
+ this[0] = 1;
1320
+ this[5] = 1;
1321
+ this[10] = 1;
1322
+ this[15] = 1;
1323
+ this.width = 4;
1324
+ this.height = 4;
1297
1325
  }
1298
1326
  /**
1299
- * Create a transformation matrix that represents a rotation by the given angle around the X-axis.
1300
- * @param r - The angle in radians.
1301
- * @param out - The matrix to store the result in.
1327
+ * Create a transformation matrix from a dual quaternion.
1328
+ * @param quaternion - The dual quaternion.
1302
1329
  * @returns The transformation matrix.
1330
+ * @see {@link https://en.wikipedia.org/wiki/Dual_quaternion | Dual quaternion}
1303
1331
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1332
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1304
1333
  */
1305
- static fromXRotation(r, out = new Matrix4()) {
1306
- return fromXRotation(r, out);
1334
+ static fromDualQuaternion(quaternion) {
1335
+ return fromDualQuaternion(quaternion, new Matrix4());
1307
1336
  }
1308
1337
  /**
1309
- * Create a transformation matrix that represents a rotation by the given angle around the Y-axis.
1310
- * @param r - The angle in radians.
1311
- * @param out - The matrix to store the result in.
1338
+ * Create a transformation matrix from a quaternion.
1339
+ * @param quaternion - The quaternion.
1312
1340
  * @returns The transformation matrix.
1313
1341
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1342
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1314
1343
  */
1315
- static fromYRotation(r, out = new Matrix4()) {
1316
- return fromYRotation(r, out);
1344
+ static fromQuaternion(quaternion) {
1345
+ return fromQuaternion(quaternion, new Matrix4());
1317
1346
  }
1318
1347
  /**
1319
1348
  * Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
1320
1349
  * @param r - The angle in radians.
1321
- * @param out - The matrix to store the result in.
1350
+ * @param axis - The axis to rotate around.
1322
1351
  * @returns The transformation matrix.
1323
1352
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1324
1353
  */
1325
- static fromZRotation(r, out = new Matrix4()) {
1326
- return fromZRotation(r, out);
1354
+ static fromRotation(r, axis) {
1355
+ return fromRotation(r, axis, new Matrix4());
1327
1356
  }
1328
1357
  /**
1329
1358
  * Create a transformation matrix from the given rotation and translation.
1330
1359
  * @param rotation - The rotation quaternion.
1331
1360
  * @param translation - The translation vector.
1332
- * @param out - The matrix to store the result in.
1333
1361
  * @returns The transformation matrix.
1334
1362
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1335
1363
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1336
1364
  */
1337
- static fromRotationTranslation(rotation, translation, out = new Matrix4()) {
1338
- return fromRotationTranslation(rotation, translation, out);
1365
+ static fromRotationTranslation(rotation, translation) {
1366
+ return fromRotationTranslation(rotation, translation, new Matrix4());
1339
1367
  }
1340
1368
  /**
1341
1369
  * Create a transformation matrix from the given rotation, translation, and scale.
1342
1370
  * @param rotation - The rotation quaternion.
1343
1371
  * @param translation - The translation vector.
1344
1372
  * @param scaling - The scaling vector.
1345
- * @param out - The matrix to store the result in.
1346
1373
  * @returns The transformation matrix.
1347
1374
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1348
1375
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1349
1376
  */
1350
- static fromRotationTranslationScale(rotation, translation, scaling, out = new Matrix4()) {
1351
- return fromRotationTranslationScale(rotation, translation, scaling, out);
1377
+ static fromRotationTranslationScale(rotation, translation, scaling) {
1378
+ return fromRotationTranslationScale(rotation, translation, scaling, new Matrix4());
1352
1379
  }
1353
1380
  /**
1354
1381
  * Create a transformation matrix from the given rotation, translation, and scale around the given origin.
@@ -1356,36 +1383,83 @@ export default class Matrix4 extends Float32Array {
1356
1383
  * @param translation - The translation vector.
1357
1384
  * @param scaling - The scaling vector.
1358
1385
  * @param origin - The origin vector.
1359
- * @param out - The matrix to store the result in.
1360
1386
  * @returns The transformation matrix.
1361
1387
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1362
1388
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1363
1389
  */
1364
- static fromRotationTranslationScaleOrigin(rotation, translation, scaling, origin, out = new Matrix4()) {
1365
- return fromRotationTranslationScaleOrigin(rotation, translation, scaling, origin, out);
1390
+ static fromRotationTranslationScaleOrigin(rotation, translation, scaling, origin) {
1391
+ return fromRotationTranslationScaleOrigin(rotation, translation, scaling, origin, new Matrix4());
1366
1392
  }
1367
1393
  /**
1368
- * Create a transformation matrix from a dual quaternion.
1369
- * @param quaternion - The dual quaternion.
1370
- * @param out - The matrix to store the result in.
1394
+ * Create a transformation matrix that represents a scaling by the given vector.
1395
+ * @param vector - The scaling vector.
1371
1396
  * @returns The transformation matrix.
1372
- * @see {@link https://en.wikipedia.org/wiki/Dual_quaternion | Dual quaternion}
1373
- * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1374
1397
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1375
1398
  */
1376
- static fromDualQuaternion(quaternion, out = new Matrix4()) {
1377
- return fromDualQuaternion(quaternion, out);
1399
+ static fromScaling(vector) {
1400
+ return fromScaling(vector, new Matrix4());
1378
1401
  }
1379
1402
  /**
1380
- * Create a transformation matrix from a quaternion.
1381
- * @param quaternion - The quaternion.
1382
- * @param out - The matrix to store the result in.
1403
+ * Create a transformation matrix that represents a translation by the given vector.
1404
+ * @param vector - The translation vector.
1383
1405
  * @returns The transformation matrix.
1384
- * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1385
1406
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1386
1407
  */
1387
- static fromQuaternion(quaternion, out = new Matrix4()) {
1388
- return fromQuaternion(quaternion, out);
1408
+ static fromTranslation(vector) {
1409
+ return fromTranslation(vector, new Matrix4());
1410
+ }
1411
+ /**
1412
+ * Create a two-by-two matrix with the given values.
1413
+ * @param c0r0 - The value in the first column and first row.
1414
+ * @param c0r1 - The value in the first column and second row.
1415
+ * @param c0r2 - The value in the first column and third row.
1416
+ * @param c0r3 - The value in the first column and fourth row.
1417
+ * @param c1r0 - The value in the second column and first row.
1418
+ * @param c1r1 - The value in the second column and second row.
1419
+ * @param c1r2 - The value in the second column and third row.
1420
+ * @param c1r3 - The value in the second column and fourth row.
1421
+ * @param c2r0 - The value in the third column and first row.
1422
+ * @param c2r1 - The value in the third column and second row.
1423
+ * @param c2r2 - The value in the third column and third row.
1424
+ * @param c2r3 - The value in the third column and fourth row.
1425
+ * @param c3r0 - The value in the fourth column and first row.
1426
+ * @param c3r1 - The value in the fourth column and second row.
1427
+ * @param c3r2 - The value in the fourth column and third row.
1428
+ * @param c3r3 - The value in the fourth column and fourth row.
1429
+ * @returns The matrix.
1430
+ */
1431
+ static fromValues(c0r0, c0r1, c0r2, c0r3, c1r0, c1r1, c1r2, c1r3, c2r0, c2r1, c2r2, c2r3, c3r0, c3r1, c3r2, c3r3) {
1432
+ return fromValues(c0r0, c0r1, c0r2, c0r3, c1r0, c1r1, c1r2, c1r3, c2r0, c2r1, c2r2, c2r3, c3r0, c3r1, c3r2, c3r3, new Matrix4());
1433
+ }
1434
+ /**
1435
+ * Create a transformation matrix that represents a rotation by the given angle around the X-axis.
1436
+ * @param r - The angle in radians.
1437
+ * @returns The transformation matrix.
1438
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1439
+ */
1440
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1441
+ static fromXRotation(r) {
1442
+ return fromXRotation(r, new Matrix4());
1443
+ }
1444
+ /**
1445
+ * Create a transformation matrix that represents a rotation by the given angle around the Y-axis.
1446
+ * @param r - The angle in radians.
1447
+ * @returns The transformation matrix.
1448
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1449
+ */
1450
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1451
+ static fromYRotation(r) {
1452
+ return fromYRotation(r, new Matrix4());
1453
+ }
1454
+ /**
1455
+ * Create a transformation matrix that represents a rotation by the given angle around the Z-axis.
1456
+ * @param r - The angle in radians.
1457
+ * @returns The transformation matrix.
1458
+ * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1459
+ */
1460
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1461
+ static fromZRotation(r) {
1462
+ return fromZRotation(r, new Matrix4());
1389
1463
  }
1390
1464
  /**
1391
1465
  * Generate a frustum matrix with the given bounds.
@@ -1395,227 +1469,127 @@ export default class Matrix4 extends Float32Array {
1395
1469
  * @param top - The top bound of the frustum.
1396
1470
  * @param near - The near bound of the frustum.
1397
1471
  * @param far - The far bound of the frustum.
1398
- * @param out - The matrix to store the result in.
1399
1472
  * @returns The frustum matrix.
1400
1473
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1401
1474
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1402
1475
  */
1403
- static frustum(left, right, bottom, top, near, far, out = new Matrix4()) {
1404
- return frustum(left, right, bottom, top, near, far, out);
1476
+ static frustum(left, right, bottom, top, near, far) {
1477
+ return frustum(left, right, bottom, top, near, far, new Matrix4());
1405
1478
  }
1406
1479
  /**
1407
- * Create a perspective projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[-1, 1]` (OpenGL/WebGL).
1408
- * @param fov - The vertical field of view in radians.
1409
- * @param aspect - The aspect ratio (typically the width of the viewport divided by its height).
1480
+ * Generate a look-at matrix. If you want a matrix that actually makes an object look at another object, use `targetTo` instead.
1481
+ * @param eye - The position of the viewer.
1482
+ * @param center - The point that the viewer is looking at.
1483
+ * @param up - The local up direction.
1484
+ * @returns The look-at matrix.
1485
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1486
+ */
1487
+ static lookAt(eye, center, up = [0, 1, 0]) {
1488
+ return lookAt(eye, center, up, new Matrix4());
1489
+ }
1490
+ /**
1491
+ * Generate an orthogonal projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[-1, 1]` (OpenGL/WebGL).
1492
+ * @param left - The left bound of the frustum.
1493
+ * @param right - The right bound of the frustum.
1494
+ * @param bottom - The bottom bound of the frustum.
1495
+ * @param top - The top bound of the frustum.
1410
1496
  * @param near - The near bound of the frustum.
1411
1497
  * @param far - The far bound of the frustum.
1412
- * @param out - The matrix to store the result in.
1413
- * @returns The perspective projection matrix.
1498
+ * @returns The frustum matrix.
1414
1499
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1415
1500
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1416
1501
  */
1417
- static perspective(fov, aspect, near, far, out = new Matrix4()) {
1418
- return perspective(fov, aspect, near, far, out);
1502
+ static ortho(left, right, bottom, top, near, far) {
1503
+ return ortho(left, right, bottom, top, near, far, new Matrix4());
1419
1504
  }
1420
1505
  /**
1421
- * Create a perspective projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[0, 1]` (WebGPU/Vulkan/DirectX/Metal).
1422
- * @param fov - The vertical field of view in radians.
1423
- * @param aspect - The aspect ratio (typically the width of the viewport divided by its height).
1506
+ * Generate an orthogonal projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[0, 1]` (WebGPU/Vulkan/DirectX/Metal).
1507
+ * @param left - The left bound of the frustum.
1508
+ * @param right - The right bound of the frustum.
1509
+ * @param bottom - The bottom bound of the frustum.
1510
+ * @param top - The top bound of the frustum.
1424
1511
  * @param near - The near bound of the frustum.
1425
1512
  * @param far - The far bound of the frustum.
1426
- * @param out - The matrix to store the result in.
1427
- * @returns The perspective projection matrix.
1513
+ * @returns The frustum matrix.
1428
1514
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1429
1515
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1430
1516
  */
1431
- static perspectiveGpu(fov, aspect, near, far, out = new Matrix4()) {
1432
- return perspectiveGpu(fov, aspect, near, far, out);
1517
+ static orthoGpu(left, right, bottom, top, near, far) {
1518
+ return orthoGpu(left, right, bottom, top, near, far, new Matrix4());
1433
1519
  }
1434
1520
  /**
1435
- * Create a perspective projection matrix from a field of view. Useful for generating projection matrices to be used with the WebXR API.
1436
- * @param fov - The field of view.
1521
+ * Create a perspective projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[-1, 1]` (OpenGL/WebGL).
1522
+ * @param fov - The vertical field of view in radians.
1523
+ * @param aspect - The aspect ratio (typically the width of the viewport divided by its height).
1437
1524
  * @param near - The near bound of the frustum.
1438
1525
  * @param far - The far bound of the frustum.
1439
- * @param out - The matrix to store the result in.
1440
1526
  * @returns The perspective projection matrix.
1441
1527
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1442
1528
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1443
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API | WebXR API}
1444
1529
  */
1445
- static perspectiveFromFieldOfView(fov, near, far, out = new Matrix4()) {
1446
- return perspectiveFromFieldOfView(fov, near, far, out);
1530
+ static perspective(fov, aspect, near, far) {
1531
+ return perspective(fov, aspect, near, far, new Matrix4());
1447
1532
  }
1448
1533
  /**
1449
- * Generate an orthogonal projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[-1, 1]` (OpenGL/WebGL).
1450
- * @param left - The left bound of the frustum.
1451
- * @param right - The right bound of the frustum.
1452
- * @param bottom - The bottom bound of the frustum.
1453
- * @param top - The top bound of the frustum.
1534
+ * Create a perspective projection matrix from a field of view. Useful for generating projection matrices to be used with the WebXR API.
1535
+ * @param fov - The field of view.
1454
1536
  * @param near - The near bound of the frustum.
1455
1537
  * @param far - The far bound of the frustum.
1456
- * @param out - The matrix to store the result in.
1457
- * @returns The frustum matrix.
1538
+ * @returns The perspective projection matrix.
1458
1539
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1459
1540
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1541
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API | WebXR API}
1460
1542
  */
1461
- static ortho(left, right, bottom, top, near, far, out = new Matrix4()) {
1462
- return ortho(left, right, bottom, top, near, far, out);
1543
+ static perspectiveFromFieldOfView(fov, near, far) {
1544
+ return perspectiveFromFieldOfView(fov, near, far, new Matrix4());
1463
1545
  }
1464
1546
  /**
1465
- * Generate an orthogonal projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[0, 1]` (WebGPU/Vulkan/DirectX/Metal).
1466
- * @param left - The left bound of the frustum.
1467
- * @param right - The right bound of the frustum.
1468
- * @param bottom - The bottom bound of the frustum.
1469
- * @param top - The top bound of the frustum.
1547
+ * Create a perspective projection matrix with the given bounds such that the near and far clip planes correspond to a normalized device coordinate Z range of `[0, 1]` (WebGPU/Vulkan/DirectX/Metal).
1548
+ * @param fov - The vertical field of view in radians.
1549
+ * @param aspect - The aspect ratio (typically the width of the viewport divided by its height).
1470
1550
  * @param near - The near bound of the frustum.
1471
1551
  * @param far - The far bound of the frustum.
1472
- * @param out - The matrix to store the result in.
1473
- * @returns The frustum matrix.
1552
+ * @returns The perspective projection matrix.
1474
1553
  * @see {@link https://en.wikipedia.org/wiki/Camera_matrix | Camera matrix}
1475
1554
  * @see {@link https://en.wikipedia.org/wiki/3D_projection | 3D projection}
1476
1555
  */
1477
- static orthoGpu(left, right, bottom, top, near, far, out = new Matrix4()) {
1478
- return orthoGpu(left, right, bottom, top, near, far, out);
1479
- }
1480
- /**
1481
- * Generate a look-at matrix. If you want a matrix that actually makes an object look at another object, use `targetTo` instead.
1482
- * @param eye - The position of the viewer.
1483
- * @param center - The point that the viewer is looking at.
1484
- * @param up - The local up direction.
1485
- * @param out - The matrix to store the result in.
1486
- * @returns The look-at matrix.
1487
- * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1488
- */
1489
- static lookAt(eye, center, up = [0, 1, 0], out = new Matrix4()) {
1490
- return lookAt(eye, center, up, out);
1556
+ static perspectiveGpu(fov, aspect, near, far) {
1557
+ return perspectiveGpu(fov, aspect, near, far, new Matrix4());
1491
1558
  }
1492
1559
  /**
1493
1560
  * Create a matrix that makes something look at something else.
1494
1561
  * @param eye - The position of the viewer.
1495
1562
  * @param target - The point that the viewer is looking at.
1496
1563
  * @param up - The local up direction.
1497
- * @param out - The matrix to store the result in.
1498
1564
  * @returns The transformation matrix.
1499
1565
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1500
1566
  */
1501
- static targetTo(eye, target, up = [0, 1, 0], out = new Matrix4()) {
1502
- return targetTo(eye, target, up, out);
1503
- }
1504
- /**
1505
- * Create a two-by-two matrix with the given values.
1506
- * @param c0r0 - The value in the first column and first row.
1507
- * @param c0r1 - The value in the first column and second row.
1508
- * @param c0r2 - The value in the first column and third row.
1509
- * @param c0r3 - The value in the first column and fourth row.
1510
- * @param c1r0 - The value in the second column and first row.
1511
- * @param c1r1 - The value in the second column and second row.
1512
- * @param c1r2 - The value in the second column and third row.
1513
- * @param c1r3 - The value in the second column and fourth row.
1514
- * @param c2r0 - The value in the third column and first row.
1515
- * @param c2r1 - The value in the third column and second row.
1516
- * @param c2r2 - The value in the third column and third row.
1517
- * @param c2r3 - The value in the third column and fourth row.
1518
- * @param c3r0 - The value in the fourth column and first row.
1519
- * @param c3r1 - The value in the fourth column and second row.
1520
- * @param c3r2 - The value in the fourth column and third row.
1521
- * @param c3r3 - The value in the fourth column and fourth row.
1522
- * @param out - The matrix to store the result in.
1523
- * @returns The matrix.
1524
- */
1525
- static fromValues(c0r0, c0r1, c0r2, c0r3, c1r0, c1r1, c1r2, c1r3, c2r0, c2r1, c2r2, c2r3, c3r0, c3r1, c3r2, c3r3, out = new Matrix4()) {
1526
- return fromValues(c0r0, c0r1, c0r2, c0r3, c1r0, c1r1, c1r2, c1r3, c2r0, c2r1, c2r2, c2r3, c3r0, c3r1, c3r2, c3r3, out);
1527
- }
1528
- /**
1529
- * Create a four-by-four identity matrix.
1530
- * @see {@link https://en.wikipedia.org/wiki/Identity_matrix | Identity matrix}
1531
- */
1532
- constructor() {
1533
- super(16);
1534
- this[0] = 1;
1535
- this[5] = 1;
1536
- this[10] = 1;
1537
- this[15] = 1;
1538
- this.width = 4;
1539
- this.height = 4;
1540
- }
1541
- /** The value in the first column and first row. */
1542
- 0;
1543
- /** The value in the first column and second row. */
1544
- 1;
1545
- /** The value in the first column and third row. */
1546
- 2;
1547
- /** The value in the first column and fourth row. */
1548
- 3;
1549
- /** The value in the second column and first row. */
1550
- 4;
1551
- /** The value in the second column and second row. */
1552
- 5;
1553
- /** The value in the second column and third row. */
1554
- 6;
1555
- /** The value in the second column and fourth row. */
1556
- 7;
1557
- /** The value in the third column and first row. */
1558
- 8;
1559
- /** The value in the third column and second row. */
1560
- 9;
1561
- /** The value in the third column and third row. */
1562
- 10;
1563
- /** The value in the third column and fourth row. */
1564
- 11;
1565
- /** The value in the fourth column and first row. */
1566
- 12;
1567
- /** The value in the fourth column and second row. */
1568
- 13;
1569
- /** The value in the fourth column and third row. */
1570
- 14;
1571
- /** The value in the fourth column and fourth row. */
1572
- 15;
1573
- /** The number of columns in this matrix. */
1574
- width;
1575
- /** The number of rows in this matrix. */
1576
- height;
1577
- /**
1578
- * Determine whether or not this matrix is roughly equivalent to another.
1579
- * @param matrix - The other matrix.
1580
- * @returns Whether or not the matrices are equivalent.
1581
- */
1582
- equals(matrix) {
1583
- return equals(this, matrix);
1584
- }
1585
- /**
1586
- * Determine whether or not this matrix is exactly equivalent to another.
1587
- * @param matrix - The other matrix.
1588
- * @returns Whether or not the matrices are equivalent.
1589
- */
1590
- exactEquals(matrix) {
1591
- return exactEquals(this, matrix);
1567
+ static targetTo(eye, target, up = [0, 1, 0]) {
1568
+ return targetTo(eye, target, up, new Matrix4());
1592
1569
  }
1593
1570
  /**
1594
1571
  * Add two matrices of the same size.
1595
1572
  * @param matrix - The other matrix.
1596
- * @param out - The matrix to store the result in.
1597
1573
  * @returns The sum of the matrices.
1598
1574
  * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
1599
1575
  */
1600
- add(matrix, out = new Matrix4()) {
1601
- return add(this, matrix, out);
1576
+ add(matrix) {
1577
+ return add(this, matrix, new Matrix4());
1602
1578
  }
1603
1579
  /**
1604
1580
  * Calculate the adjugate of this matrix.
1605
- * @param out - The matrix to store the result in.
1606
1581
  * @returns The adjugate of this matrix.
1607
1582
  * @see {@link https://en.wikipedia.org/wiki/Adjugate_matrix | Adjugate matrix}
1608
1583
  */
1609
- adjoint(out = new Matrix4()) {
1610
- return adjoint(this, out);
1584
+ adjoint() {
1585
+ return adjoint(this, new Matrix4());
1611
1586
  }
1612
1587
  /**
1613
1588
  * Copy the values from this matrix to another one.
1614
- * @param out - The matrix to store the result in.
1615
1589
  * @returns The copy.
1616
1590
  */
1617
- clone(out = new Matrix4()) {
1618
- return copy(this, out);
1591
+ clone() {
1592
+ return copy(this, new Matrix4());
1619
1593
  }
1620
1594
  /**
1621
1595
  * Copy the values of another matrix into this one.
@@ -1626,69 +1600,20 @@ export default class Matrix4 extends Float32Array {
1626
1600
  return copy(matrix, this);
1627
1601
  }
1628
1602
  /**
1629
- * Get the Frobenius norm of this matrix.
1630
- * @see {@link https://en.wikipedia.org/wiki/Matrix_norm | Matrix norm}
1631
- */
1632
- get frob() {
1633
- return frob(this);
1634
- }
1635
- /**
1636
- * Multiply this matrix by another.
1637
- * @param matrix - The other matrix.
1638
- * @param out - The matrix to store the result in.
1639
- * @returns The product of the matrices.
1640
- * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
1641
- */
1642
- multiply(matrix, out = new Matrix4()) {
1643
- return multiply(this, matrix, out);
1644
- }
1645
- /**
1646
- * Multiply this matrix by a scalar value.
1647
- * @param scalar - The scalar value.
1648
- * @param out - The matrix to store the result in.
1649
- * @returns The product of the matrix and the scalar value.
1650
- * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
1651
- */
1652
- multiplyScalar(scalar, out = new Matrix4()) {
1653
- return multiplyScalar(this, scalar, out);
1654
- }
1655
- /**
1656
- * Add this matrix to another after multiplying the other by a scalar.
1603
+ * Determine whether or not this matrix is roughly equivalent to another.
1657
1604
  * @param matrix - The other matrix.
1658
- * @param scalar - The scalar.
1659
- * @param out - The matrix to store the result in.
1660
- * @returns The sum.
1661
- * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
1662
- * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
1605
+ * @returns Whether or not the matrices are equivalent.
1663
1606
  */
1664
- multiplyScalarAndAdd(matrix, scalar, out = new Matrix4()) {
1665
- return multiplyScalarAndAdd(this, matrix, scalar, out);
1607
+ equals(matrix) {
1608
+ return equals(this, matrix);
1666
1609
  }
1667
1610
  /**
1668
- * Subtract another matrix from this one.
1611
+ * Determine whether or not this matrix is exactly equivalent to another.
1669
1612
  * @param matrix - The other matrix.
1670
- * @param out - The matrix to store the result in.
1671
- * @returns The difference between the matrices.
1672
- * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
1673
- */
1674
- subtract(matrix, out = new Matrix4()) {
1675
- return subtract(this, matrix, out);
1676
- }
1677
- /**
1678
- * Transpose this matrix.
1679
- * @param out - The matrix to store the result in.
1680
- * @returns The transpose of this matrix.
1681
- * @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
1682
- */
1683
- transpose(out = new Matrix4()) {
1684
- return transpose(this, out);
1685
- }
1686
- /**
1687
- * Get the determinant of this matrix.
1688
- * @see {@link https://en.wikipedia.org/wiki/Determinant | Determinant}
1613
+ * @returns Whether or not the matrices are equivalent.
1689
1614
  */
1690
- get determinant() {
1691
- return determinant(this);
1615
+ exactEquals(matrix) {
1616
+ return exactEquals(this, matrix);
1692
1617
  }
1693
1618
  /**
1694
1619
  * Reset this matrix to identity.
@@ -1700,110 +1625,121 @@ export default class Matrix4 extends Float32Array {
1700
1625
  }
1701
1626
  /**
1702
1627
  * Invert this matrix.
1703
- * @param out - The matrix to store the result in.
1704
1628
  * @returns The inverted matrix.
1705
1629
  * @see {@link https://en.wikipedia.org/wiki/Invertible_matrix | Invertible matrix}
1706
1630
  */
1707
- invert(out = new Matrix4()) {
1708
- return invert(this, out);
1631
+ invert() {
1632
+ return invert(this, new Matrix4());
1709
1633
  }
1710
1634
  /**
1711
- * Scale this matrix by the given vector.
1712
- * @param vector - The scaling vector.
1713
- * @param out - The matrix to store the result in.
1714
- * @returns The scaled matrix.
1715
- * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1635
+ * Multiply this matrix by another.
1636
+ * @param matrix - The other matrix.
1637
+ * @returns The product of the matrices.
1638
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
1716
1639
  */
1717
- scale(vector, out = new Matrix4()) {
1718
- return scale(this, vector, out);
1640
+ multiply(matrix) {
1641
+ return multiply(this, matrix, new Matrix4());
1719
1642
  }
1720
1643
  /**
1721
- * Translate this matrix by the given vector.
1722
- * @param vector - The translation vector.
1723
- * @param out - The matrix to store the result in.
1724
- * @returns The translated matrix.
1725
- * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1644
+ * Multiply this matrix by a scalar value.
1645
+ * @param scalar - The scalar value.
1646
+ * @returns The product of the matrix and the scalar value.
1647
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
1648
+ */
1649
+ multiplyScalar(scalar) {
1650
+ return multiplyScalar(this, scalar, new Matrix4());
1651
+ }
1652
+ /**
1653
+ * Add this matrix to another after multiplying the other by a scalar.
1654
+ * @param matrix - The other matrix.
1655
+ * @param scalar - The scalar.
1656
+ * @returns The sum.
1657
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
1658
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_multiplication | Matrix multiplication}
1726
1659
  */
1727
- translate(vector, out = new Matrix4()) {
1728
- return translate(this, vector, out);
1660
+ multiplyScalarAndAdd(matrix, scalar) {
1661
+ return multiplyScalarAndAdd(this, matrix, scalar, new Matrix4());
1729
1662
  }
1730
1663
  /**
1731
1664
  * Rotate this matrix by the given angle around the given axis.
1732
1665
  * @param r - The angle in radians.
1733
1666
  * @param axis - The axis.
1734
- * @param out - The matrix to store the result in.
1735
1667
  * @returns The rotated matrix.
1736
1668
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1737
1669
  */
1738
- rotate(r, axis, out = new Matrix4()) {
1739
- return rotate(this, r, axis, out);
1670
+ rotate(r, axis) {
1671
+ return rotate(this, r, axis, new Matrix4());
1740
1672
  }
1741
1673
  /**
1742
1674
  * Rotate this matrix by the given angle around the X-axis.
1743
1675
  * @param r - The angle in radians.
1744
- * @param out - The matrix to store the result in.
1745
1676
  * @returns The rotated matrix.
1746
1677
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1747
1678
  */
1748
- rotateX(r, out = new Matrix4()) {
1749
- return rotateX(this, r, out);
1679
+ rotateX(r) {
1680
+ return rotateX(this, r, new Matrix4());
1750
1681
  }
1751
1682
  /**
1752
1683
  * Rotate this matrix by the given angle around the Y-axis.
1753
1684
  * @param r - The angle in radians.
1754
- * @param out - The matrix to store the result in.
1755
1685
  * @returns The rotated matrix.
1756
1686
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1757
1687
  */
1758
- rotateY(r, out = new Matrix4()) {
1759
- return rotateY(this, r, out);
1688
+ rotateY(r) {
1689
+ return rotateY(this, r, new Matrix4());
1760
1690
  }
1761
1691
  /**
1762
1692
  * Rotate this matrix by the given angle around the Z-axis.
1763
1693
  * @param r - The angle in radians.
1764
- * @param out - The matrix to store the result in.
1765
1694
  * @returns The rotated matrix.
1766
1695
  * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1767
1696
  */
1768
- rotateZ(r, out = new Matrix4()) {
1769
- return rotateZ(this, r, out);
1697
+ rotateZ(r) {
1698
+ return rotateZ(this, r, new Matrix4());
1770
1699
  }
1771
1700
  /**
1772
- * Get the translation vector component of this transformation matrix.
1773
- * @param out - The vector to store the result in.
1774
- * @returns The translation.
1701
+ * Scale this matrix by the given vector.
1702
+ * @param vector - The scaling vector.
1703
+ * @returns The scaled matrix.
1775
1704
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1776
1705
  */
1777
- getTranslation(out = new Vector3()) {
1778
- return getTranslation(this, out);
1706
+ scale(vector) {
1707
+ return scale(this, vector, new Matrix4());
1779
1708
  }
1780
1709
  /**
1781
1710
  * Set the translation vector component of this transformation matrix.
1782
1711
  * @param translation - The translation vector.
1783
- * @param out - The matrix to store the result in.
1784
1712
  * @returns The transformation matrix.
1785
1713
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1786
1714
  */
1787
- setTranslation(translation, out = new Matrix4()) {
1788
- return setTranslation(this, translation, out);
1715
+ setTranslation(translation) {
1716
+ return setTranslation(this, translation, new Matrix4());
1789
1717
  }
1790
1718
  /**
1791
- * Get the scaling vector component of this transformation matrix.
1792
- * @param out - The vector to store the result in.
1793
- * @returns The scaling.
1719
+ * Subtract another matrix from this one.
1720
+ * @param matrix - The other matrix.
1721
+ * @returns The difference between the matrices.
1722
+ * @see {@link https://en.wikipedia.org/wiki/Matrix_addition | Matrix addition}
1723
+ */
1724
+ subtract(matrix) {
1725
+ return subtract(this, matrix, new Matrix4());
1726
+ }
1727
+ /**
1728
+ * Translate this matrix by the given vector.
1729
+ * @param vector - The translation vector.
1730
+ * @returns The translated matrix.
1794
1731
  * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
1795
1732
  */
1796
- getScaling(out = new Vector3()) {
1797
- return getScaling(this, out);
1733
+ translate(vector) {
1734
+ return translate(this, vector, new Matrix4());
1798
1735
  }
1799
1736
  /**
1800
- * Get the scaling vector component of this transformation matrix.
1801
- * @param out - The quaternion to store the result in.
1802
- * @returns The rotation.
1803
- * @see {@link https://en.wikipedia.org/wiki/Rotation_matrix | Rotation matrix}
1737
+ * Transpose this matrix.
1738
+ * @returns The transpose of this matrix.
1739
+ * @see {@link https://en.wikipedia.org/wiki/Transpose | Transpose}
1804
1740
  */
1805
- getRotation(out = new Quaternion()) {
1806
- return getRotation(this, out);
1741
+ transpose() {
1742
+ return transpose(this, new Matrix4());
1807
1743
  }
1808
1744
  }
1809
1745
  //# sourceMappingURL=Matrix4.js.map