@lakuna/umath 1.3.2 → 1.3.4
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/Quaternion.ts
CHANGED
|
@@ -20,6 +20,14 @@ import epsilon from "#epsilon";
|
|
|
20
20
|
/** A complex number that is commonly used to describe rotations. */
|
|
21
21
|
export type QuaternionLike = Quaternion | [number, number, number, number];
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Creates a quaternion-like object.
|
|
25
|
+
* @returns A quaternion-like object.
|
|
26
|
+
*/
|
|
27
|
+
export function createQuaternionLike(): QuaternionLike {
|
|
28
|
+
return new Float32Array(4) as QuaternionLike;
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
/**
|
|
24
32
|
* Creates a quaternion from a three-by-three rotation matrix.
|
|
25
33
|
* @param matrix The matrix.
|
|
@@ -104,11 +112,15 @@ export function fromEuler<T extends QuaternionLike>(
|
|
|
104
112
|
return out;
|
|
105
113
|
}
|
|
106
114
|
|
|
107
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* A three-by-three matrix that is used to store intermediary values for some
|
|
117
|
+
* functions.
|
|
118
|
+
*/
|
|
108
119
|
const intermediary: Matrix3Like = new Float32Array(9) as Matrix3Like;
|
|
109
120
|
|
|
110
121
|
/**
|
|
111
|
-
* Creates a quaternion with values corresponding to the given orthonormal set
|
|
122
|
+
* Creates a quaternion with values corresponding to the given orthonormal set
|
|
123
|
+
* of vectors.
|
|
112
124
|
* @param view The vector representing the viewing direction.
|
|
113
125
|
* @param right The vector representing the local "right" direction.
|
|
114
126
|
* @param up The vector representing the local "up" direction.
|
|
@@ -318,7 +330,8 @@ export function rotateZ<T extends QuaternionLike>(
|
|
|
318
330
|
}
|
|
319
331
|
|
|
320
332
|
/**
|
|
321
|
-
* Calculates the fourth component of a unit quaternion from the first three,
|
|
333
|
+
* Calculates the fourth component of a unit quaternion from the first three,
|
|
334
|
+
* ignoring the existing fourth component.
|
|
322
335
|
* @param quaternion The quaternion.
|
|
323
336
|
* @param out The quaternion to store the result in.
|
|
324
337
|
* @returns The quaternion.
|
|
@@ -486,7 +499,8 @@ export function random<T extends QuaternionLike>(out: T): T {
|
|
|
486
499
|
}
|
|
487
500
|
|
|
488
501
|
/**
|
|
489
|
-
* Calculates the inverse of a quaternion. If the quaternion is normalized, the
|
|
502
|
+
* Calculates the inverse of a quaternion. If the quaternion is normalized, the
|
|
503
|
+
* conjugate is the same but faster to calculate.
|
|
490
504
|
* @param quaternion The quaternion.
|
|
491
505
|
* @param out The quaternion to store the result in.
|
|
492
506
|
* @returns The inverse.
|
|
@@ -519,7 +533,8 @@ export function invert<T extends QuaternionLike>(
|
|
|
519
533
|
}
|
|
520
534
|
|
|
521
535
|
/**
|
|
522
|
-
* Calculates the conjugate of a quaternion. If the quaternion is normalized,
|
|
536
|
+
* Calculates the conjugate of a quaternion. If the quaternion is normalized,
|
|
537
|
+
* this is the same as the inverse but faster to calculate.
|
|
523
538
|
* @param quaternion The quaternion.
|
|
524
539
|
* @param out The quaternion to store the result in.
|
|
525
540
|
* @returns The conjugate.
|
|
@@ -535,14 +550,19 @@ export function conjugate<T extends QuaternionLike>(
|
|
|
535
550
|
return out;
|
|
536
551
|
}
|
|
537
552
|
|
|
538
|
-
/**
|
|
553
|
+
/**
|
|
554
|
+
* A quaternion that is used to store intermediary values for some functions.
|
|
555
|
+
*/
|
|
539
556
|
const controlPointOne: QuaternionLike = new Float32Array(4) as QuaternionLike;
|
|
540
557
|
|
|
541
|
-
/**
|
|
558
|
+
/**
|
|
559
|
+
* A quaternion that is used to store intermediary values for some functions.
|
|
560
|
+
*/
|
|
542
561
|
const controlPointTwo: QuaternionLike = new Float32Array(4) as QuaternionLike;
|
|
543
562
|
|
|
544
563
|
/**
|
|
545
|
-
* Performs a spherical linear interpolation with two control points between
|
|
564
|
+
* Performs a spherical linear interpolation with two control points between
|
|
565
|
+
* two quaternions.
|
|
546
566
|
* @param a The first quaternion.
|
|
547
567
|
* @param b The first control point.
|
|
548
568
|
* @param c The second control point.
|
|
@@ -675,7 +695,8 @@ export default class Quaternion extends Float32Array {
|
|
|
675
695
|
}
|
|
676
696
|
|
|
677
697
|
/**
|
|
678
|
-
* Creates a quaternion with values corresponding to the given orthonormal
|
|
698
|
+
* Creates a quaternion with values corresponding to the given orthonormal
|
|
699
|
+
* set of vectors.
|
|
679
700
|
* @param view The vector representing the viewing direction.
|
|
680
701
|
* @param right The vector representing the local "right" direction.
|
|
681
702
|
* @param up The vector representing the local "up" direction.
|
|
@@ -688,7 +709,8 @@ export default class Quaternion extends Float32Array {
|
|
|
688
709
|
): Quaternion;
|
|
689
710
|
|
|
690
711
|
/**
|
|
691
|
-
* Creates a quaternion with values corresponding to the given orthonormal
|
|
712
|
+
* Creates a quaternion with values corresponding to the given orthonormal
|
|
713
|
+
* set of vectors.
|
|
692
714
|
* @param view The vector representing the viewing direction.
|
|
693
715
|
* @param right The vector representing the local "right" direction.
|
|
694
716
|
* @param up The vector representing the local "up" direction.
|
|
@@ -855,13 +877,15 @@ export default class Quaternion extends Float32Array {
|
|
|
855
877
|
}
|
|
856
878
|
|
|
857
879
|
/**
|
|
858
|
-
* Calculates the fourth component of this unit quaternion from the first
|
|
880
|
+
* Calculates the fourth component of this unit quaternion from the first
|
|
881
|
+
* three, ignoring the existing fourth component.
|
|
859
882
|
* @returns The quaternion.
|
|
860
883
|
*/
|
|
861
884
|
public calculateW(): Quaternion;
|
|
862
885
|
|
|
863
886
|
/**
|
|
864
|
-
* Calculates the fourth component of this unit quaternion from the first
|
|
887
|
+
* Calculates the fourth component of this unit quaternion from the first
|
|
888
|
+
* three, ignoring the existing fourth component.
|
|
865
889
|
* @param out The quaternion to store the result in.
|
|
866
890
|
* @returns The quaternion.
|
|
867
891
|
*/
|
|
@@ -930,7 +954,8 @@ export default class Quaternion extends Float32Array {
|
|
|
930
954
|
}
|
|
931
955
|
|
|
932
956
|
/**
|
|
933
|
-
* Performs a spherical linear interpolation between this and another
|
|
957
|
+
* Performs a spherical linear interpolation between this and another
|
|
958
|
+
* quaternion.
|
|
934
959
|
* @param quaternion The other quaternion.
|
|
935
960
|
* @param t The interpolation amount in `[0,1]`.
|
|
936
961
|
* @returns The interpolated quaternion.
|
|
@@ -939,7 +964,8 @@ export default class Quaternion extends Float32Array {
|
|
|
939
964
|
public slerp(quaternion: QuaternionLike, t: number): Quaternion;
|
|
940
965
|
|
|
941
966
|
/**
|
|
942
|
-
* Performs a spherical linear interpolation between this and another
|
|
967
|
+
* Performs a spherical linear interpolation between this and another
|
|
968
|
+
* quaternion.
|
|
943
969
|
* @param quaternion The other quaternion.
|
|
944
970
|
* @param t The interpolation amount in `[0,1]`.
|
|
945
971
|
* @param out The quaternion to store the result in.
|
|
@@ -969,13 +995,15 @@ export default class Quaternion extends Float32Array {
|
|
|
969
995
|
}
|
|
970
996
|
|
|
971
997
|
/**
|
|
972
|
-
* Calculates the inverse of this quaternion. If the quaternion is
|
|
998
|
+
* Calculates the inverse of this quaternion. If the quaternion is
|
|
999
|
+
* normalized, the conjugate is the same but faster to calculate.
|
|
973
1000
|
* @returns The inverse.
|
|
974
1001
|
*/
|
|
975
1002
|
public invert(): Quaternion;
|
|
976
1003
|
|
|
977
1004
|
/**
|
|
978
|
-
* Calculates the inverse of this quaternion. If the quaternion is
|
|
1005
|
+
* Calculates the inverse of this quaternion. If the quaternion is
|
|
1006
|
+
* normalized, the conjugate is the same but faster to calculate.
|
|
979
1007
|
* @param out The quaternion to store the result in.
|
|
980
1008
|
* @returns The inverse.
|
|
981
1009
|
*/
|
|
@@ -986,13 +1014,15 @@ export default class Quaternion extends Float32Array {
|
|
|
986
1014
|
}
|
|
987
1015
|
|
|
988
1016
|
/**
|
|
989
|
-
* Calculates the conjugate of this quaternion. If the quaternion is
|
|
1017
|
+
* Calculates the conjugate of this quaternion. If the quaternion is
|
|
1018
|
+
* normalized, this is the same as the inverse but faster to calculate.
|
|
990
1019
|
* @returns The conjugate.
|
|
991
1020
|
*/
|
|
992
1021
|
public conjugate(): Quaternion;
|
|
993
1022
|
|
|
994
1023
|
/**
|
|
995
|
-
* Calculates the conjugate of this quaternion. If the quaternion is
|
|
1024
|
+
* Calculates the conjugate of this quaternion. If the quaternion is
|
|
1025
|
+
* normalized, this is the same as the inverse but faster to calculate.
|
|
996
1026
|
* @param out The quaternion to store the result in.
|
|
997
1027
|
* @returns The conjugate.
|
|
998
1028
|
*/
|
|
@@ -1179,7 +1209,8 @@ export default class Quaternion extends Float32Array {
|
|
|
1179
1209
|
}
|
|
1180
1210
|
|
|
1181
1211
|
/**
|
|
1182
|
-
* Performs a spherical linear interpolation with two control points
|
|
1212
|
+
* Performs a spherical linear interpolation with two control points
|
|
1213
|
+
* between this and another quaternion.
|
|
1183
1214
|
* @param a The first control point.
|
|
1184
1215
|
* @param b The second control point.
|
|
1185
1216
|
* @param quaternion The other quaternion.
|
|
@@ -1195,7 +1226,8 @@ export default class Quaternion extends Float32Array {
|
|
|
1195
1226
|
): Quaternion;
|
|
1196
1227
|
|
|
1197
1228
|
/**
|
|
1198
|
-
* Performs a spherical linear interpolation with two control points
|
|
1229
|
+
* Performs a spherical linear interpolation with two control points
|
|
1230
|
+
* between this and another quaternion.
|
|
1199
1231
|
* @param a The first control point.
|
|
1200
1232
|
* @param b The second control point.
|
|
1201
1233
|
* @param quaternion The other quaternion.
|
|
@@ -12,7 +12,8 @@ export default class SlowSquareMatrix
|
|
|
12
12
|
implements SquareMatrix
|
|
13
13
|
{
|
|
14
14
|
/**
|
|
15
|
-
* Creates a variable-size matrix with the same number of rows and columns
|
|
15
|
+
* Creates a variable-size matrix with the same number of rows and columns
|
|
16
|
+
* from the given columns.
|
|
16
17
|
* @param cols The columns in the matrix.
|
|
17
18
|
* @see [Square matrix](https://en.wikipedia.org/wiki/Square_matrix)
|
|
18
19
|
*/
|
|
@@ -160,7 +161,8 @@ export default class SlowSquareMatrix
|
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
/**
|
|
163
|
-
* Calculates the minor of this matrix which results from removing the
|
|
164
|
+
* Calculates the minor of this matrix which results from removing the
|
|
165
|
+
* given row and column.
|
|
164
166
|
* @param row The row to remove.
|
|
165
167
|
* @param col The column to remove.
|
|
166
168
|
* @returns The minor.
|
|
@@ -171,7 +173,8 @@ export default class SlowSquareMatrix
|
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
/**
|
|
174
|
-
* Creates a submatrix by removing the given row and column from this
|
|
176
|
+
* Creates a submatrix by removing the given row and column from this
|
|
177
|
+
* matrix.
|
|
175
178
|
* @param row The row to remove.
|
|
176
179
|
* @param col The column to remove.
|
|
177
180
|
* @returns The submatrix.
|
package/src/linalg/Vector.ts
CHANGED
|
@@ -116,7 +116,8 @@ export default interface Vector extends Iterable<number> {
|
|
|
116
116
|
distance(vector: VectorLike): number;
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
* Calculates the squared Euclidean distance between this vector and
|
|
119
|
+
* Calculates the squared Euclidean distance between this vector and
|
|
120
|
+
* another.
|
|
120
121
|
* @param vector The other vector.
|
|
121
122
|
* @returns The squared distance.
|
|
122
123
|
*/
|
package/src/linalg/Vector2.ts
CHANGED
|
@@ -8,6 +8,14 @@ import epsilon from "#epsilon";
|
|
|
8
8
|
/** A quantity with magnitude and direction in two dimensions. */
|
|
9
9
|
export type Vector2Like = Vector2 | [number, number];
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Creates a 2x1 vector-like object.
|
|
13
|
+
* @returns A 2x1 vector-like object.
|
|
14
|
+
*/
|
|
15
|
+
export function createVector2Like(): Vector2Like {
|
|
16
|
+
return new Float32Array(2) as Vector2Like;
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
/**
|
|
12
20
|
* Creates a vector with the given values.
|
|
13
21
|
* @param x The first component.
|
|
@@ -84,7 +92,8 @@ export function copy<T extends Vector2Like>(vector: Vector2Like, out: T): T {
|
|
|
84
92
|
}
|
|
85
93
|
|
|
86
94
|
/**
|
|
87
|
-
* Multiplies the components in one vector by the corresponding components in
|
|
95
|
+
* Multiplies the components in one vector by the corresponding components in
|
|
96
|
+
* another.
|
|
88
97
|
* @param a The multiplicand.
|
|
89
98
|
* @param b The multiplier.
|
|
90
99
|
* @param out The vector to store the result in.
|
|
@@ -634,14 +643,16 @@ export default class Vector2 extends Float32Array implements Vector {
|
|
|
634
643
|
}
|
|
635
644
|
|
|
636
645
|
/**
|
|
637
|
-
* Multiplies the components in this vector by the corresponding components
|
|
646
|
+
* Multiplies the components in this vector by the corresponding components
|
|
647
|
+
* in another.
|
|
638
648
|
* @param vector The other vector.
|
|
639
649
|
* @returns The product of the vectors.
|
|
640
650
|
*/
|
|
641
651
|
public multiply(vector: Vector2Like): Vector2;
|
|
642
652
|
|
|
643
653
|
/**
|
|
644
|
-
* Multiplies the components in this vector by the corresponding components
|
|
654
|
+
* Multiplies the components in this vector by the corresponding components
|
|
655
|
+
* in another.
|
|
645
656
|
* @param vector The other vector.
|
|
646
657
|
* @param out The vector to store the result in.
|
|
647
658
|
* @returns The product of the vectors.
|
package/src/linalg/Vector3.ts
CHANGED
|
@@ -8,6 +8,14 @@ import epsilon from "#epsilon";
|
|
|
8
8
|
/** A quantity with magnitude and direction in three dimensions. */
|
|
9
9
|
export type Vector3Like = Vector3 | [number, number, number];
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Creates a 3x1 vector-like object.
|
|
13
|
+
* @returns A 3x1 vector-like object.
|
|
14
|
+
*/
|
|
15
|
+
export function createVector3Like(): Vector3Like {
|
|
16
|
+
return new Float32Array(3) as Vector3Like;
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
/**
|
|
12
20
|
* Creates a vector with the given values.
|
|
13
21
|
* @param x The first component.
|
|
@@ -745,7 +753,8 @@ const yAxis: Vector3Like = new Float32Array([0, 1, 0]) as Vector3Like;
|
|
|
745
753
|
const intermediary: Vector3Like = new Float32Array(3) as Vector3Like;
|
|
746
754
|
|
|
747
755
|
/**
|
|
748
|
-
* Creates a quaternion that represents the shortest rotation from one unit
|
|
756
|
+
* Creates a quaternion that represents the shortest rotation from one unit
|
|
757
|
+
* vector to another.
|
|
749
758
|
* @param a The first vector.
|
|
750
759
|
* @param b The second vector.
|
|
751
760
|
* @param out The quaternion to store the result in.
|
|
@@ -1122,7 +1131,8 @@ export default class Vector3 extends Float32Array implements Vector {
|
|
|
1122
1131
|
}
|
|
1123
1132
|
|
|
1124
1133
|
/**
|
|
1125
|
-
* Calculates the squared Euclidean distance between this vector and
|
|
1134
|
+
* Calculates the squared Euclidean distance between this vector and
|
|
1135
|
+
* another.
|
|
1126
1136
|
* @param vector The other vector.
|
|
1127
1137
|
* @returns The squared distance.
|
|
1128
1138
|
* @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
|
|
@@ -1419,7 +1429,8 @@ export default class Vector3 extends Float32Array implements Vector {
|
|
|
1419
1429
|
}
|
|
1420
1430
|
|
|
1421
1431
|
/**
|
|
1422
|
-
* Performs a Hermite interpolation with two control points between this
|
|
1432
|
+
* Performs a Hermite interpolation with two control points between this
|
|
1433
|
+
* vector and another.
|
|
1423
1434
|
* @param a The first control point.
|
|
1424
1435
|
* @param b The second control point.
|
|
1425
1436
|
* @param end The other vector.
|
|
@@ -1435,7 +1446,8 @@ export default class Vector3 extends Float32Array implements Vector {
|
|
|
1435
1446
|
): Vector3;
|
|
1436
1447
|
|
|
1437
1448
|
/**
|
|
1438
|
-
* Performs a Hermite interpolation with two control points between this
|
|
1449
|
+
* Performs a Hermite interpolation with two control points between this
|
|
1450
|
+
* vector and another.
|
|
1439
1451
|
* @param a The first control point.
|
|
1440
1452
|
* @param b The second control point.
|
|
1441
1453
|
* @param end The other vector.
|
|
@@ -1463,7 +1475,8 @@ export default class Vector3 extends Float32Array implements Vector {
|
|
|
1463
1475
|
}
|
|
1464
1476
|
|
|
1465
1477
|
/**
|
|
1466
|
-
* Performs a Bézier interpolation with two control points between this
|
|
1478
|
+
* Performs a Bézier interpolation with two control points between this
|
|
1479
|
+
* vector and another.
|
|
1467
1480
|
* @param a The first control point.
|
|
1468
1481
|
* @param b The second control point.
|
|
1469
1482
|
* @param end The other vector.
|
|
@@ -1479,7 +1492,8 @@ export default class Vector3 extends Float32Array implements Vector {
|
|
|
1479
1492
|
): Vector3;
|
|
1480
1493
|
|
|
1481
1494
|
/**
|
|
1482
|
-
* Performs a Bézier interpolation with two control points between this
|
|
1495
|
+
* Performs a Bézier interpolation with two control points between this
|
|
1496
|
+
* vector and another.
|
|
1483
1497
|
* @param a The first control point.
|
|
1484
1498
|
* @param b The second control point.
|
|
1485
1499
|
* @param end The other vector.
|
|
@@ -1534,14 +1548,16 @@ export default class Vector3 extends Float32Array implements Vector {
|
|
|
1534
1548
|
}
|
|
1535
1549
|
|
|
1536
1550
|
/**
|
|
1537
|
-
* Creates a quaternion that represents the shortest rotation from this
|
|
1551
|
+
* Creates a quaternion that represents the shortest rotation from this
|
|
1552
|
+
* vector to another.
|
|
1538
1553
|
* @param vector The other vector.
|
|
1539
1554
|
* @returns The rotation.
|
|
1540
1555
|
*/
|
|
1541
1556
|
public rotationTo(vector: Vector3Like): Quaternion;
|
|
1542
1557
|
|
|
1543
1558
|
/**
|
|
1544
|
-
* Creates a quaternion that represents the shortest rotation from this
|
|
1559
|
+
* Creates a quaternion that represents the shortest rotation from this
|
|
1560
|
+
* unit vector to another.
|
|
1545
1561
|
* @param vector The other vector.
|
|
1546
1562
|
* @param out The quaternion to store the result in.
|
|
1547
1563
|
* @returns The quaternion.
|
package/src/linalg/Vector4.ts
CHANGED
|
@@ -6,6 +6,14 @@ import epsilon from "#epsilon";
|
|
|
6
6
|
/** A quantity with magnitude and direction in four dimensions. */
|
|
7
7
|
export type Vector4Like = Vector4 | [number, number, number, number];
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Creates a 4x1 vector-like object.
|
|
11
|
+
* @returns A 4x1 vector-like object.
|
|
12
|
+
*/
|
|
13
|
+
export function createVector4Like(): Vector4Like {
|
|
14
|
+
return new Float32Array(4) as Vector4Like;
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
/**
|
|
10
18
|
* Creates a vector with the given values.
|
|
11
19
|
* @param x The first component.
|
|
@@ -895,7 +903,8 @@ export default class Vector4 extends Float32Array implements Vector {
|
|
|
895
903
|
}
|
|
896
904
|
|
|
897
905
|
/**
|
|
898
|
-
* Calculates the squared Euclidean distance between this vector and
|
|
906
|
+
* Calculates the squared Euclidean distance between this vector and
|
|
907
|
+
* another.
|
|
899
908
|
* @param vector The other vector.
|
|
900
909
|
* @returns The squared distance.
|
|
901
910
|
* @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
|
|
@@ -978,7 +987,8 @@ export default class Vector4 extends Float32Array implements Vector {
|
|
|
978
987
|
}
|
|
979
988
|
|
|
980
989
|
/**
|
|
981
|
-
* Calculates the cross product of this and two other vectors in a
|
|
990
|
+
* Calculates the cross product of this and two other vectors in a
|
|
991
|
+
* four-dimensional space.
|
|
982
992
|
* @param a One other vector.
|
|
983
993
|
* @param b The other other vector.
|
|
984
994
|
* @returns The cross product.
|
|
@@ -987,7 +997,8 @@ export default class Vector4 extends Float32Array implements Vector {
|
|
|
987
997
|
public cross(a: Vector4Like, b: Vector4Like): Vector4;
|
|
988
998
|
|
|
989
999
|
/**
|
|
990
|
-
* Calculates the cross product of this and two other vectors in a
|
|
1000
|
+
* Calculates the cross product of this and two other vectors in a
|
|
1001
|
+
* four-dimensional space.
|
|
991
1002
|
* @param a One other vector.
|
|
992
1003
|
* @param b The other other vector.
|
|
993
1004
|
* @param out The vector to store the result in.
|
package/src/utility/BigNumber.ts
CHANGED
|
@@ -122,7 +122,8 @@ export default class BigNumber {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
|
-
* Converts this number to a regular `number`. Might result in loss of
|
|
125
|
+
* Converts this number to a regular `number`. Might result in loss of
|
|
126
|
+
* precision.
|
|
126
127
|
* @returns This number as a `number`.
|
|
127
128
|
*/
|
|
128
129
|
public toNumber(): number {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** An error resulting from trying to use a matrix that is the wrong size. */
|
|
2
2
|
export default class PartialMatrixError extends Error {
|
|
3
3
|
/**
|
|
4
|
-
* Creates an error resulting from trying to use a matrix that is the wrong
|
|
4
|
+
* Creates an error resulting from trying to use a matrix that is the wrong
|
|
5
|
+
* size.
|
|
5
6
|
* @param message The message of the error.
|
|
6
7
|
*/
|
|
7
8
|
public constructor(message = "Invalid matrix dimensions.") {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** An error resulting from creating a matrix that isn't a perfect rectangle. */
|
|
2
2
|
export default class PartialMatrixError extends Error {
|
|
3
3
|
/**
|
|
4
|
-
* Creates an error resulting from creating a matrix that isn't a perfect
|
|
4
|
+
* Creates an error resulting from creating a matrix that isn't a perfect
|
|
5
|
+
* rectangle.
|
|
5
6
|
* @param message The message of the error.
|
|
6
7
|
*/
|
|
7
8
|
public constructor(message = "The matrix is not rectangular.") {
|
package/src/utility/epsilon.ts
CHANGED