@lakuna/umath 1.5.0 → 2.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.
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/linalg/DualQuaternion.d.ts +23 -46
- package/dist/linalg/DualQuaternion.d.ts.map +1 -1
- package/dist/linalg/DualQuaternion.js +47 -70
- package/dist/linalg/DualQuaternion.js.map +1 -1
- package/dist/linalg/Matrix2.d.ts +14 -28
- package/dist/linalg/Matrix2.d.ts.map +1 -1
- package/dist/linalg/Matrix2.js +28 -42
- package/dist/linalg/Matrix2.js.map +1 -1
- package/dist/linalg/Matrix3.d.ts +21 -42
- package/dist/linalg/Matrix3.d.ts.map +1 -1
- package/dist/linalg/Matrix3.js +43 -84
- package/dist/linalg/Matrix3.js.map +1 -1
- package/dist/linalg/Matrix4.d.ts +39 -78
- package/dist/linalg/Matrix4.d.ts.map +1 -1
- package/dist/linalg/Matrix4.js +85 -170
- package/dist/linalg/Matrix4.js.map +1 -1
- package/dist/linalg/Quaternion.d.ts +27 -58
- package/dist/linalg/Quaternion.d.ts.map +1 -1
- package/dist/linalg/Quaternion.js +54 -85
- package/dist/linalg/Quaternion.js.map +1 -1
- package/dist/linalg/SlowMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowMatrix.js +52 -78
- package/dist/linalg/SlowMatrix.js.map +1 -1
- package/dist/linalg/SlowVector.d.ts +165 -0
- package/dist/linalg/SlowVector.d.ts.map +1 -0
- package/dist/linalg/SlowVector.js +369 -0
- package/dist/linalg/SlowVector.js.map +1 -0
- package/dist/linalg/Vector.d.ts +14 -15
- package/dist/linalg/Vector.d.ts.map +1 -1
- package/dist/linalg/Vector2.d.ts +28 -50
- package/dist/linalg/Vector2.d.ts.map +1 -1
- package/dist/linalg/Vector2.js +59 -85
- package/dist/linalg/Vector2.js.map +1 -1
- package/dist/linalg/Vector3.d.ts +32 -58
- package/dist/linalg/Vector3.d.ts.map +1 -1
- package/dist/linalg/Vector3.js +67 -107
- package/dist/linalg/Vector3.js.map +1 -1
- package/dist/linalg/Vector4.d.ts +26 -46
- package/dist/linalg/Vector4.d.ts.map +1 -1
- package/dist/linalg/Vector4.js +54 -82
- package/dist/linalg/Vector4.js.map +1 -1
- package/dist/utility/MatrixSizeError.d.ts +1 -1
- package/dist/utility/MatrixSizeError.d.ts.map +1 -1
- package/dist/utility/MatrixSizeError.js +1 -1
- package/dist/utility/MatrixSizeError.js.map +1 -1
- package/dist/utility/VectorSizeError.d.ts +12 -0
- package/dist/utility/VectorSizeError.d.ts.map +1 -0
- package/dist/utility/VectorSizeError.js +15 -0
- package/dist/utility/VectorSizeError.js.map +1 -0
- package/dist/utility/createAxisAngleLike.d.ts +10 -0
- package/dist/utility/createAxisAngleLike.d.ts.map +1 -0
- package/dist/utility/createAxisAngleLike.js +10 -0
- package/dist/utility/createAxisAngleLike.js.map +1 -0
- package/package.json +1 -3
- package/src/index.ts +7 -0
- package/src/linalg/DualQuaternion.ts +51 -134
- package/src/linalg/Matrix2.ts +30 -81
- package/src/linalg/Matrix3.ts +55 -149
- package/src/linalg/Matrix4.ts +135 -291
- package/src/linalg/Quaternion.ts +60 -151
- package/src/linalg/SlowMatrix.ts +82 -81
- package/src/linalg/SlowVector.ts +449 -0
- package/src/linalg/Vector.ts +14 -16
- package/src/linalg/Vector2.ts +63 -153
- package/src/linalg/Vector3.ts +75 -194
- package/src/linalg/Vector4.ts +60 -143
- package/src/utility/MatrixSizeError.ts +1 -1
- package/src/utility/VectorSizeError.ts +14 -0
- package/src/utility/createAxisAngleLike.ts +13 -0
package/src/linalg/Vector3.ts
CHANGED
|
@@ -302,12 +302,8 @@ export const scaleAndAdd = <T extends Vector3Like>(
|
|
|
302
302
|
* @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
|
|
303
303
|
* @public
|
|
304
304
|
*/
|
|
305
|
-
export const distance = (a: Vector3Like, b: Vector3Like): number =>
|
|
306
|
-
|
|
307
|
-
const y = b[1] - a[1];
|
|
308
|
-
const z = b[2] - a[2];
|
|
309
|
-
return Math.sqrt(x * x + y * y + z * z); // `Math.hypot` is slower.
|
|
310
|
-
};
|
|
305
|
+
export const distance = (a: Vector3Like, b: Vector3Like): number =>
|
|
306
|
+
Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
|
|
311
307
|
|
|
312
308
|
/**
|
|
313
309
|
* Calculate the squared Euclidean distance between this vector and another.
|
|
@@ -330,12 +326,8 @@ export const squaredDistance = (a: Vector3Like, b: Vector3Like): number => {
|
|
|
330
326
|
* @returns The magnitude.
|
|
331
327
|
* @public
|
|
332
328
|
*/
|
|
333
|
-
export const getMagnitude = (vector: Vector3Like): number =>
|
|
334
|
-
|
|
335
|
-
const y = vector[1];
|
|
336
|
-
const z = vector[2];
|
|
337
|
-
return Math.sqrt(x * x + y * y + z * z); // `Math.hypot` is slower.
|
|
338
|
-
};
|
|
329
|
+
export const getMagnitude = (vector: Vector3Like): number =>
|
|
330
|
+
Math.hypot(vector[0], vector[1], vector[2]);
|
|
339
331
|
|
|
340
332
|
/**
|
|
341
333
|
* Calculate the squared magnitude (length) of a vector.
|
|
@@ -655,19 +647,7 @@ export const rotateZ = <T extends Vector3Like>(
|
|
|
655
647
|
* @public
|
|
656
648
|
*/
|
|
657
649
|
export const angle = (a: Vector3Like, b: Vector3Like): number => {
|
|
658
|
-
const
|
|
659
|
-
const ay = a[1];
|
|
660
|
-
const az = a[2];
|
|
661
|
-
|
|
662
|
-
const bx = b[0];
|
|
663
|
-
const by = b[1];
|
|
664
|
-
const bz = b[2];
|
|
665
|
-
|
|
666
|
-
// `Math.hypot` is slower.
|
|
667
|
-
const mag =
|
|
668
|
-
Math.sqrt(ax * ax + ay * ay + az * az) *
|
|
669
|
-
Math.sqrt(bx * bx + by * by + bz * bz);
|
|
670
|
-
|
|
650
|
+
const mag = Math.hypot(a[0], a[1], a[2]) * Math.hypot(b[0], b[1], b[2]);
|
|
671
651
|
return Math.acos(Math.min(Math.max(mag && dot(a, b) / mag, -1), 1));
|
|
672
652
|
};
|
|
673
653
|
|
|
@@ -802,16 +782,10 @@ export default class Vector3
|
|
|
802
782
|
* @param x - The first component.
|
|
803
783
|
* @param y - The second component.
|
|
804
784
|
* @param z - The third component.
|
|
805
|
-
* @param out - The vector to store the result in.
|
|
806
785
|
* @returns A new vector.
|
|
807
786
|
*/
|
|
808
|
-
public static fromValues
|
|
809
|
-
x
|
|
810
|
-
y: number,
|
|
811
|
-
z: number,
|
|
812
|
-
out: T = new Vector3() as Vector3 & T
|
|
813
|
-
): T {
|
|
814
|
-
return fromValues(x, y, z, out);
|
|
787
|
+
public static fromValues(x: number, y: number, z: number): Vector3 {
|
|
788
|
+
return fromValues(x, y, z, new Vector3());
|
|
815
789
|
}
|
|
816
790
|
|
|
817
791
|
/**
|
|
@@ -852,25 +826,18 @@ export default class Vector3
|
|
|
852
826
|
/**
|
|
853
827
|
* Add two vectors of the same size.
|
|
854
828
|
* @param vector - The other vector.
|
|
855
|
-
* @param out - The vector to store the result in.
|
|
856
829
|
* @returns The sum of the vectors.
|
|
857
830
|
*/
|
|
858
|
-
public add
|
|
859
|
-
vector
|
|
860
|
-
out: T = new Vector3() as Vector3 & T
|
|
861
|
-
): T {
|
|
862
|
-
return add(this, vector, out);
|
|
831
|
+
public add(vector: Vector3Like): Vector3 {
|
|
832
|
+
return add(this, vector, new Vector3());
|
|
863
833
|
}
|
|
864
834
|
|
|
865
835
|
/**
|
|
866
836
|
* Copy the values from this vector to another one.
|
|
867
|
-
* @param out - The vector to store the result in.
|
|
868
837
|
* @returns The copy.
|
|
869
838
|
*/
|
|
870
|
-
public clone
|
|
871
|
-
|
|
872
|
-
): T {
|
|
873
|
-
return copy(this, out);
|
|
839
|
+
public clone(): Vector3 {
|
|
840
|
+
return copy(this, new Vector3());
|
|
874
841
|
}
|
|
875
842
|
|
|
876
843
|
/**
|
|
@@ -885,151 +852,106 @@ export default class Vector3
|
|
|
885
852
|
/**
|
|
886
853
|
* Multiply this vector by another.
|
|
887
854
|
* @param vector - The other vector.
|
|
888
|
-
* @param out - The vector to store the result in.
|
|
889
855
|
* @returns The product of the vectors.
|
|
890
856
|
*/
|
|
891
|
-
public multiply
|
|
892
|
-
vector
|
|
893
|
-
out: T = new Vector3() as Vector3 & T
|
|
894
|
-
): T {
|
|
895
|
-
return multiply(this, vector, out);
|
|
857
|
+
public multiply(vector: Vector3Like): Vector3 {
|
|
858
|
+
return multiply(this, vector, new Vector3());
|
|
896
859
|
}
|
|
897
860
|
|
|
898
861
|
/**
|
|
899
862
|
* Divide this vector by another.
|
|
900
863
|
* @param vector - The other vector.
|
|
901
|
-
* @param out - The vector to store the result in.
|
|
902
864
|
* @returns The quotient of the vectors.
|
|
903
865
|
*/
|
|
904
|
-
public divide
|
|
905
|
-
vector
|
|
906
|
-
out: T = new Vector3() as Vector3 & T
|
|
907
|
-
): T {
|
|
908
|
-
return divide(this, vector, out);
|
|
866
|
+
public divide(vector: Vector3Like): Vector3 {
|
|
867
|
+
return divide(this, vector, new Vector3());
|
|
909
868
|
}
|
|
910
869
|
|
|
911
870
|
/**
|
|
912
871
|
* Subtract another vector from this one.
|
|
913
872
|
* @param vector - The other vector.
|
|
914
|
-
* @param out - The vector to store the result in.
|
|
915
873
|
* @returns The difference between the vectors.
|
|
916
874
|
*/
|
|
917
|
-
public subtract
|
|
918
|
-
vector
|
|
919
|
-
out: T = new Vector3() as Vector3 & T
|
|
920
|
-
): T {
|
|
921
|
-
return subtract(this, vector, out);
|
|
875
|
+
public subtract(vector: Vector3Like): Vector3 {
|
|
876
|
+
return subtract(this, vector, new Vector3());
|
|
922
877
|
}
|
|
923
878
|
|
|
924
879
|
/**
|
|
925
880
|
* Absolutize the components of this vector.
|
|
926
|
-
* @param out - The vector to store the result in.
|
|
927
881
|
* @returns The absolutized vector.
|
|
928
882
|
*/
|
|
929
|
-
public abs
|
|
930
|
-
|
|
931
|
-
): T {
|
|
932
|
-
return abs(this, out);
|
|
883
|
+
public abs(): Vector3 {
|
|
884
|
+
return abs(this, new Vector3());
|
|
933
885
|
}
|
|
934
886
|
|
|
935
887
|
/**
|
|
936
888
|
* Round up the components of this vector.
|
|
937
|
-
* @param out - The vector to store the result in.
|
|
938
889
|
* @returns The rounded vector.
|
|
939
890
|
*/
|
|
940
|
-
public ceil
|
|
941
|
-
|
|
942
|
-
): T {
|
|
943
|
-
return ceil(this, out);
|
|
891
|
+
public ceil(): Vector3 {
|
|
892
|
+
return ceil(this, new Vector3());
|
|
944
893
|
}
|
|
945
894
|
|
|
946
895
|
/**
|
|
947
896
|
* Round down the components of this vector.
|
|
948
|
-
* @param out - The vector to store the result in.
|
|
949
897
|
* @returns The rounded vector.
|
|
950
898
|
*/
|
|
951
|
-
public floor
|
|
952
|
-
|
|
953
|
-
): T {
|
|
954
|
-
return floor(this, out);
|
|
899
|
+
public floor(): Vector3 {
|
|
900
|
+
return floor(this, new Vector3());
|
|
955
901
|
}
|
|
956
902
|
|
|
957
903
|
/**
|
|
958
904
|
* Round the components of this vector.
|
|
959
|
-
* @param out - The vector to store the result in.
|
|
960
905
|
* @returns The rounded vector.
|
|
961
906
|
*/
|
|
962
|
-
public round
|
|
963
|
-
|
|
964
|
-
): T {
|
|
965
|
-
return round(this, out);
|
|
907
|
+
public round(): Vector3 {
|
|
908
|
+
return round(this, new Vector3());
|
|
966
909
|
}
|
|
967
910
|
|
|
968
911
|
/**
|
|
969
912
|
* Return the minimum of this and another vector.
|
|
970
913
|
* @param vector - The other vector.
|
|
971
|
-
* @param out - The vector to store the result in.
|
|
972
914
|
* @returns The minimum.
|
|
973
915
|
*/
|
|
974
|
-
public min
|
|
975
|
-
vector
|
|
976
|
-
out: T = new Vector3() as Vector3 & T
|
|
977
|
-
): T {
|
|
978
|
-
return min(this, vector, out);
|
|
916
|
+
public min(vector: Vector3Like): Vector3 {
|
|
917
|
+
return min(this, vector, new Vector3());
|
|
979
918
|
}
|
|
980
919
|
|
|
981
920
|
/**
|
|
982
921
|
* Return the maximum of this and another vector.
|
|
983
922
|
* @param vector - The other vector.
|
|
984
|
-
* @param out - The vector to store the result in.
|
|
985
923
|
* @returns The maximum.
|
|
986
924
|
*/
|
|
987
|
-
public max
|
|
988
|
-
vector
|
|
989
|
-
out: T = new Vector3() as Vector3 & T
|
|
990
|
-
): T {
|
|
991
|
-
return max(this, vector, out);
|
|
925
|
+
public max(vector: Vector3Like): Vector3 {
|
|
926
|
+
return max(this, vector, new Vector3());
|
|
992
927
|
}
|
|
993
928
|
|
|
994
929
|
/**
|
|
995
930
|
* Raise each component of this vector to the given power.
|
|
996
931
|
* @param scalar - The exponent (power) to raise each component to.
|
|
997
|
-
* @param out - The vector to store the result in.
|
|
998
932
|
* @returns The power (result of the exponentiation).
|
|
999
933
|
*/
|
|
1000
|
-
public pow
|
|
1001
|
-
scalar
|
|
1002
|
-
out: T = new Vector3() as Vector3 & T
|
|
1003
|
-
): T {
|
|
1004
|
-
return pow(this, scalar, out);
|
|
934
|
+
public pow(scalar: number): Vector3 {
|
|
935
|
+
return pow(this, scalar, new Vector3());
|
|
1005
936
|
}
|
|
1006
937
|
|
|
1007
938
|
/**
|
|
1008
939
|
* Scale this vector by a scalar.
|
|
1009
940
|
* @param scalar - The scalar.
|
|
1010
|
-
* @param out - The vector to store the result in.
|
|
1011
941
|
* @returns The scaled vector.
|
|
1012
942
|
*/
|
|
1013
|
-
public scale
|
|
1014
|
-
scalar
|
|
1015
|
-
out: T = new Vector3() as Vector3 & T
|
|
1016
|
-
): T {
|
|
1017
|
-
return scale(this, scalar, out);
|
|
943
|
+
public scale(scalar: number): Vector3 {
|
|
944
|
+
return scale(this, scalar, new Vector3());
|
|
1018
945
|
}
|
|
1019
946
|
|
|
1020
947
|
/**
|
|
1021
948
|
* Add another vector to this one after scaling the other by a scalar.
|
|
1022
949
|
* @param vector - The other vector.
|
|
1023
950
|
* @param scalar - The scalar.
|
|
1024
|
-
* @param out - The vector to store the result in.
|
|
1025
951
|
* @returns The sum.
|
|
1026
952
|
*/
|
|
1027
|
-
public scaleAndAdd
|
|
1028
|
-
vector
|
|
1029
|
-
scalar: number,
|
|
1030
|
-
out: T = new Vector3() as Vector3 & T
|
|
1031
|
-
): T {
|
|
1032
|
-
return scaleAndAdd(this, vector, scalar, out);
|
|
953
|
+
public scaleAndAdd(vector: Vector3Like, scalar: number): Vector3 {
|
|
954
|
+
return scaleAndAdd(this, vector, scalar, new Vector3());
|
|
1033
955
|
}
|
|
1034
956
|
|
|
1035
957
|
/**
|
|
@@ -1052,48 +974,47 @@ export default class Vector3
|
|
|
1052
974
|
return squaredDistance(this, vector);
|
|
1053
975
|
}
|
|
1054
976
|
|
|
1055
|
-
/**
|
|
977
|
+
/** The magnitude (length) of this vector. */
|
|
1056
978
|
public get magnitude(): number {
|
|
1057
979
|
return getMagnitude(this);
|
|
1058
980
|
}
|
|
1059
981
|
|
|
1060
|
-
|
|
982
|
+
public set magnitude(value: number) {
|
|
983
|
+
scale(normalize(this, this), value, this);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/** The squared magnitude (length) of this vector. */
|
|
1061
987
|
public get squaredMagnitude(): number {
|
|
1062
988
|
return getSquaredMagnitude(this);
|
|
1063
989
|
}
|
|
1064
990
|
|
|
991
|
+
public set squaredMagnitude(value: number) {
|
|
992
|
+
this.magnitude = Math.sqrt(value);
|
|
993
|
+
}
|
|
994
|
+
|
|
1065
995
|
/**
|
|
1066
996
|
* Negate this vector.
|
|
1067
|
-
* @param out - The vector to store the result in.
|
|
1068
997
|
* @returns The negated vector.
|
|
1069
998
|
*/
|
|
1070
|
-
public negate
|
|
1071
|
-
|
|
1072
|
-
): T {
|
|
1073
|
-
return negate(this, out);
|
|
999
|
+
public negate(): Vector3 {
|
|
1000
|
+
return negate(this, new Vector3());
|
|
1074
1001
|
}
|
|
1075
1002
|
|
|
1076
1003
|
/**
|
|
1077
1004
|
* Calculate the multiplicative inverse of the components of this vector.
|
|
1078
|
-
* @param out - The vector to store the result in.
|
|
1079
1005
|
* @returns The inverted vector.
|
|
1080
1006
|
*/
|
|
1081
|
-
public invert
|
|
1082
|
-
|
|
1083
|
-
): T {
|
|
1084
|
-
return invert(this, out);
|
|
1007
|
+
public invert(): Vector3 {
|
|
1008
|
+
return invert(this, new Vector3());
|
|
1085
1009
|
}
|
|
1086
1010
|
|
|
1087
1011
|
/**
|
|
1088
1012
|
* Normalize this vector.
|
|
1089
|
-
* @param out - The vector to store the result in.
|
|
1090
1013
|
* @returns The normalized vector.
|
|
1091
1014
|
* @see {@link https://en.wikipedia.org/wiki/Unit_vector | Unit vector}
|
|
1092
1015
|
*/
|
|
1093
|
-
public normalize
|
|
1094
|
-
|
|
1095
|
-
): T {
|
|
1096
|
-
return normalize(this, out);
|
|
1016
|
+
public normalize(): Vector3 {
|
|
1017
|
+
return normalize(this, new Vector3());
|
|
1097
1018
|
}
|
|
1098
1019
|
|
|
1099
1020
|
/**
|
|
@@ -1109,31 +1030,22 @@ export default class Vector3
|
|
|
1109
1030
|
/**
|
|
1110
1031
|
* Calculate the cross product of this and another vector.
|
|
1111
1032
|
* @param vector - The other vector.
|
|
1112
|
-
* @param out - The vector to store the result in.
|
|
1113
1033
|
* @returns The cross product.
|
|
1114
1034
|
* @see {@link https://en.wikipedia.org/wiki/Cross_product | Cross product}
|
|
1115
1035
|
*/
|
|
1116
|
-
public cross
|
|
1117
|
-
vector
|
|
1118
|
-
out: T = new Vector3() as Vector3 & T
|
|
1119
|
-
): T {
|
|
1120
|
-
return cross(this, vector, out);
|
|
1036
|
+
public cross(vector: Vector3Like): Vector3 {
|
|
1037
|
+
return cross(this, vector, new Vector3());
|
|
1121
1038
|
}
|
|
1122
1039
|
|
|
1123
1040
|
/**
|
|
1124
1041
|
* Perform a linear interpolation between this and another vector.
|
|
1125
1042
|
* @param vector - The other vector.
|
|
1126
1043
|
* @param t - The interpolation amount (in `[0,1]`).
|
|
1127
|
-
* @param out - The vector to store the result in.
|
|
1128
1044
|
* @returns The interpolated vector.
|
|
1129
1045
|
* @see {@link https://en.wikipedia.org/wiki/Linear_interpolation | Linear interpolation}
|
|
1130
1046
|
*/
|
|
1131
|
-
public lerp
|
|
1132
|
-
vector
|
|
1133
|
-
t: number,
|
|
1134
|
-
out: T = new Vector3() as Vector3 & T
|
|
1135
|
-
): T {
|
|
1136
|
-
return lerp(this, vector, t, out);
|
|
1047
|
+
public lerp(vector: Vector3Like, t: number): Vector3 {
|
|
1048
|
+
return lerp(this, vector, t, new Vector3());
|
|
1137
1049
|
}
|
|
1138
1050
|
|
|
1139
1051
|
/**
|
|
@@ -1148,72 +1060,49 @@ export default class Vector3
|
|
|
1148
1060
|
/**
|
|
1149
1061
|
* Transform this vector by a three-by-three matrix.
|
|
1150
1062
|
* @param matrix - The matrix.
|
|
1151
|
-
* @param out - The vector to store the result in.
|
|
1152
1063
|
* @returns The transformed vector.
|
|
1153
1064
|
*/
|
|
1154
|
-
public transformMatrix3
|
|
1155
|
-
matrix
|
|
1156
|
-
out: T = new Vector3() as Vector3 & T
|
|
1157
|
-
): T {
|
|
1158
|
-
return transformMatrix3(this, matrix, out);
|
|
1065
|
+
public transformMatrix3(matrix: Matrix3Like): Vector3 {
|
|
1066
|
+
return transformMatrix3(this, matrix, new Vector3());
|
|
1159
1067
|
}
|
|
1160
1068
|
|
|
1161
1069
|
/**
|
|
1162
1070
|
* Transform this vector by a four-by-four matrix.
|
|
1163
1071
|
* @param matrix - The matrix.
|
|
1164
|
-
* @param out - The vector to store the result in.
|
|
1165
1072
|
* @returns The transformed vector.
|
|
1166
1073
|
*/
|
|
1167
|
-
public transformMatrix4
|
|
1168
|
-
matrix
|
|
1169
|
-
out: T = new Vector3() as Vector3 & T
|
|
1170
|
-
): T {
|
|
1171
|
-
return transformMatrix4(this, matrix, out);
|
|
1074
|
+
public transformMatrix4(matrix: Matrix4Like): Vector3 {
|
|
1075
|
+
return transformMatrix4(this, matrix, new Vector3());
|
|
1172
1076
|
}
|
|
1173
1077
|
|
|
1174
1078
|
/**
|
|
1175
1079
|
* Rotate this vector around the X-axis.
|
|
1176
1080
|
* @param origin - The origin of the rotation.
|
|
1177
1081
|
* @param r - The angle of rotation in radians.
|
|
1178
|
-
* @param out - The vector to store the result in.
|
|
1179
1082
|
* @returns The rotated vector.
|
|
1180
1083
|
*/
|
|
1181
|
-
public rotateX
|
|
1182
|
-
origin
|
|
1183
|
-
r: number,
|
|
1184
|
-
out: T = new Vector3() as Vector3 & T
|
|
1185
|
-
): T {
|
|
1186
|
-
return rotateX(this, origin, r, out);
|
|
1084
|
+
public rotateX(origin: Vector3Like, r: number): Vector3 {
|
|
1085
|
+
return rotateX(this, origin, r, new Vector3());
|
|
1187
1086
|
}
|
|
1188
1087
|
|
|
1189
1088
|
/**
|
|
1190
1089
|
* Rotate this vector around the Y-axis.
|
|
1191
1090
|
* @param origin - The origin of the rotation.
|
|
1192
1091
|
* @param r - The angle of rotation in radians.
|
|
1193
|
-
* @param out - The vector to store the result in.
|
|
1194
1092
|
* @returns The rotated vector.
|
|
1195
1093
|
*/
|
|
1196
|
-
public rotateY
|
|
1197
|
-
origin
|
|
1198
|
-
r: number,
|
|
1199
|
-
out: T = new Vector3() as Vector3 & T
|
|
1200
|
-
): T {
|
|
1201
|
-
return rotateY(this, origin, r, out);
|
|
1094
|
+
public rotateY(origin: Vector3Like, r: number): Vector3 {
|
|
1095
|
+
return rotateY(this, origin, r, new Vector3());
|
|
1202
1096
|
}
|
|
1203
1097
|
|
|
1204
1098
|
/**
|
|
1205
1099
|
* Rotate this vector around the Z-axis.
|
|
1206
1100
|
* @param origin - The origin of the rotation.
|
|
1207
1101
|
* @param r - The angle of rotation in radians.
|
|
1208
|
-
* @param out - The vector to store the result in.
|
|
1209
1102
|
* @returns The rotated vector.
|
|
1210
1103
|
*/
|
|
1211
|
-
public rotateZ
|
|
1212
|
-
origin
|
|
1213
|
-
r: number,
|
|
1214
|
-
out: T = new Vector3() as Vector3 & T
|
|
1215
|
-
): T {
|
|
1216
|
-
return rotateZ(this, origin, r, out);
|
|
1104
|
+
public rotateZ(origin: Vector3Like, r: number): Vector3 {
|
|
1105
|
+
return rotateZ(this, origin, r, new Vector3());
|
|
1217
1106
|
}
|
|
1218
1107
|
|
|
1219
1108
|
/**
|
|
@@ -1239,18 +1128,16 @@ export default class Vector3
|
|
|
1239
1128
|
* @param b - The second control point.
|
|
1240
1129
|
* @param end - The other vector.
|
|
1241
1130
|
* @param t - The interpolation amount in the range `[0,1]`.
|
|
1242
|
-
* @param out - The vector to store the result in.
|
|
1243
1131
|
* @returns The interpolated vector.
|
|
1244
1132
|
* @see {@link https://en.wikipedia.org/wiki/Hermite_interpolation | Hermite interpolation}
|
|
1245
1133
|
*/
|
|
1246
|
-
public hermite
|
|
1134
|
+
public hermite(
|
|
1247
1135
|
a: Vector3Like,
|
|
1248
1136
|
b: Vector3Like,
|
|
1249
1137
|
end: Vector3Like,
|
|
1250
|
-
t: number
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
return hermite(this, a, b, end, t, out);
|
|
1138
|
+
t: number
|
|
1139
|
+
): Vector3 {
|
|
1140
|
+
return hermite(this, a, b, end, t, new Vector3());
|
|
1254
1141
|
}
|
|
1255
1142
|
|
|
1256
1143
|
/**
|
|
@@ -1259,31 +1146,25 @@ export default class Vector3
|
|
|
1259
1146
|
* @param b - The second control point.
|
|
1260
1147
|
* @param end - The other vector.
|
|
1261
1148
|
* @param t - The interpolation amount in the range `[0,1]`.
|
|
1262
|
-
* @param out - The vector to store the result in.
|
|
1263
1149
|
* @returns The interpolated vector.
|
|
1264
1150
|
* @see {@link https://en.wikipedia.org/wiki/B%C3%A9zier_curve | Bézier curve}
|
|
1265
1151
|
*/
|
|
1266
|
-
public bezier
|
|
1152
|
+
public bezier(
|
|
1267
1153
|
a: Vector3Like,
|
|
1268
1154
|
b: Vector3Like,
|
|
1269
1155
|
end: Vector3Like,
|
|
1270
|
-
t: number
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
return bezier(this, a, b, end, t, out);
|
|
1156
|
+
t: number
|
|
1157
|
+
): Vector3 {
|
|
1158
|
+
return bezier(this, a, b, end, t, new Vector3());
|
|
1274
1159
|
}
|
|
1275
1160
|
|
|
1276
1161
|
/**
|
|
1277
1162
|
* Transform this vector by a quaternion.
|
|
1278
1163
|
* @param quaternion - The quaternion.
|
|
1279
|
-
* @param out - The vector to store the result in.
|
|
1280
1164
|
* @returns The transformed vector.
|
|
1281
1165
|
* @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
|
|
1282
1166
|
*/
|
|
1283
|
-
public transformQuaternion
|
|
1284
|
-
quaternion
|
|
1285
|
-
out: T = new Vector3() as Vector3 & T
|
|
1286
|
-
): T {
|
|
1287
|
-
return transformQuaternion(this, quaternion, out);
|
|
1167
|
+
public transformQuaternion(quaternion: QuaternionLike): Vector3 {
|
|
1168
|
+
return transformQuaternion(this, quaternion, new Vector3());
|
|
1288
1169
|
}
|
|
1289
1170
|
}
|