@lakuna/umath 1.3.2 → 1.3.3
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/hypergeometricPmf.d.ts.map +1 -1
- package/dist/algorithms/hypergeometricPmf.js.map +1 -1
- package/dist/linalg/DualQuaternion.d.ts +1 -0
- package/dist/linalg/DualQuaternion.d.ts.map +1 -1
- package/dist/linalg/DualQuaternion.js +3 -0
- package/dist/linalg/DualQuaternion.js.map +1 -1
- package/dist/linalg/Matrix2.d.ts +1 -0
- package/dist/linalg/Matrix2.d.ts.map +1 -1
- package/dist/linalg/Matrix2.js +3 -0
- package/dist/linalg/Matrix2.js.map +1 -1
- package/dist/linalg/Matrix3.d.ts +1 -0
- package/dist/linalg/Matrix3.d.ts.map +1 -1
- package/dist/linalg/Matrix3.js +3 -0
- package/dist/linalg/Matrix3.js.map +1 -1
- package/dist/linalg/Matrix4.d.ts +1 -0
- package/dist/linalg/Matrix4.d.ts.map +1 -1
- package/dist/linalg/Matrix4.js +3 -0
- package/dist/linalg/Matrix4.js.map +1 -1
- package/dist/linalg/Quaternion.d.ts +1 -0
- package/dist/linalg/Quaternion.d.ts.map +1 -1
- package/dist/linalg/Quaternion.js +3 -0
- package/dist/linalg/Quaternion.js.map +1 -1
- package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowSquareMatrix.js.map +1 -1
- package/dist/linalg/Vector.d.ts.map +1 -1
- package/dist/linalg/Vector2.d.ts +1 -0
- package/dist/linalg/Vector2.d.ts.map +1 -1
- package/dist/linalg/Vector2.js +3 -0
- package/dist/linalg/Vector2.js.map +1 -1
- package/dist/linalg/Vector3.d.ts +1 -0
- package/dist/linalg/Vector3.d.ts.map +1 -1
- package/dist/linalg/Vector3.js +3 -0
- package/dist/linalg/Vector3.js.map +1 -1
- package/dist/linalg/Vector4.d.ts +1 -0
- package/dist/linalg/Vector4.d.ts.map +1 -1
- package/dist/linalg/Vector4.js +3 -0
- package/dist/linalg/Vector4.js.map +1 -1
- package/dist/utility/BigNumber.d.ts.map +1 -1
- package/dist/utility/BigNumber.js.map +1 -1
- package/dist/utility/MatrixSizeError.d.ts.map +1 -1
- package/dist/utility/MatrixSizeError.js.map +1 -1
- package/dist/utility/PartialMatrixError.d.ts.map +1 -1
- package/dist/utility/PartialMatrixError.js.map +1 -1
- package/dist/utility/SingularMatrixError.d.ts.map +1 -1
- package/dist/utility/SingularMatrixError.js +1 -0
- package/dist/utility/SingularMatrixError.js.map +1 -1
- package/dist/utility/epsilon.d.ts.map +1 -1
- package/dist/utility/epsilon.js.map +1 -1
- package/package.json +1 -1
- package/src/algorithms/hypergeometricPmf.ts +2 -1
- package/src/linalg/DualQuaternion.ts +25 -7
- package/src/linalg/Matrix2.ts +20 -6
- package/src/linalg/Matrix3.ts +44 -18
- package/src/linalg/Matrix4.ts +74 -33
- package/src/linalg/Quaternion.ts +52 -20
- package/src/linalg/SlowSquareMatrix.ts +6 -3
- package/src/linalg/Vector.ts +2 -1
- package/src/linalg/Vector2.ts +14 -3
- package/src/linalg/Vector3.ts +24 -8
- package/src/linalg/Vector4.ts +14 -3
- package/src/utility/BigNumber.ts +2 -1
- package/src/utility/MatrixSizeError.ts +2 -1
- package/src/utility/PartialMatrixError.ts +2 -1
- package/src/utility/SingularMatrixError.ts +1 -0
- package/src/utility/epsilon.ts +4 -1
package/src/linalg/Matrix2.ts
CHANGED
|
@@ -10,7 +10,16 @@ import SingularMatrixError from "#SingularMatrixError";
|
|
|
10
10
|
export type Matrix2Like = Matrix2 | [number, number, number, number];
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Creates a
|
|
13
|
+
* Creates a 2x2 matrix-like object.
|
|
14
|
+
* @returns A 2x2 matrix-like object.
|
|
15
|
+
*/
|
|
16
|
+
export function createMatrix2Like(): Matrix2Like {
|
|
17
|
+
return new Float32Array(4) as Matrix2Like;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
22
|
+
* angle around the Z-axis.
|
|
14
23
|
* @param radians The angle in radians.
|
|
15
24
|
* @param out The matrix to store the result in.
|
|
16
25
|
* @returns The transformation matrix.
|
|
@@ -31,7 +40,8 @@ export function fromRotation<T extends Matrix2Like>(
|
|
|
31
40
|
}
|
|
32
41
|
|
|
33
42
|
/**
|
|
34
|
-
* Creates a transformation matrix that represents a scaling by the given
|
|
43
|
+
* Creates a transformation matrix that represents a scaling by the given
|
|
44
|
+
* vector.
|
|
35
45
|
* @param vector The scaling vector.
|
|
36
46
|
* @param out The matrix to store the result in.
|
|
37
47
|
* @returns The transformation matrix.
|
|
@@ -398,7 +408,8 @@ export function scale<T extends Matrix2Like>(
|
|
|
398
408
|
*/
|
|
399
409
|
export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
400
410
|
/**
|
|
401
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
411
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
412
|
+
* angle around the Z-axis.
|
|
402
413
|
* @param radians The angle in radians.
|
|
403
414
|
* @returns The transformation matrix.
|
|
404
415
|
* @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
|
|
@@ -406,7 +417,8 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
406
417
|
public static fromRotation(radians: number): Matrix2;
|
|
407
418
|
|
|
408
419
|
/**
|
|
409
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
420
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
421
|
+
* angle around the Z-axis.
|
|
410
422
|
* @param radians The angle in radians.
|
|
411
423
|
* @param out The matrix to store the result in.
|
|
412
424
|
* @returns The transformation matrix.
|
|
@@ -422,7 +434,8 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
422
434
|
}
|
|
423
435
|
|
|
424
436
|
/**
|
|
425
|
-
* Creates a transformation matrix that represents a scaling by the given
|
|
437
|
+
* Creates a transformation matrix that represents a scaling by the given
|
|
438
|
+
* vector.
|
|
426
439
|
* @param vector The scaling vector.
|
|
427
440
|
* @returns The transformation matrix.
|
|
428
441
|
* @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
|
|
@@ -430,7 +443,8 @@ export default class Matrix2 extends Float32Array implements SquareMatrix {
|
|
|
430
443
|
public static fromScaling(vector: Vector2Like): Matrix2;
|
|
431
444
|
|
|
432
445
|
/**
|
|
433
|
-
* Creates a transformation matrix that represents a scaling by the given
|
|
446
|
+
* Creates a transformation matrix that represents a scaling by the given
|
|
447
|
+
* vector.
|
|
434
448
|
* @param vector The scaling vector.
|
|
435
449
|
* @param out The matrix to store the result in.
|
|
436
450
|
* @returns The transformation matrix.
|
package/src/linalg/Matrix3.ts
CHANGED
|
@@ -14,7 +14,16 @@ export type Matrix3Like =
|
|
|
14
14
|
| [number, number, number, number, number, number, number, number, number];
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Creates a
|
|
17
|
+
* Creates a 3x3 matrix-like object.
|
|
18
|
+
* @returns A 3x3 matrix-like object.
|
|
19
|
+
*/
|
|
20
|
+
export function createMatrix3Like(): Matrix3Like {
|
|
21
|
+
return new Float32Array(9) as Matrix3Like;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
26
|
+
* angle around the Z-axis.
|
|
18
27
|
* @param radians The angle in radians.
|
|
19
28
|
* @param out The matrix to store the result in.
|
|
20
29
|
* @returns The transformation matrix.
|
|
@@ -40,7 +49,8 @@ export function fromRotation<T extends Matrix3Like>(
|
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
/**
|
|
43
|
-
* Creates a transformation matrix that represents a scaling by the given
|
|
52
|
+
* Creates a transformation matrix that represents a scaling by the given
|
|
53
|
+
* vector.
|
|
44
54
|
* @param vector The scaling vector.
|
|
45
55
|
* @param out The matrix to store the result in.
|
|
46
56
|
* @returns The transformation matrix.
|
|
@@ -63,7 +73,8 @@ export function fromScaling<T extends Matrix3Like>(
|
|
|
63
73
|
}
|
|
64
74
|
|
|
65
75
|
/**
|
|
66
|
-
* Creates a transformation matrix that represents a translation by the given
|
|
76
|
+
* Creates a transformation matrix that represents a translation by the given
|
|
77
|
+
* vector.
|
|
67
78
|
* @param vector The translation vector.
|
|
68
79
|
* @param out The matrix to store the result in.
|
|
69
80
|
* @returns The transformation matrix.
|
|
@@ -86,7 +97,8 @@ export function fromTranslation<T extends Matrix3Like>(
|
|
|
86
97
|
}
|
|
87
98
|
|
|
88
99
|
/**
|
|
89
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
100
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
101
|
+
* quaternion.
|
|
90
102
|
* @param quaternion The quaternion.
|
|
91
103
|
* @param out The matrix to store the result in.
|
|
92
104
|
* @returns The transformation matrix.
|
|
@@ -128,7 +140,8 @@ export function fromQuaternion<T extends Matrix3Like>(
|
|
|
128
140
|
}
|
|
129
141
|
|
|
130
142
|
/**
|
|
131
|
-
* Calculates a three-by-three normal (inverse transpose) matrix from a
|
|
143
|
+
* Calculates a three-by-three normal (inverse transpose) matrix from a
|
|
144
|
+
* four-by-four matrix.
|
|
132
145
|
* @param matrix The four-by-four matrix.
|
|
133
146
|
* @param out The matrix to store the result in.
|
|
134
147
|
* @returns The normal matrix.
|
|
@@ -214,7 +227,8 @@ export function projection<T extends Matrix3Like>(
|
|
|
214
227
|
}
|
|
215
228
|
|
|
216
229
|
/**
|
|
217
|
-
* Creates a three-by-three matrix from the upper-left corner of a four-by-four
|
|
230
|
+
* Creates a three-by-three matrix from the upper-left corner of a four-by-four
|
|
231
|
+
* matrix.
|
|
218
232
|
* @param matrix The four-by-four matrix.
|
|
219
233
|
* @param out The matrix to store the result in.
|
|
220
234
|
* @returns The three-by-three matrix.
|
|
@@ -778,7 +792,8 @@ export function translate<T extends Matrix3Like>(
|
|
|
778
792
|
*/
|
|
779
793
|
export default class Matrix3 extends Float32Array implements SquareMatrix {
|
|
780
794
|
/**
|
|
781
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
795
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
796
|
+
* angle around the Z-axis.
|
|
782
797
|
* @param radians The angle in radians.
|
|
783
798
|
* @returns The transformation matrix.
|
|
784
799
|
* @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
|
|
@@ -786,7 +801,8 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
|
|
|
786
801
|
public static fromRotation(radians: number): Matrix3;
|
|
787
802
|
|
|
788
803
|
/**
|
|
789
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
804
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
805
|
+
* angle around the Z-axis.
|
|
790
806
|
* @param radians The angle in radians.
|
|
791
807
|
* @param out The matrix to store the result in.
|
|
792
808
|
* @returns The transformation matrix.
|
|
@@ -802,7 +818,8 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
|
|
|
802
818
|
}
|
|
803
819
|
|
|
804
820
|
/**
|
|
805
|
-
* Creates a transformation matrix that represents a scaling by the given
|
|
821
|
+
* Creates a transformation matrix that represents a scaling by the given
|
|
822
|
+
* vector.
|
|
806
823
|
* @param vector The scaling vector.
|
|
807
824
|
* @returns The transformation matrix.
|
|
808
825
|
* @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
|
|
@@ -810,7 +827,8 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
|
|
|
810
827
|
public static fromScaling(vector: Vector2Like): Matrix3;
|
|
811
828
|
|
|
812
829
|
/**
|
|
813
|
-
* Creates a transformation matrix that represents a scaling by the given
|
|
830
|
+
* Creates a transformation matrix that represents a scaling by the given
|
|
831
|
+
* vector.
|
|
814
832
|
* @param vector The scaling vector.
|
|
815
833
|
* @param out The matrix to store the result in.
|
|
816
834
|
* @returns The transformation matrix.
|
|
@@ -829,7 +847,8 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
|
|
|
829
847
|
}
|
|
830
848
|
|
|
831
849
|
/**
|
|
832
|
-
* Creates a transformation matrix that represents a translation by the
|
|
850
|
+
* Creates a transformation matrix that represents a translation by the
|
|
851
|
+
* given vector.
|
|
833
852
|
* @param vector The translation vector.
|
|
834
853
|
* @returns The transformation matrix.
|
|
835
854
|
* @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
|
|
@@ -837,7 +856,8 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
|
|
|
837
856
|
public static fromTranslation(vector: Vector2Like): Matrix3;
|
|
838
857
|
|
|
839
858
|
/**
|
|
840
|
-
* Creates a transformation matrix that represents a translation by the
|
|
859
|
+
* Creates a transformation matrix that represents a translation by the
|
|
860
|
+
* given vector.
|
|
841
861
|
* @param vector The translation vector.
|
|
842
862
|
* @param out The matrix to store the result in.
|
|
843
863
|
* @returns The transformation matrix.
|
|
@@ -856,7 +876,8 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
|
|
|
856
876
|
}
|
|
857
877
|
|
|
858
878
|
/**
|
|
859
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
879
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
880
|
+
* quaternion.
|
|
860
881
|
* @param quaternion The quaternion.
|
|
861
882
|
* @returns The transformation matrix.
|
|
862
883
|
* @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
|
|
@@ -865,7 +886,8 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
|
|
|
865
886
|
public static fromQuaternion(quaternion: QuaternionLike): Matrix3;
|
|
866
887
|
|
|
867
888
|
/**
|
|
868
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
889
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
890
|
+
* quaternion.
|
|
869
891
|
* @param quaternion The quaternion.
|
|
870
892
|
* @param out The matrix to store the result in.
|
|
871
893
|
* @returns The transformation matrix.
|
|
@@ -885,7 +907,8 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
|
|
|
885
907
|
}
|
|
886
908
|
|
|
887
909
|
/**
|
|
888
|
-
* Calculates a three-by-three normal (inverse transpose) matrix from a
|
|
910
|
+
* Calculates a three-by-three normal (inverse transpose) matrix from a
|
|
911
|
+
* four-by-four matrix.
|
|
889
912
|
* @param matrix The four-by-four matrix.
|
|
890
913
|
* @returns The normal matrix.
|
|
891
914
|
* @see [Normal matrix](https://en.wikipedia.org/wiki/Normal_matrix)
|
|
@@ -893,7 +916,8 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
|
|
|
893
916
|
public static normalFromMatrix4(matrix: Matrix4Like): Matrix3;
|
|
894
917
|
|
|
895
918
|
/**
|
|
896
|
-
* Calculates a three-by-three normal (inverse transpose) matrix from a
|
|
919
|
+
* Calculates a three-by-three normal (inverse transpose) matrix from a
|
|
920
|
+
* four-by-four matrix.
|
|
897
921
|
* @param matrix The four-by-four matrix.
|
|
898
922
|
* @param out The matrix to store the result in.
|
|
899
923
|
* @returns The normal matrix.
|
|
@@ -945,14 +969,16 @@ export default class Matrix3 extends Float32Array implements SquareMatrix {
|
|
|
945
969
|
}
|
|
946
970
|
|
|
947
971
|
/**
|
|
948
|
-
* Creates a three-by-three matrix from the upper-left corner of a
|
|
972
|
+
* Creates a three-by-three matrix from the upper-left corner of a
|
|
973
|
+
* four-by-four matrix.
|
|
949
974
|
* @param matrix The four-by-four matrix.
|
|
950
975
|
* @returns The three-by-three matrix.
|
|
951
976
|
*/
|
|
952
977
|
public static fromMatrix4(matrix: Matrix4Like): Matrix3;
|
|
953
978
|
|
|
954
979
|
/**
|
|
955
|
-
* Creates a three-by-three matrix from the upper-left corner of a
|
|
980
|
+
* Creates a three-by-three matrix from the upper-left corner of a
|
|
981
|
+
* four-by-four matrix.
|
|
956
982
|
* @param matrix The four-by-four matrix.
|
|
957
983
|
* @param out The matrix to store the result in.
|
|
958
984
|
* @returns The three-by-three matrix.
|
package/src/linalg/Matrix4.ts
CHANGED
|
@@ -33,7 +33,16 @@ export type Matrix4Like =
|
|
|
33
33
|
];
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Creates a
|
|
36
|
+
* Creates a 4x4 matrix-like object.
|
|
37
|
+
* @returns A 4x4 matrix-like object.
|
|
38
|
+
*/
|
|
39
|
+
export function createMatrix4Like(): Matrix4Like {
|
|
40
|
+
return new Float32Array(16) as Matrix4Like;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Creates a transformation matrix that represents a translation by the given
|
|
45
|
+
* vector.
|
|
37
46
|
* @param vector The translation vector.
|
|
38
47
|
* @param out The matrix to store the result in.
|
|
39
48
|
* @returns The transformation matrix.
|
|
@@ -63,7 +72,8 @@ export function fromTranslation<T extends Matrix4Like>(
|
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
/**
|
|
66
|
-
* Creates a transformation matrix that represents a scaling by the given
|
|
75
|
+
* Creates a transformation matrix that represents a scaling by the given
|
|
76
|
+
* vector.
|
|
67
77
|
* @param vector The scaling vector.
|
|
68
78
|
* @param out The matrix to store the result in.
|
|
69
79
|
* @returns The transformation matrix.
|
|
@@ -119,7 +129,8 @@ export function identity<T extends Matrix4Like>(out: T): T {
|
|
|
119
129
|
}
|
|
120
130
|
|
|
121
131
|
/**
|
|
122
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
132
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
133
|
+
* angle around the Z-axis.
|
|
123
134
|
* @param radians The angle in radians.
|
|
124
135
|
* @param axis The axis to rotate around.
|
|
125
136
|
* @param out The matrix to store the result in.
|
|
@@ -169,7 +180,8 @@ export function fromRotation<T extends Matrix4Like>(
|
|
|
169
180
|
}
|
|
170
181
|
|
|
171
182
|
/**
|
|
172
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
183
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
184
|
+
* angle around the X-axis.
|
|
173
185
|
* @param radians The angle in radians.
|
|
174
186
|
* @param out The matrix to store the result in.
|
|
175
187
|
* @returns The transformation matrix.
|
|
@@ -202,7 +214,8 @@ export function fromXRotation<T extends Matrix4Like>(
|
|
|
202
214
|
}
|
|
203
215
|
|
|
204
216
|
/**
|
|
205
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
217
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
218
|
+
* angle around the Y-axis.
|
|
206
219
|
* @param radians The angle in radians.
|
|
207
220
|
* @param out The matrix to store the result in.
|
|
208
221
|
* @returns The transformation matrix.
|
|
@@ -235,7 +248,8 @@ export function fromYRotation<T extends Matrix4Like>(
|
|
|
235
248
|
}
|
|
236
249
|
|
|
237
250
|
/**
|
|
238
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
251
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
252
|
+
* angle around the Z-axis.
|
|
239
253
|
* @param radians The angle in radians.
|
|
240
254
|
* @param out The matrix to store the result in.
|
|
241
255
|
* @returns The transformation matrix.
|
|
@@ -320,7 +334,8 @@ export function fromRotationTranslation<T extends Matrix4Like>(
|
|
|
320
334
|
}
|
|
321
335
|
|
|
322
336
|
/**
|
|
323
|
-
* Creates a transformation matrix from the given rotation, translation, and
|
|
337
|
+
* Creates a transformation matrix from the given rotation, translation, and
|
|
338
|
+
* scale.
|
|
324
339
|
* @param rotation The rotation quaternion.
|
|
325
340
|
* @param translation The translation vector.
|
|
326
341
|
* @param scaling The scaling vector.
|
|
@@ -378,7 +393,8 @@ export function fromRotationTranslationScale<T extends Matrix4Like>(
|
|
|
378
393
|
}
|
|
379
394
|
|
|
380
395
|
/**
|
|
381
|
-
* Creates a transformation matrix from the given rotation, translation, and
|
|
396
|
+
* Creates a transformation matrix from the given rotation, translation, and
|
|
397
|
+
* scale around the given origin.
|
|
382
398
|
* @param rotation The rotation quaternion.
|
|
383
399
|
* @param translation The translation vector.
|
|
384
400
|
* @param scaling The scaling vector.
|
|
@@ -541,7 +557,8 @@ export function frustum<T extends Matrix4Like>(
|
|
|
541
557
|
/**
|
|
542
558
|
* Creates a perspective projection matrix with the given bounds.
|
|
543
559
|
* @param fov The vertical field of view in radians.
|
|
544
|
-
* @param aspect The aspect ratio (typically the width of the viewport divided
|
|
560
|
+
* @param aspect The aspect ratio (typically the width of the viewport divided
|
|
561
|
+
* by its height).
|
|
545
562
|
* @param near The near bound of the frustum.
|
|
546
563
|
* @param far The far bound of the frustum.
|
|
547
564
|
* @param out The matrix to store the result in.
|
|
@@ -586,7 +603,8 @@ export function perspective<T extends Matrix4Like>(
|
|
|
586
603
|
}
|
|
587
604
|
|
|
588
605
|
/**
|
|
589
|
-
* Creates a perspective projection matrix from a field of view. Useful for
|
|
606
|
+
* Creates a perspective projection matrix from a field of view. Useful for
|
|
607
|
+
* generating projection matrices to be used with the WebXR API.
|
|
590
608
|
* @param fov The field of view.
|
|
591
609
|
* @param near The near bound of the frustum.
|
|
592
610
|
* @param far The far bound of the frustum.
|
|
@@ -674,7 +692,8 @@ export function ortho<T extends Matrix4Like>(
|
|
|
674
692
|
}
|
|
675
693
|
|
|
676
694
|
/**
|
|
677
|
-
* Generates a look-at matrix. If you want a matrix that actually makes an
|
|
695
|
+
* Generates a look-at matrix. If you want a matrix that actually makes an
|
|
696
|
+
* object look at another object, use `targetTo` instead.
|
|
678
697
|
* @param eye The position of the viewer.
|
|
679
698
|
* @param center The point that the viewer is looking at.
|
|
680
699
|
* @param up The local up direction.
|
|
@@ -1949,7 +1968,8 @@ export function getRotation<T extends QuaternionLike>(
|
|
|
1949
1968
|
*/
|
|
1950
1969
|
export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
1951
1970
|
/**
|
|
1952
|
-
* Creates a transformation matrix that represents a translation by the
|
|
1971
|
+
* Creates a transformation matrix that represents a translation by the
|
|
1972
|
+
* given vector.
|
|
1953
1973
|
* @param vector The translation vector.
|
|
1954
1974
|
* @returns The transformation matrix.
|
|
1955
1975
|
* @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
|
|
@@ -1957,7 +1977,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
1957
1977
|
public static fromTranslation(vector: Vector3Like): Matrix4;
|
|
1958
1978
|
|
|
1959
1979
|
/**
|
|
1960
|
-
* Creates a transformation matrix that represents a translation by the
|
|
1980
|
+
* Creates a transformation matrix that represents a translation by the
|
|
1981
|
+
* given vector.
|
|
1961
1982
|
* @param vector The translation vector.
|
|
1962
1983
|
* @param out The matrix to store the result in.
|
|
1963
1984
|
* @returns The transformation matrix.
|
|
@@ -1976,7 +1997,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
1976
1997
|
}
|
|
1977
1998
|
|
|
1978
1999
|
/**
|
|
1979
|
-
* Creates a transformation matrix that represents a scaling by the given
|
|
2000
|
+
* Creates a transformation matrix that represents a scaling by the given
|
|
2001
|
+
* vector.
|
|
1980
2002
|
* @param vector The scaling vector.
|
|
1981
2003
|
* @returns The transformation matrix.
|
|
1982
2004
|
* @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
|
|
@@ -1984,7 +2006,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
1984
2006
|
public static fromScaling(vector: Vector3Like): Matrix4;
|
|
1985
2007
|
|
|
1986
2008
|
/**
|
|
1987
|
-
* Creates a transformation matrix that represents a scaling by the given
|
|
2009
|
+
* Creates a transformation matrix that represents a scaling by the given
|
|
2010
|
+
* vector.
|
|
1988
2011
|
* @param vector The scaling vector.
|
|
1989
2012
|
* @param out The matrix to store the result in.
|
|
1990
2013
|
* @returns The transformation matrix.
|
|
@@ -2003,7 +2026,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2003
2026
|
}
|
|
2004
2027
|
|
|
2005
2028
|
/**
|
|
2006
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
2029
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
2030
|
+
* angle around the given axis.
|
|
2007
2031
|
* @param radians The angle in radians.
|
|
2008
2032
|
* @param axis The axis to rotate around.
|
|
2009
2033
|
* @returns The transformation matrix.
|
|
@@ -2012,7 +2036,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2012
2036
|
public static fromRotation(radians: number, axis: Vector3Like): Matrix4;
|
|
2013
2037
|
|
|
2014
2038
|
/**
|
|
2015
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
2039
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
2040
|
+
* angle around the Z-axis.
|
|
2016
2041
|
* @param radians The angle in radians.
|
|
2017
2042
|
* @param axis The axis to rotate around.
|
|
2018
2043
|
* @param out The matrix to store the result in.
|
|
@@ -2034,7 +2059,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2034
2059
|
}
|
|
2035
2060
|
|
|
2036
2061
|
/**
|
|
2037
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
2062
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
2063
|
+
* angle around the X-axis.
|
|
2038
2064
|
* @param radians The angle in radians.
|
|
2039
2065
|
* @returns The transformation matrix.
|
|
2040
2066
|
* @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
|
|
@@ -2042,7 +2068,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2042
2068
|
public static fromXRotation(radians: number): Matrix4;
|
|
2043
2069
|
|
|
2044
2070
|
/**
|
|
2045
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
2071
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
2072
|
+
* angle around the X-axis.
|
|
2046
2073
|
* @param radians The angle in radians.
|
|
2047
2074
|
* @param out The matrix to store the result in.
|
|
2048
2075
|
* @returns The transformation matrix.
|
|
@@ -2061,7 +2088,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2061
2088
|
}
|
|
2062
2089
|
|
|
2063
2090
|
/**
|
|
2064
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
2091
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
2092
|
+
* angle around the Y-axis.
|
|
2065
2093
|
* @param radians The angle in radians.
|
|
2066
2094
|
* @returns The transformation matrix.
|
|
2067
2095
|
* @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
|
|
@@ -2069,7 +2097,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2069
2097
|
public static fromYRotation(radians: number): Matrix4;
|
|
2070
2098
|
|
|
2071
2099
|
/**
|
|
2072
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
2100
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
2101
|
+
* angle around the Y-axis.
|
|
2073
2102
|
* @param radians The angle in radians.
|
|
2074
2103
|
* @param out The matrix to store the result in.
|
|
2075
2104
|
* @returns The transformation matrix.
|
|
@@ -2088,7 +2117,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2088
2117
|
}
|
|
2089
2118
|
|
|
2090
2119
|
/**
|
|
2091
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
2120
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
2121
|
+
* angle around the Z-axis.
|
|
2092
2122
|
* @param radians The angle in radians.
|
|
2093
2123
|
* @returns The transformation matrix.
|
|
2094
2124
|
* @see [Rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix)
|
|
@@ -2096,7 +2126,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2096
2126
|
public static fromZRotation(radians: number): Matrix4;
|
|
2097
2127
|
|
|
2098
2128
|
/**
|
|
2099
|
-
* Creates a transformation matrix that represents a rotation by the given
|
|
2129
|
+
* Creates a transformation matrix that represents a rotation by the given
|
|
2130
|
+
* angle around the Z-axis.
|
|
2100
2131
|
* @param radians The angle in radians.
|
|
2101
2132
|
* @param out The matrix to store the result in.
|
|
2102
2133
|
* @returns The transformation matrix.
|
|
@@ -2151,7 +2182,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2151
2182
|
}
|
|
2152
2183
|
|
|
2153
2184
|
/**
|
|
2154
|
-
* Creates a transformation matrix from the given rotation, translation,
|
|
2185
|
+
* Creates a transformation matrix from the given rotation, translation,
|
|
2186
|
+
* and scale.
|
|
2155
2187
|
* @param rotation The rotation quaternion.
|
|
2156
2188
|
* @param translation The translation vector.
|
|
2157
2189
|
* @param scaling The scaling vector.
|
|
@@ -2166,7 +2198,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2166
2198
|
): Matrix4;
|
|
2167
2199
|
|
|
2168
2200
|
/**
|
|
2169
|
-
* Creates a transformation matrix from the given rotation, translation,
|
|
2201
|
+
* Creates a transformation matrix from the given rotation, translation,
|
|
2202
|
+
* and scale.
|
|
2170
2203
|
* @param rotation The rotation quaternion.
|
|
2171
2204
|
* @param translation The translation vector.
|
|
2172
2205
|
* @param scaling The scaling vector.
|
|
@@ -2192,7 +2225,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2192
2225
|
}
|
|
2193
2226
|
|
|
2194
2227
|
/**
|
|
2195
|
-
* Creates a transformation matrix from the given rotation, translation,
|
|
2228
|
+
* Creates a transformation matrix from the given rotation, translation,
|
|
2229
|
+
* and scale around the given origin.
|
|
2196
2230
|
* @param rotation The rotation quaternion.
|
|
2197
2231
|
* @param translation The translation vector.
|
|
2198
2232
|
* @param scaling The scaling vector.
|
|
@@ -2209,7 +2243,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2209
2243
|
): Matrix4;
|
|
2210
2244
|
|
|
2211
2245
|
/**
|
|
2212
|
-
* Creates a transformation matrix from the given rotation, translation,
|
|
2246
|
+
* Creates a transformation matrix from the given rotation, translation,
|
|
2247
|
+
* and scale around the given origin.
|
|
2213
2248
|
* @param rotation The rotation quaternion.
|
|
2214
2249
|
* @param translation The translation vector.
|
|
2215
2250
|
* @param scaling The scaling vector.
|
|
@@ -2333,7 +2368,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2333
2368
|
/**
|
|
2334
2369
|
* Creates a perspective projection matrix with the given bounds.
|
|
2335
2370
|
* @param fov The vertical field of view in radians.
|
|
2336
|
-
* @param aspect The aspect ratio (typically the width of the viewport
|
|
2371
|
+
* @param aspect The aspect ratio (typically the width of the viewport
|
|
2372
|
+
* divided by its height).
|
|
2337
2373
|
* @param near The near bound of the frustum.
|
|
2338
2374
|
* @param far The far bound of the frustum.
|
|
2339
2375
|
* @returns The perspective projection matrix.
|
|
@@ -2350,7 +2386,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2350
2386
|
/**
|
|
2351
2387
|
* Creates a perspective projection matrix with the given bounds.
|
|
2352
2388
|
* @param fov The vertical field of view in radians.
|
|
2353
|
-
* @param aspect The aspect ratio (typically the width of the viewport
|
|
2389
|
+
* @param aspect The aspect ratio (typically the width of the viewport
|
|
2390
|
+
* divided by its height).
|
|
2354
2391
|
* @param near The near bound of the frustum.
|
|
2355
2392
|
* @param far The far bound of the frustum.
|
|
2356
2393
|
* @param out The matrix to store the result in.
|
|
@@ -2377,7 +2414,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2377
2414
|
}
|
|
2378
2415
|
|
|
2379
2416
|
/**
|
|
2380
|
-
* Creates a perspective projection matrix from a field of view. Useful for
|
|
2417
|
+
* Creates a perspective projection matrix from a field of view. Useful for
|
|
2418
|
+
* generating projection matrices to be used with the WebXR API.
|
|
2381
2419
|
* @param fov The field of view.
|
|
2382
2420
|
* @param near The near bound of the frustum.
|
|
2383
2421
|
* @param far The far bound of the frustum.
|
|
@@ -2393,7 +2431,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2393
2431
|
): Matrix4;
|
|
2394
2432
|
|
|
2395
2433
|
/**
|
|
2396
|
-
* Creates a perspective projection matrix from a field of view. Useful for
|
|
2434
|
+
* Creates a perspective projection matrix from a field of view. Useful for
|
|
2435
|
+
* generating projection matrices to be used with the WebXR API.
|
|
2397
2436
|
* @param fov The field of view.
|
|
2398
2437
|
* @param near The near bound of the frustum.
|
|
2399
2438
|
* @param far The far bound of the frustum.
|
|
@@ -2476,7 +2515,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2476
2515
|
}
|
|
2477
2516
|
|
|
2478
2517
|
/**
|
|
2479
|
-
* Generates a look-at matrix. If you want a matrix that actually makes an
|
|
2518
|
+
* Generates a look-at matrix. If you want a matrix that actually makes an
|
|
2519
|
+
* object look at another object, use `targetTo` instead.
|
|
2480
2520
|
* @param eye The position of the viewer.
|
|
2481
2521
|
* @param center The point that the viewer is looking at.
|
|
2482
2522
|
* @param up The local up direction.
|
|
@@ -2490,7 +2530,8 @@ export default class Matrix4 extends Float32Array implements SquareMatrix {
|
|
|
2490
2530
|
): Matrix4;
|
|
2491
2531
|
|
|
2492
2532
|
/**
|
|
2493
|
-
* Generates a look-at matrix. If you want a matrix that actually makes an
|
|
2533
|
+
* Generates a look-at matrix. If you want a matrix that actually makes an
|
|
2534
|
+
* object look at another object, use `targetTo` instead.
|
|
2494
2535
|
* @param eye The position of the viewer.
|
|
2495
2536
|
* @param center The point that the viewer is looking at.
|
|
2496
2537
|
* @param up The local up direction.
|