@lakuna/umath 1.2.0 → 1.2.1
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.
- package/dist/algorithms/combinations.js +1 -1
- package/dist/algorithms/combinations.js.map +1 -1
- package/dist/algorithms/degreesToRadians.js +1 -1
- package/dist/algorithms/degreesToRadians.js.map +1 -1
- package/dist/algorithms/factorial.js.map +1 -1
- package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
- package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
- package/dist/algorithms/hypergeometricPmf.js +1 -1
- package/dist/algorithms/hypergeometricPmf.js.map +1 -1
- package/dist/algorithms/permutations.js +1 -1
- package/dist/algorithms/permutations.js.map +1 -1
- package/dist/algorithms/radiansToDegrees.js +1 -1
- package/dist/algorithms/radiansToDegrees.js.map +1 -1
- package/dist/algorithms/summation.d.ts.map +1 -1
- package/dist/algorithms/summation.js.map +1 -1
- package/dist/index.d.ts +33 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -27
- package/dist/index.js.map +1 -1
- package/dist/linalg/DualQuaternion.d.ts +3 -3
- package/dist/linalg/DualQuaternion.d.ts.map +1 -1
- package/dist/linalg/DualQuaternion.js +60 -28
- package/dist/linalg/DualQuaternion.js.map +1 -1
- package/dist/linalg/Matrix2.d.ts +3 -8
- package/dist/linalg/Matrix2.d.ts.map +1 -1
- package/dist/linalg/Matrix2.js +9 -12
- package/dist/linalg/Matrix2.js.map +1 -1
- package/dist/linalg/Matrix3.d.ts +5 -15
- package/dist/linalg/Matrix3.d.ts.map +1 -1
- package/dist/linalg/Matrix3.js +23 -23
- package/dist/linalg/Matrix3.js.map +1 -1
- package/dist/linalg/Matrix4.d.ts +5 -5
- package/dist/linalg/Matrix4.d.ts.map +1 -1
- package/dist/linalg/Matrix4.js +45 -40
- package/dist/linalg/Matrix4.js.map +1 -1
- package/dist/linalg/Quaternion.d.ts +3 -3
- package/dist/linalg/Quaternion.d.ts.map +1 -1
- package/dist/linalg/Quaternion.js +16 -9
- package/dist/linalg/Quaternion.js.map +1 -1
- package/dist/linalg/SlowMatrix.d.ts +1 -1
- package/dist/linalg/SlowMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowMatrix.js +12 -6
- package/dist/linalg/SlowMatrix.js.map +1 -1
- package/dist/linalg/SlowSquareMatrix.d.ts +2 -2
- package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowSquareMatrix.js +9 -5
- package/dist/linalg/SlowSquareMatrix.js.map +1 -1
- package/dist/linalg/SquareMatrix.d.ts +1 -1
- package/dist/linalg/SquareMatrix.d.ts.map +1 -1
- package/dist/linalg/Vector2.d.ts +5 -5
- package/dist/linalg/Vector2.d.ts.map +1 -1
- package/dist/linalg/Vector2.js +5 -6
- package/dist/linalg/Vector2.js.map +1 -1
- package/dist/linalg/Vector3.d.ts +4 -4
- package/dist/linalg/Vector3.d.ts.map +1 -1
- package/dist/linalg/Vector3.js +7 -9
- package/dist/linalg/Vector3.js.map +1 -1
- package/dist/linalg/Vector4.d.ts +3 -3
- package/dist/linalg/Vector4.d.ts.map +1 -1
- package/dist/linalg/Vector4.js +6 -9
- package/dist/linalg/Vector4.js.map +1 -1
- package/dist/types/AxisAngle.d.ts +1 -1
- package/dist/types/AxisAngle.d.ts.map +1 -1
- package/dist/utility/BigNumber.d.ts +1 -1
- package/dist/utility/BigNumber.d.ts.map +1 -1
- package/dist/utility/BigNumber.js +3 -2
- package/dist/utility/BigNumber.js.map +1 -1
- package/package.json +37 -6
- package/src/algorithms/combinations.ts +1 -1
- package/src/algorithms/degreesToRadians.ts +1 -1
- package/src/algorithms/factorial.ts +2 -2
- package/src/algorithms/greatestCommonDivisor.ts +10 -3
- package/src/algorithms/hypergeometricPmf.ts +8 -3
- package/src/algorithms/permutations.ts +1 -1
- package/src/algorithms/radiansToDegrees.ts +1 -1
- package/src/algorithms/summation.ts +5 -1
- package/src/index.ts +36 -33
- package/src/linalg/DualQuaternion.ts +409 -116
- package/src/linalg/Matrix.ts +1 -1
- package/src/linalg/Matrix2.ts +159 -63
- package/src/linalg/Matrix3.ts +300 -107
- package/src/linalg/Matrix4.ts +722 -206
- package/src/linalg/Quaternion.ts +311 -80
- package/src/linalg/SlowMatrix.ts +17 -9
- package/src/linalg/SlowSquareMatrix.ts +24 -13
- package/src/linalg/SquareMatrix.ts +1 -1
- package/src/linalg/Vector2.ts +361 -223
- package/src/linalg/Vector3.ts +318 -89
- package/src/linalg/Vector4.ts +177 -53
- package/src/types/AxisAngle.ts +1 -1
- package/src/utility/BigNumber.ts +18 -7
package/src/linalg/Matrix.ts
CHANGED
package/src/linalg/Matrix2.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import type SquareMatrix from "#
|
|
2
|
-
import type { Vector2Like } from "#
|
|
3
|
-
import epsilon from "#
|
|
4
|
-
import SingularMatrixError from "#
|
|
1
|
+
import type SquareMatrix from "#SquareMatrix";
|
|
2
|
+
import type { Vector2Like } from "#Vector2";
|
|
3
|
+
import epsilon from "#epsilon";
|
|
4
|
+
import SingularMatrixError from "#SingularMatrixError";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Numbers arranged into two columns and two rows.
|
|
8
8
|
* @see [Matrix](https://en.wikipedia.org/wiki/Matrix_(mathematics))
|
|
9
9
|
*/
|
|
10
|
-
export type Matrix2Like = Matrix2 | [
|
|
11
|
-
number, number,
|
|
12
|
-
number, number
|
|
13
|
-
];
|
|
10
|
+
export type Matrix2Like = Matrix2 | [number, number, number, number];
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
13
|
* Creates a transformation matrix that represents a rotation by the given angle around the Z-axis.
|
|
@@ -19,7 +16,10 @@ export type Matrix2Like = Matrix2 | [
|
|
|
19
16
|
* @returns The transformation matrix.
|
|
20
17
|
* @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
|
|
21
18
|
*/
|
|
22
|
-
export function fromRotation<T extends Matrix2Like>(
|
|
19
|
+
export function fromRotation<T extends Matrix2Like>(
|
|
20
|
+
radians: number,
|
|
21
|
+
out: T
|
|
22
|
+
): T {
|
|
23
23
|
const s: number = Math.sin(radians);
|
|
24
24
|
const c: number = Math.cos(radians);
|
|
25
25
|
|
|
@@ -37,7 +37,10 @@ export function fromRotation<T extends Matrix2Like>(radians: number, out: T): T
|
|
|
37
37
|
* @returns The transformation matrix.
|
|
38
38
|
* @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
|
|
39
39
|
*/
|
|
40
|
-
export function fromScaling<T extends Matrix2Like>(
|
|
40
|
+
export function fromScaling<T extends Matrix2Like>(
|
|
41
|
+
vector: Vector2Like,
|
|
42
|
+
out: T
|
|
43
|
+
): T {
|
|
41
44
|
out[0] = vector[0];
|
|
42
45
|
out[1] = 0;
|
|
43
46
|
out[2] = 0;
|
|
@@ -54,7 +57,13 @@ export function fromScaling<T extends Matrix2Like>(vector: Vector2Like, out: T):
|
|
|
54
57
|
* @param out The matrix to store the result in.
|
|
55
58
|
* @returns The matrix.
|
|
56
59
|
*/
|
|
57
|
-
export function fromValues<T extends Matrix2Like>(
|
|
60
|
+
export function fromValues<T extends Matrix2Like>(
|
|
61
|
+
c0r0: number,
|
|
62
|
+
c0r1: number,
|
|
63
|
+
c1r0: number,
|
|
64
|
+
c1r1: number,
|
|
65
|
+
out: T
|
|
66
|
+
): T {
|
|
58
67
|
out[0] = c0r0;
|
|
59
68
|
out[1] = c0r1;
|
|
60
69
|
out[2] = c1r0;
|
|
@@ -79,10 +88,12 @@ export function equals(a: Matrix2Like, b: Matrix2Like): boolean {
|
|
|
79
88
|
const b2: number = b[2];
|
|
80
89
|
const b3: number = b[3];
|
|
81
90
|
|
|
82
|
-
return (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
return (
|
|
92
|
+
Math.abs(a0 - b0) <= epsilon * Math.max(1, Math.abs(a0), Math.abs(b0)) &&
|
|
93
|
+
Math.abs(a1 - b1) <= epsilon * Math.max(1, Math.abs(a1), Math.abs(b1)) &&
|
|
94
|
+
Math.abs(a2 - b2) <= epsilon * Math.max(1, Math.abs(a2), Math.abs(b2)) &&
|
|
95
|
+
Math.abs(a3 - b3) <= epsilon * Math.max(1, Math.abs(a3), Math.abs(b3))
|
|
96
|
+
);
|
|
86
97
|
}
|
|
87
98
|
|
|
88
99
|
/**
|
|
@@ -92,10 +103,7 @@ export function equals(a: Matrix2Like, b: Matrix2Like): boolean {
|
|
|
92
103
|
* @returns Whether the matrices are equivalent.
|
|
93
104
|
*/
|
|
94
105
|
export function exactEquals(a: Matrix2Like, b: Matrix2Like): boolean {
|
|
95
|
-
return a[0] == b[0]
|
|
96
|
-
&& a[1] == b[1]
|
|
97
|
-
&& a[2] == b[2]
|
|
98
|
-
&& a[3] == b[3];
|
|
106
|
+
return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3];
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
/**
|
|
@@ -106,7 +114,11 @@ export function exactEquals(a: Matrix2Like, b: Matrix2Like): boolean {
|
|
|
106
114
|
* @returns The sum.
|
|
107
115
|
* @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
|
|
108
116
|
*/
|
|
109
|
-
export function add<T extends Matrix2Like>(
|
|
117
|
+
export function add<T extends Matrix2Like>(
|
|
118
|
+
a: Matrix2Like,
|
|
119
|
+
b: Matrix2Like,
|
|
120
|
+
out: T
|
|
121
|
+
): T {
|
|
110
122
|
out[0] = a[0] + b[0];
|
|
111
123
|
out[1] = a[1] + b[1];
|
|
112
124
|
out[2] = a[2] + b[2];
|
|
@@ -152,8 +164,10 @@ export function copy<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T {
|
|
|
152
164
|
*/
|
|
153
165
|
export function frob(matrix: Matrix2Like): number {
|
|
154
166
|
return Math.hypot(
|
|
155
|
-
matrix[0] as number,
|
|
156
|
-
matrix[
|
|
167
|
+
matrix[0] as number,
|
|
168
|
+
matrix[1] as number,
|
|
169
|
+
matrix[2] as number,
|
|
170
|
+
matrix[3] as number
|
|
157
171
|
);
|
|
158
172
|
}
|
|
159
173
|
|
|
@@ -165,7 +179,11 @@ export function frob(matrix: Matrix2Like): number {
|
|
|
165
179
|
* @returns The product.
|
|
166
180
|
* @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
|
|
167
181
|
*/
|
|
168
|
-
export function multiply<T extends Matrix2Like>(
|
|
182
|
+
export function multiply<T extends Matrix2Like>(
|
|
183
|
+
a: Matrix2Like,
|
|
184
|
+
b: Matrix2Like,
|
|
185
|
+
out: T
|
|
186
|
+
): T {
|
|
169
187
|
const a0: number = a[0];
|
|
170
188
|
const a1: number = a[1];
|
|
171
189
|
const a2: number = a[2];
|
|
@@ -191,7 +209,11 @@ export function multiply<T extends Matrix2Like>(a: Matrix2Like, b: Matrix2Like,
|
|
|
191
209
|
* @returns The product.
|
|
192
210
|
* @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
|
|
193
211
|
*/
|
|
194
|
-
export function multiplyScalar<T extends Matrix2Like>(
|
|
212
|
+
export function multiplyScalar<T extends Matrix2Like>(
|
|
213
|
+
matrix: Matrix2Like,
|
|
214
|
+
scalar: number,
|
|
215
|
+
out: T
|
|
216
|
+
): T {
|
|
195
217
|
out[0] = matrix[0] * scalar;
|
|
196
218
|
out[1] = matrix[1] * scalar;
|
|
197
219
|
out[2] = matrix[2] * scalar;
|
|
@@ -209,7 +231,12 @@ export function multiplyScalar<T extends Matrix2Like>(matrix: Matrix2Like, scala
|
|
|
209
231
|
* @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
|
|
210
232
|
* @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
|
|
211
233
|
*/
|
|
212
|
-
export function multiplyScalarAndAdd<T extends Matrix2Like>(
|
|
234
|
+
export function multiplyScalarAndAdd<T extends Matrix2Like>(
|
|
235
|
+
a: Matrix2Like,
|
|
236
|
+
b: Matrix2Like,
|
|
237
|
+
scalar: number,
|
|
238
|
+
out: T
|
|
239
|
+
): T {
|
|
213
240
|
out[0] = a[0] + b[0] * scalar;
|
|
214
241
|
out[1] = a[1] + b[1] * scalar;
|
|
215
242
|
out[2] = a[2] + b[2] * scalar;
|
|
@@ -225,7 +252,11 @@ export function multiplyScalarAndAdd<T extends Matrix2Like>(a: Matrix2Like, b: M
|
|
|
225
252
|
* @returns The difference.
|
|
226
253
|
* @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
|
|
227
254
|
*/
|
|
228
|
-
export function subtract<T extends Matrix2Like>(
|
|
255
|
+
export function subtract<T extends Matrix2Like>(
|
|
256
|
+
a: Matrix2Like,
|
|
257
|
+
b: Matrix2Like,
|
|
258
|
+
out: T
|
|
259
|
+
): T {
|
|
229
260
|
out[0] = a[0] - b[0];
|
|
230
261
|
out[1] = a[1] - b[1];
|
|
231
262
|
out[2] = a[2] - b[2];
|
|
@@ -240,7 +271,10 @@ export function subtract<T extends Matrix2Like>(a: Matrix2Like, b: Matrix2Like,
|
|
|
240
271
|
* @returns The transpose of the matrix.
|
|
241
272
|
* @see [Transpose](https://en.wikipedia.org/wiki/Transpose)
|
|
242
273
|
*/
|
|
243
|
-
export function transpose<T extends Matrix2Like>(
|
|
274
|
+
export function transpose<T extends Matrix2Like>(
|
|
275
|
+
matrix: Matrix2Like,
|
|
276
|
+
out: T
|
|
277
|
+
): T {
|
|
244
278
|
if (out == matrix) {
|
|
245
279
|
const a1 = matrix[1];
|
|
246
280
|
out[1] = matrix[2];
|
|
@@ -261,8 +295,10 @@ export function transpose<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T
|
|
|
261
295
|
* @see [Determinant](https://en.wikipedia.org/wiki/Determinant)
|
|
262
296
|
*/
|
|
263
297
|
export function determinant(matrix: Matrix2Like): number {
|
|
264
|
-
return (
|
|
265
|
-
|
|
298
|
+
return (
|
|
299
|
+
(matrix[0] as number) * (matrix[3] as number) -
|
|
300
|
+
(matrix[2] as number) * (matrix[1] as number)
|
|
301
|
+
);
|
|
266
302
|
}
|
|
267
303
|
|
|
268
304
|
/**
|
|
@@ -291,7 +327,7 @@ export function invert<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T {
|
|
|
291
327
|
const a1: number = matrix[1];
|
|
292
328
|
const a2: number = matrix[2];
|
|
293
329
|
const a3: number = matrix[3];
|
|
294
|
-
|
|
330
|
+
|
|
295
331
|
let determinant: number = a0 * a3 - a2 * a1;
|
|
296
332
|
if (!determinant) {
|
|
297
333
|
throw new SingularMatrixError();
|
|
@@ -313,7 +349,11 @@ export function invert<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T {
|
|
|
313
349
|
* @returns The rotated matrix.
|
|
314
350
|
* @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
|
|
315
351
|
*/
|
|
316
|
-
export function rotate<T extends Matrix2Like>(
|
|
352
|
+
export function rotate<T extends Matrix2Like>(
|
|
353
|
+
matrix: Matrix2Like,
|
|
354
|
+
radians: number,
|
|
355
|
+
out: T
|
|
356
|
+
): T {
|
|
317
357
|
const a0: number = matrix[0];
|
|
318
358
|
const a1: number = matrix[1];
|
|
319
359
|
const a2: number = matrix[2];
|
|
@@ -337,7 +377,11 @@ export function rotate<T extends Matrix2Like>(matrix: Matrix2Like, radians: numb
|
|
|
337
377
|
* @returns The scaled matrix.
|
|
338
378
|
* @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
|
|
339
379
|
*/
|
|
340
|
-
export function scale<T extends Matrix2Like>(
|
|
380
|
+
export function scale<T extends Matrix2Like>(
|
|
381
|
+
matrix: Matrix2Like,
|
|
382
|
+
vector: Vector2Like,
|
|
383
|
+
out: T
|
|
384
|
+
): T {
|
|
341
385
|
const v0: number = vector[0];
|
|
342
386
|
const v1: number = vector[1];
|
|
343
387
|
|
|
@@ -370,7 +414,10 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
370
414
|
*/
|
|
371
415
|
public static fromRotation<T extends Matrix2Like>(radians: number, out: T): T;
|
|
372
416
|
|
|
373
|
-
public static fromRotation<T extends Matrix2Like>(
|
|
417
|
+
public static fromRotation<T extends Matrix2Like>(
|
|
418
|
+
radians: number,
|
|
419
|
+
out: T = new Matrix2() as T
|
|
420
|
+
): T {
|
|
374
421
|
return fromRotation(radians, out);
|
|
375
422
|
}
|
|
376
423
|
|
|
@@ -389,9 +436,15 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
389
436
|
* @returns The transformation matrix.
|
|
390
437
|
* @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
|
|
391
438
|
*/
|
|
392
|
-
public static fromScaling<T extends Matrix2Like>(
|
|
439
|
+
public static fromScaling<T extends Matrix2Like>(
|
|
440
|
+
vector: Vector2Like,
|
|
441
|
+
out: T
|
|
442
|
+
): T;
|
|
393
443
|
|
|
394
|
-
public static fromScaling<T extends Matrix2Like>(
|
|
444
|
+
public static fromScaling<T extends Matrix2Like>(
|
|
445
|
+
vector: Vector2Like,
|
|
446
|
+
out: T = new Matrix2() as T
|
|
447
|
+
): T {
|
|
395
448
|
return fromScaling(vector, out);
|
|
396
449
|
}
|
|
397
450
|
|
|
@@ -403,7 +456,12 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
403
456
|
* @param c1r1 The value in the second column and second row.
|
|
404
457
|
* @returns The matrix.
|
|
405
458
|
*/
|
|
406
|
-
public static fromValues(
|
|
459
|
+
public static fromValues(
|
|
460
|
+
c0r0: number,
|
|
461
|
+
c0r1: number,
|
|
462
|
+
c1r0: number,
|
|
463
|
+
c1r1: number
|
|
464
|
+
): Matrix2;
|
|
407
465
|
|
|
408
466
|
/**
|
|
409
467
|
* Creates a two-by-two matrix with the given values.
|
|
@@ -414,9 +472,21 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
414
472
|
* @param out The matrix to store the result in.
|
|
415
473
|
* @returns The matrix.
|
|
416
474
|
*/
|
|
417
|
-
public static fromValues<T extends Matrix2Like>(
|
|
418
|
-
|
|
419
|
-
|
|
475
|
+
public static fromValues<T extends Matrix2Like>(
|
|
476
|
+
c0r0: number,
|
|
477
|
+
c0r1: number,
|
|
478
|
+
c1r0: number,
|
|
479
|
+
c1r1: number,
|
|
480
|
+
out: T
|
|
481
|
+
): T;
|
|
482
|
+
|
|
483
|
+
public static fromValues<T extends Matrix2Like>(
|
|
484
|
+
c0r0: number,
|
|
485
|
+
c0r1: number,
|
|
486
|
+
c1r0: number,
|
|
487
|
+
c1r1: number,
|
|
488
|
+
out: T = new Matrix2() as T
|
|
489
|
+
): T {
|
|
420
490
|
return fromValues(c0r0, c0r1, c1r0, c1r1, out);
|
|
421
491
|
}
|
|
422
492
|
|
|
@@ -427,7 +497,7 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
427
497
|
public constructor() {
|
|
428
498
|
super(4);
|
|
429
499
|
|
|
430
|
-
this[0] =
|
|
500
|
+
this[0] = 1;
|
|
431
501
|
this[3] = 1;
|
|
432
502
|
|
|
433
503
|
this.width = 2;
|
|
@@ -475,7 +545,10 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
475
545
|
*/
|
|
476
546
|
public add<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T;
|
|
477
547
|
|
|
478
|
-
public add<T extends Matrix2Like>(
|
|
548
|
+
public add<T extends Matrix2Like>(
|
|
549
|
+
matrix: Matrix2Like,
|
|
550
|
+
out: T = new Matrix2() as T
|
|
551
|
+
): T {
|
|
479
552
|
return add(this, matrix, out);
|
|
480
553
|
}
|
|
481
554
|
|
|
@@ -499,21 +572,21 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
499
572
|
}
|
|
500
573
|
|
|
501
574
|
/**
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
575
|
+
* Creates a copy of this matrix.
|
|
576
|
+
* @returns The copy.
|
|
577
|
+
*/
|
|
578
|
+
public clone(): Matrix2;
|
|
506
579
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
580
|
+
/**
|
|
581
|
+
* Copies the values from this matrix to another one.
|
|
582
|
+
* @param out The matrix to store the result in.
|
|
583
|
+
* @returns The copy.
|
|
584
|
+
*/
|
|
585
|
+
public clone<T extends Matrix2Like>(out: T): T;
|
|
586
|
+
|
|
587
|
+
public clone<T extends Matrix2Like>(out: T = new Matrix2() as T): T {
|
|
588
|
+
return copy(this, out);
|
|
589
|
+
}
|
|
517
590
|
|
|
518
591
|
/**
|
|
519
592
|
* Copies the values of another matrix into this one.
|
|
@@ -549,7 +622,10 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
549
622
|
*/
|
|
550
623
|
public multiply<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T;
|
|
551
624
|
|
|
552
|
-
public multiply<T extends Matrix2Like>(
|
|
625
|
+
public multiply<T extends Matrix2Like>(
|
|
626
|
+
matrix: Matrix2Like,
|
|
627
|
+
out: T = new Matrix2() as T
|
|
628
|
+
): T {
|
|
553
629
|
return multiply(this, matrix, out);
|
|
554
630
|
}
|
|
555
631
|
|
|
@@ -570,7 +646,10 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
570
646
|
*/
|
|
571
647
|
public multiplyScalar<T extends Matrix2Like>(scalar: number, out: T): T;
|
|
572
648
|
|
|
573
|
-
public multiplyScalar<T extends Matrix2Like>(
|
|
649
|
+
public multiplyScalar<T extends Matrix2Like>(
|
|
650
|
+
scalar: number,
|
|
651
|
+
out: T = new Matrix2() as T
|
|
652
|
+
): T {
|
|
574
653
|
return multiplyScalar(this, scalar, out);
|
|
575
654
|
}
|
|
576
655
|
|
|
@@ -593,9 +672,17 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
593
672
|
* @see [Matrix addition](https://en.wikipedia.org/wiki/Matrix_addition)
|
|
594
673
|
* @see [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication)
|
|
595
674
|
*/
|
|
596
|
-
public multiplyScalarAndAdd<T extends Matrix2Like>(
|
|
597
|
-
|
|
598
|
-
|
|
675
|
+
public multiplyScalarAndAdd<T extends Matrix2Like>(
|
|
676
|
+
matrix: Matrix2Like,
|
|
677
|
+
scalar: number,
|
|
678
|
+
out: T
|
|
679
|
+
): T;
|
|
680
|
+
|
|
681
|
+
public multiplyScalarAndAdd<T extends Matrix2Like>(
|
|
682
|
+
matrix: Matrix2Like,
|
|
683
|
+
scalar: number,
|
|
684
|
+
out: T = new Matrix2() as T
|
|
685
|
+
): T {
|
|
599
686
|
return multiplyScalarAndAdd(this, matrix, scalar, out);
|
|
600
687
|
}
|
|
601
688
|
|
|
@@ -616,7 +703,10 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
616
703
|
*/
|
|
617
704
|
public subtract<T extends Matrix2Like>(matrix: Matrix2Like, out: T): T;
|
|
618
705
|
|
|
619
|
-
public subtract<T extends Matrix2Like>(
|
|
706
|
+
public subtract<T extends Matrix2Like>(
|
|
707
|
+
matrix: Matrix2Like,
|
|
708
|
+
out: T = new Matrix2() as T
|
|
709
|
+
): T {
|
|
620
710
|
return subtract(this, matrix, out);
|
|
621
711
|
}
|
|
622
712
|
|
|
@@ -692,7 +782,10 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
692
782
|
*/
|
|
693
783
|
public rotate<T extends Matrix2Like>(radians: number, out: T): T;
|
|
694
784
|
|
|
695
|
-
public rotate<T extends Matrix2Like>(
|
|
785
|
+
public rotate<T extends Matrix2Like>(
|
|
786
|
+
radians: number,
|
|
787
|
+
out: T = new Matrix2() as T
|
|
788
|
+
): T {
|
|
696
789
|
return rotate(this, radians, out);
|
|
697
790
|
}
|
|
698
791
|
|
|
@@ -713,7 +806,10 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
713
806
|
*/
|
|
714
807
|
public scale<T extends Matrix2Like>(vector: Vector2Like, out: T): T;
|
|
715
808
|
|
|
716
|
-
public scale<T extends Matrix2Like>(
|
|
809
|
+
public scale<T extends Matrix2Like>(
|
|
810
|
+
vector: Vector2Like,
|
|
811
|
+
out: T = new Matrix2() as T
|
|
812
|
+
): T {
|
|
717
813
|
return scale(this, vector, out);
|
|
718
814
|
}
|
|
719
815
|
}
|