@lakuna/umath 1.5.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/LICENSE +1 -1
  2. package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
  3. package/dist/algorithms/greatestCommonDivisor.js +14 -4
  4. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  5. package/dist/index.d.ts +15 -11
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +6 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/linalg/DualQuaternion.d.ts +131 -154
  10. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  11. package/dist/linalg/DualQuaternion.js +188 -203
  12. package/dist/linalg/DualQuaternion.js.map +1 -1
  13. package/dist/linalg/Matrix.d.ts +24 -24
  14. package/dist/linalg/Matrix.d.ts.map +1 -1
  15. package/dist/linalg/Matrix2.d.ts +74 -88
  16. package/dist/linalg/Matrix2.d.ts.map +1 -1
  17. package/dist/linalg/Matrix2.js +114 -124
  18. package/dist/linalg/Matrix2.js.map +1 -1
  19. package/dist/linalg/Matrix3.d.ts +118 -139
  20. package/dist/linalg/Matrix3.d.ts.map +1 -1
  21. package/dist/linalg/Matrix3.js +169 -201
  22. package/dist/linalg/Matrix3.js.map +1 -1
  23. package/dist/linalg/Matrix4.d.ts +217 -257
  24. package/dist/linalg/Matrix4.d.ts.map +1 -1
  25. package/dist/linalg/Matrix4.js +310 -374
  26. package/dist/linalg/Matrix4.js.map +1 -1
  27. package/dist/linalg/Quaternion.d.ts +120 -151
  28. package/dist/linalg/Quaternion.d.ts.map +1 -1
  29. package/dist/linalg/Quaternion.js +187 -204
  30. package/dist/linalg/Quaternion.js.map +1 -1
  31. package/dist/linalg/SlowMatrix.d.ts +5 -5
  32. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  33. package/dist/linalg/SlowMatrix.js +63 -89
  34. package/dist/linalg/SlowMatrix.js.map +1 -1
  35. package/dist/linalg/SlowSquareMatrix.d.ts +6 -6
  36. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  37. package/dist/linalg/SlowSquareMatrix.js +15 -15
  38. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  39. package/dist/linalg/SlowVector.d.ts +165 -0
  40. package/dist/linalg/SlowVector.d.ts.map +1 -0
  41. package/dist/linalg/SlowVector.js +369 -0
  42. package/dist/linalg/SlowVector.js.map +1 -0
  43. package/dist/linalg/SquareMatrix.d.ts +8 -8
  44. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  45. package/dist/linalg/Vector.d.ts +84 -84
  46. package/dist/linalg/Vector.d.ts.map +1 -1
  47. package/dist/linalg/Vector2.d.ts +115 -137
  48. package/dist/linalg/Vector2.d.ts.map +1 -1
  49. package/dist/linalg/Vector2.js +164 -188
  50. package/dist/linalg/Vector2.js.map +1 -1
  51. package/dist/linalg/Vector3.d.ts +141 -167
  52. package/dist/linalg/Vector3.d.ts.map +1 -1
  53. package/dist/linalg/Vector3.js +200 -237
  54. package/dist/linalg/Vector3.js.map +1 -1
  55. package/dist/linalg/Vector4.d.ts +111 -131
  56. package/dist/linalg/Vector4.d.ts.map +1 -1
  57. package/dist/linalg/Vector4.js +163 -187
  58. package/dist/linalg/Vector4.js.map +1 -1
  59. package/dist/types/AxisAngle.d.ts +2 -2
  60. package/dist/types/AxisAngle.d.ts.map +1 -1
  61. package/dist/types/FieldOfView.d.ts +2 -2
  62. package/dist/types/FieldOfView.d.ts.map +1 -1
  63. package/dist/utility/BigNumber.d.ts +21 -11
  64. package/dist/utility/BigNumber.d.ts.map +1 -1
  65. package/dist/utility/BigNumber.js +42 -31
  66. package/dist/utility/BigNumber.js.map +1 -1
  67. package/dist/utility/MatrixSizeError.d.ts +1 -1
  68. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  69. package/dist/utility/MatrixSizeError.js +1 -1
  70. package/dist/utility/MatrixSizeError.js.map +1 -1
  71. package/dist/utility/VectorSizeError.d.ts +12 -0
  72. package/dist/utility/VectorSizeError.d.ts.map +1 -0
  73. package/dist/utility/VectorSizeError.js +15 -0
  74. package/dist/utility/VectorSizeError.js.map +1 -0
  75. package/dist/utility/createAxisAngleLike.d.ts +10 -0
  76. package/dist/utility/createAxisAngleLike.d.ts.map +1 -0
  77. package/dist/utility/createAxisAngleLike.js +10 -0
  78. package/dist/utility/createAxisAngleLike.js.map +1 -0
  79. package/package.json +11 -11
  80. package/src/algorithms/greatestCommonDivisor.ts +19 -7
  81. package/src/index.ts +24 -13
  82. package/src/linalg/DualQuaternion.ts +224 -292
  83. package/src/linalg/Matrix.ts +28 -28
  84. package/src/linalg/Matrix2.ts +138 -180
  85. package/src/linalg/Matrix3.ts +211 -286
  86. package/src/linalg/Matrix4.ts +466 -584
  87. package/src/linalg/Quaternion.ts +221 -294
  88. package/src/linalg/SlowMatrix.ts +97 -95
  89. package/src/linalg/SlowSquareMatrix.ts +19 -18
  90. package/src/linalg/SlowVector.ts +450 -0
  91. package/src/linalg/SquareMatrix.ts +9 -9
  92. package/src/linalg/Vector.ts +90 -90
  93. package/src/linalg/Vector2.ts +181 -266
  94. package/src/linalg/Vector3.ts +230 -342
  95. package/src/linalg/Vector4.ts +183 -257
  96. package/src/types/AxisAngle.ts +3 -3
  97. package/src/types/FieldOfView.ts +3 -3
  98. package/src/utility/BigNumber.ts +63 -41
  99. package/src/utility/MatrixSizeError.ts +1 -1
  100. package/src/utility/VectorSizeError.ts +14 -0
  101. package/src/utility/createAxisAngleLike.ts +14 -0
@@ -1,6 +1,8 @@
1
+ import approxRelative from "../algorithms/approxRelative.js";
2
+ import epsilon from "../utility/epsilon.js";
1
3
  import {
2
- type Matrix4Like,
3
- getScaling as matrix4GetScaling
4
+ getScaling as matrix4GetScaling,
5
+ type Matrix4Like
4
6
  } from "./Matrix4.js";
5
7
  import Quaternion, {
6
8
  type QuaternionLike,
@@ -9,9 +11,9 @@ import Quaternion, {
9
11
  rotateZ as quaternionRotateZ
10
12
  } from "./Quaternion.js";
11
13
  import Vector3, {
12
- type Vector3Like,
13
14
  createVector3Like,
14
- fromValues as vector3FromValues
15
+ fromValues as vector3FromValues,
16
+ type Vector3Like
15
17
  } from "./Vector3.js";
16
18
  import {
17
19
  copy as vector4Copy,
@@ -20,8 +22,6 @@ import {
20
22
  getMagnitude as vector4GetMagnitude,
21
23
  getSquaredMagnitude as vector4GetSquaredMagnitude
22
24
  } from "./Vector4.js";
23
- import approxRelative from "../algorithms/approxRelative.js";
24
- import epsilon from "../utility/epsilon.js";
25
25
 
26
26
  /**
27
27
  * A complex number that is commonly used to describe transformations.
@@ -29,27 +29,35 @@ import epsilon from "../utility/epsilon.js";
29
29
  */
30
30
  export interface DualQuaternionLike extends Record<number, number> {
31
31
  /** The first real component of this dual quaternion. */
32
+ // eslint-disable-next-line @typescript-eslint/naming-convention
32
33
  0: number;
33
34
 
34
35
  /** The second real component of this dual quaternion. */
36
+ // eslint-disable-next-line @typescript-eslint/naming-convention
35
37
  1: number;
36
38
 
37
39
  /** The third real component of this dual quaternion. */
40
+ // eslint-disable-next-line @typescript-eslint/naming-convention
38
41
  2: number;
39
42
 
40
43
  /** The fourth real component of this dual quaternion. */
44
+ // eslint-disable-next-line @typescript-eslint/naming-convention
41
45
  3: number;
42
46
 
43
47
  /** The first dual component of this dual quaternion. */
48
+ // eslint-disable-next-line @typescript-eslint/naming-convention
44
49
  4: number;
45
50
 
46
51
  /** The second dual component of this dual quaternion. */
52
+ // eslint-disable-next-line @typescript-eslint/naming-convention
47
53
  5: number;
48
54
 
49
55
  /** The third dual component of this dual quaternion. */
56
+ // eslint-disable-next-line @typescript-eslint/naming-convention
50
57
  6: number;
51
58
 
52
59
  /** The fourth dual component of this dual quaternion. */
60
+ // eslint-disable-next-line @typescript-eslint/naming-convention
53
61
  7: number;
54
62
  }
55
63
 
@@ -58,10 +66,9 @@ export interface DualQuaternionLike extends Record<number, number> {
58
66
  * @returns A dual quaternion-like object.
59
67
  * @public
60
68
  */
61
- export const createDualQuaternionLike = (): Float32Array &
62
- DualQuaternionLike => {
63
- return new Float32Array(8) as Float32Array & DualQuaternionLike;
64
- };
69
+ export const createDualQuaternionLike = (): DualQuaternionLike & Float32Array =>
70
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
71
+ new Float32Array(8) as DualQuaternionLike & Float32Array;
65
72
 
66
73
  /**
67
74
  * Create a dual quaternion with the given values.
@@ -235,13 +242,13 @@ export const fromMatrix4 = <T extends DualQuaternionLike>(
235
242
 
236
243
  const trace = sm11 + sm22 + sm33;
237
244
 
238
- // eslint-disable-next-line init-declarations
245
+ // eslint-disable-next-line @typescript-eslint/init-declarations
239
246
  let x;
240
- // eslint-disable-next-line init-declarations
247
+ // eslint-disable-next-line @typescript-eslint/init-declarations
241
248
  let y;
242
- // eslint-disable-next-line init-declarations
249
+ // eslint-disable-next-line @typescript-eslint/init-declarations
243
250
  let z;
244
- // eslint-disable-next-line init-declarations
251
+ // eslint-disable-next-line @typescript-eslint/init-declarations
245
252
  let w;
246
253
  if (trace > 0) {
247
254
  const s = Math.sqrt(trace + 1) * 2;
@@ -653,7 +660,7 @@ export const rotateAroundAxis = <T extends DualQuaternionLike>(
653
660
  const ax = axis[0];
654
661
  const ay = axis[1];
655
662
  const az = axis[2];
656
- const axisLength = Math.sqrt(ax * ax + ay * ay + az * az); // `Math.hypot` is slower.
663
+ const axisLength = Math.hypot(ax, ay, az);
657
664
 
658
665
  const r = radians / 2;
659
666
 
@@ -1007,121 +1014,146 @@ export default class DualQuaternion
1007
1014
  extends Float32Array
1008
1015
  implements DualQuaternionLike
1009
1016
  {
1017
+ /** The first real component of this dual quaternion. */
1018
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1019
+ public 0: number;
1020
+
1021
+ /** The second real component of this dual quaternion. */
1022
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1023
+ public 1: number;
1024
+
1025
+ /** The third real component of this dual quaternion. */
1026
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1027
+ public 2: number;
1028
+
1029
+ /** The fourth real component of this dual quaternion. */
1030
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1031
+ public 3: number;
1032
+
1033
+ /** The first dual component of this dual quaternion. */
1034
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1035
+ public 4: number;
1036
+
1037
+ /** The second dual component of this dual quaternion. */
1038
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1039
+ public 5: number;
1040
+
1041
+ /** The third dual component of this dual quaternion. */
1042
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1043
+ public 6: number;
1044
+
1045
+ /** The fourth dual component of this dual quaternion. */
1046
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1047
+ public 7: number;
1048
+
1049
+ /** Get the magnitude (length) of this dual quaternion. */
1050
+ public get magnitude(): number {
1051
+ return getMagnitude(this);
1052
+ }
1053
+
1054
+ /** Get the squared magnitude (length) of this dual quaternion. */
1055
+ public get squaredMagnitude(): number {
1056
+ return getSquaredMagnitude(this);
1057
+ }
1058
+
1010
1059
  /**
1011
- * Create a dual quaternion with the given values.
1012
- * @param x1 - The first real component.
1013
- * @param y1 - The second real component.
1014
- * @param z1 - The third real component.
1015
- * @param w1 - The fourth real component.
1016
- * @param x2 - The first dual component.
1017
- * @param y2 - The second dual component.
1018
- * @param z2 - The third dual component.
1019
- * @param w2 - The fourth dual component.
1020
- * @param out - The dual quaternion to store the result in.
1021
- * @returns A new dual quaternion.
1060
+ * Create an identity dual quaternion.
1061
+ * @see {@link https://en.wikipedia.org/wiki/Dual_quaternion | Dual quaternion}
1022
1062
  */
1023
- public static fromValues<T extends DualQuaternionLike = DualQuaternion>(
1024
- x1: number,
1025
- y1: number,
1026
- z1: number,
1027
- w1: number,
1028
- x2: number,
1029
- y2: number,
1030
- z2: number,
1031
- w2: number,
1032
- out: T = new DualQuaternion() as DualQuaternion & T
1033
- ): T {
1034
- return fromValues(x1, y1, z1, w1, x2, y2, z2, w2, out);
1063
+ public constructor() {
1064
+ super(8);
1065
+ this[3] = 1;
1035
1066
  }
1036
1067
 
1037
1068
  /**
1038
- * Create a dual quaternion from the given rotation and translation.
1039
- * @param q - The rotation quaternion.
1040
- * @param t - The translation vector.
1041
- * @param out - The dual quaternion to store the result in.
1069
+ * Create a dual quaternion from the given four-by-four matrix.
1070
+ * @param matrix - The matrix.
1042
1071
  * @returns The dual quaternion.
1043
1072
  */
1044
- public static fromRotationTranslation<
1045
- T extends DualQuaternionLike = DualQuaternion
1046
- >(
1047
- q: QuaternionLike,
1048
- t: Vector3Like,
1049
- out: T = new DualQuaternion() as DualQuaternion & T
1050
- ): T {
1051
- return fromRotationTranslation(q, t, out);
1073
+ public static fromMatrix4(matrix: Matrix4Like): DualQuaternion {
1074
+ return fromMatrix4(matrix, new DualQuaternion());
1052
1075
  }
1053
1076
 
1054
1077
  /**
1055
- * Create a dual quaternion from the given translation.
1056
- * @param t - The translation vector.
1057
- * @param out - The dual quaternion to store the result in.
1078
+ * Create a dual quaternion from the given rotation.
1079
+ * @param q - The rotation quaternion.
1058
1080
  * @returns The dual quaternion.
1059
1081
  */
1060
- public static fromTranslation<T extends DualQuaternionLike = DualQuaternion>(
1061
- t: Vector3Like,
1062
- out: T = new DualQuaternion() as DualQuaternion & T
1063
- ): T {
1064
- return fromTranslation(t, out);
1082
+ public static fromRotation(q: QuaternionLike): DualQuaternion {
1083
+ return fromRotation(q, new DualQuaternion());
1065
1084
  }
1066
1085
 
1067
1086
  /**
1068
- * Create a dual quaternion from the given rotation.
1087
+ * Create a dual quaternion from the given rotation and translation.
1069
1088
  * @param q - The rotation quaternion.
1070
- * @param out - The dual quaternion to store the result in.
1089
+ * @param t - The translation vector.
1071
1090
  * @returns The dual quaternion.
1072
1091
  */
1073
- public static fromRotation<T extends DualQuaternionLike = DualQuaternion>(
1092
+ public static fromRotationTranslation(
1074
1093
  q: QuaternionLike,
1075
- out: T = new DualQuaternion() as DualQuaternion & T
1076
- ): T {
1077
- return fromRotation(q, out);
1094
+ t: Vector3Like
1095
+ ): DualQuaternion {
1096
+ return fromRotationTranslation(q, t, new DualQuaternion());
1078
1097
  }
1079
1098
 
1080
1099
  /**
1081
- * Create a dual quaternion from the given four-by-four matrix.
1082
- * @param matrix - The matrix.
1083
- * @param out - The dual quaternion to store the result in.
1100
+ * Create a dual quaternion from the given translation.
1101
+ * @param t - The translation vector.
1084
1102
  * @returns The dual quaternion.
1085
1103
  */
1086
- public static fromMatrix4<T extends DualQuaternionLike = DualQuaternion>(
1087
- matrix: Matrix4Like,
1088
- out: T = new DualQuaternion() as DualQuaternion & T
1089
- ): T {
1090
- return fromMatrix4(matrix, out);
1104
+ public static fromTranslation(t: Vector3Like): DualQuaternion {
1105
+ return fromTranslation(t, new DualQuaternion());
1091
1106
  }
1092
1107
 
1093
1108
  /**
1094
- * Create an identity dual quaternion.
1095
- * @see {@link https://en.wikipedia.org/wiki/Dual_quaternion | Dual quaternion}
1109
+ * Create a dual quaternion with the given values.
1110
+ * @param x1 - The first real component.
1111
+ * @param y1 - The second real component.
1112
+ * @param z1 - The third real component.
1113
+ * @param w1 - The fourth real component.
1114
+ * @param x2 - The first dual component.
1115
+ * @param y2 - The second dual component.
1116
+ * @param z2 - The third dual component.
1117
+ * @param w2 - The fourth dual component.
1118
+ * @returns A new dual quaternion.
1096
1119
  */
1097
- public constructor() {
1098
- super(8);
1099
- this[3] = 1;
1120
+ public static fromValues(
1121
+ x1: number,
1122
+ y1: number,
1123
+ z1: number,
1124
+ w1: number,
1125
+ x2: number,
1126
+ y2: number,
1127
+ z2: number,
1128
+ w2: number
1129
+ ): DualQuaternion {
1130
+ return fromValues(x1, y1, z1, w1, x2, y2, z2, w2, new DualQuaternion());
1100
1131
  }
1101
1132
 
1102
- /** The first real component of this dual quaternion. */
1103
- public 0: number;
1104
-
1105
- /** The second real component of this dual quaternion. */
1106
- public 1: number;
1107
-
1108
- /** The third real component of this dual quaternion. */
1109
- public 2: number;
1110
-
1111
- /** The fourth real component of this dual quaternion. */
1112
- public 3: number;
1113
-
1114
- /** The first dual component of this dual quaternion. */
1115
- public 4: number;
1116
-
1117
- /** The second dual component of this dual quaternion. */
1118
- public 5: number;
1133
+ /**
1134
+ * Add another dual quaternion to this one.
1135
+ * @param dq - The other dual quaternion.
1136
+ * @returns The sum.
1137
+ */
1138
+ public add(dq: DualQuaternionLike): DualQuaternion {
1139
+ return add(this, dq, new DualQuaternion());
1140
+ }
1119
1141
 
1120
- /** The third dual component of this dual quaternion. */
1121
- public 6: number;
1142
+ /**
1143
+ * Copy the values from this dual quaternion to another one.
1144
+ * @returns The copy.
1145
+ */
1146
+ public clone(): DualQuaternion {
1147
+ return copy(this, new DualQuaternion());
1148
+ }
1122
1149
 
1123
- /** The fourth dual component of this dual quaternion. */
1124
- public 7: number;
1150
+ /**
1151
+ * Calculate the conjugate of this dual quaternion. If this dual quaternion is normalized, this is equivalent to its inverse and faster to calculate.
1152
+ * @returns The conjugate.
1153
+ */
1154
+ public conjugate(): DualQuaternion {
1155
+ return conjugate(this, new DualQuaternion());
1156
+ }
1125
1157
 
1126
1158
  /**
1127
1159
  * Copy the values from another dual quaternion to this one.
@@ -1133,288 +1165,188 @@ export default class DualQuaternion
1133
1165
  }
1134
1166
 
1135
1167
  /**
1136
- * Copy the values from this dual quaternion to another one.
1137
- * @param out - The dual quaternion to store the result in.
1138
- * @returns The copy.
1139
- */
1140
- public clone<T extends DualQuaternionLike = DualQuaternion>(
1141
- out: T = new DualQuaternion() as DualQuaternion & T
1142
- ): T {
1143
- return copy(this, out);
1144
- }
1145
-
1146
- /**
1147
- * Set this dual quaternion to the identity dual quaternion.
1148
- * @returns The identity dual quaternion.
1168
+ * Calculate the dot product of this and another dual quaternion.
1169
+ * @param dq - The other dual quaternion.
1170
+ * @returns The dot product.
1171
+ * @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
1149
1172
  */
1150
- public identity(): this {
1151
- return identity(this);
1173
+ public dot(dq: DualQuaternionLike): number {
1174
+ return dot(this, dq);
1152
1175
  }
1153
1176
 
1154
1177
  /**
1155
- * Get the real part of this dual quaternion.
1156
- * @param out - The quaternion to store the result in.
1157
- * @returns The real part.
1178
+ * Determine whether or not this dual quaternion is roughly equivalent to another.
1179
+ * @param dq - The other dual quaternion.
1180
+ * @returns Whether or not the dual quaternions are equivalent.
1158
1181
  */
1159
- public getReal<T extends QuaternionLike = Quaternion>(
1160
- out: T = new Quaternion() as Quaternion & T
1161
- ): T {
1162
- return getReal(this, out);
1182
+ public equals(dq: DualQuaternionLike): boolean {
1183
+ return equals(this, dq);
1163
1184
  }
1164
1185
 
1165
1186
  /**
1166
- * Set the real part of this dual quaternion.
1167
- * @param q - The quaternion.
1187
+ * Determine whether or not this dual quaternion is exactly equivalent to another.
1188
+ * @param dq - The other dual quaternion.
1189
+ * @returns Whether or not the dual quaternions are equivalent.
1168
1190
  */
1169
- public setReal(q: QuaternionLike): void {
1170
- setReal(q, this);
1191
+ public exactEquals(dq: DualQuaternionLike): boolean {
1192
+ return exactEquals(this, dq);
1171
1193
  }
1172
1194
 
1173
1195
  /**
1174
1196
  * Get the dual part of this dual quaternion.
1175
- * @param out - The quaternion to store the result in.
1176
1197
  * @returns The dual part.
1177
1198
  */
1178
- public getDual<T extends QuaternionLike = Quaternion>(
1179
- out: T = new Quaternion() as Quaternion & T
1180
- ): T {
1181
- return getDual(this, out);
1199
+ public getDual(): Quaternion {
1200
+ return getDual(this, new Quaternion());
1182
1201
  }
1183
1202
 
1184
1203
  /**
1185
- * Set the real part of this dual quaternion.
1186
- * @param q - The quaternion.
1204
+ * Get the real part of this dual quaternion.
1205
+ * @returns The real part.
1187
1206
  */
1188
- public setDual(q: QuaternionLike): void {
1189
- setDual(q, this);
1207
+ public getReal(): Quaternion {
1208
+ return getReal(this, new Quaternion());
1190
1209
  }
1191
1210
 
1192
1211
  /**
1193
1212
  * Get the translation of this normalized dual quaternion.
1194
- * @param out - The vector to store the result in.
1195
1213
  * @returns The translation.
1196
1214
  */
1197
- public getTranslation<T extends Vector3Like = Vector3>(
1198
- out: T = new Vector3() as Vector3 & T
1199
- ): T {
1200
- return getTranslation(this, out);
1215
+ public getTranslation(): Vector3 {
1216
+ return getTranslation(this, new Vector3());
1201
1217
  }
1202
1218
 
1203
1219
  /**
1204
- * Translate this dual quaternion by the given vector.
1205
- * @param v - The vector.
1206
- * @param out - The dual quaternion to store the result in.
1207
- * @returns The translated dual quaternion.
1208
- */
1209
- public translate<T extends DualQuaternionLike = DualQuaternion>(
1210
- v: Vector3Like,
1211
- out: T = new DualQuaternion() as DualQuaternion & T
1212
- ): T {
1213
- return translate(this, v, out);
1214
- }
1215
-
1216
- /**
1217
- * Rotate this dual quaternion around the X-axis.
1218
- * @param r - The angle to rotate by in radians.
1219
- * @param out - The dual quaternion to store the result in.
1220
- * @returns The rotated dual quaternion.
1220
+ * Set this dual quaternion to the identity dual quaternion.
1221
+ * @returns The identity dual quaternion.
1221
1222
  */
1222
- public rotateX<T extends DualQuaternionLike = DualQuaternion>(
1223
- r: number,
1224
- out: T = new DualQuaternion() as DualQuaternion & T
1225
- ): T {
1226
- return rotateX(this, r, out);
1223
+ public identity(): this {
1224
+ return identity(this);
1227
1225
  }
1228
1226
 
1229
1227
  /**
1230
- * Rotate this dual quaternion around the Y-axis.
1231
- * @param r - The angle to rotate by in radians.
1232
- * @param out - The dual quaternion to store the result in.
1233
- * @returns The rotated dual quaternion.
1228
+ * Calculate the inverse of this dual quaternion. If this dual quaternion is normalized, the conjugate is equivalent and faster to calculate.
1229
+ * @returns The inverse.
1234
1230
  */
1235
- public rotateY<T extends DualQuaternionLike = DualQuaternion>(
1236
- r: number,
1237
- out: T = new DualQuaternion() as DualQuaternion & T
1238
- ): T {
1239
- return rotateY(this, r, out);
1231
+ public invert(): DualQuaternion {
1232
+ return invert(this, new DualQuaternion());
1240
1233
  }
1241
1234
 
1242
1235
  /**
1243
- * Rotate this dual quaternion around the Z-axis.
1244
- * @param r - The angle to rotate by in radians.
1245
- * @param out - The dual quaternion to store the result in.
1246
- * @returns The rotated dual quaternion.
1236
+ * Perform a linear interpolation between this and another dual quaternion.
1237
+ * @param dq - The other dual quaternion.
1238
+ * @param t - The interpolation amount in `[0,1]`.
1239
+ * @returns The interpolated value.
1247
1240
  */
1248
- public rotateZ<T extends DualQuaternionLike = DualQuaternion>(
1249
- r: number,
1250
- out: T = new DualQuaternion() as DualQuaternion & T
1251
- ): T {
1252
- return rotateZ(this, r, out);
1241
+ public lerp(dq: DualQuaternionLike, t: number): DualQuaternion {
1242
+ return lerp(this, dq, t, new DualQuaternion());
1253
1243
  }
1254
1244
 
1255
1245
  /**
1256
- * Rotate this dual quaternion by a quaternion (using the quaternion as the multiplicand).
1257
- * @param q - The quaternion.
1258
- * @param out - The dual quaternion to store the result in.
1259
- * @returns The rotated dual quaternion.
1260
- * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
1246
+ * Multiply this dual quaternion by another one.
1247
+ * @param dq - The other dual quaternion.
1248
+ * @returns The product.
1261
1249
  */
1262
- public rotateByQuaternionAppend<
1263
- T extends DualQuaternionLike = DualQuaternion
1264
- >(q: QuaternionLike, out: T = new DualQuaternion() as DualQuaternion & T): T {
1265
- return rotateByQuaternionAppend(this, q, out);
1250
+ public multiply(dq: DualQuaternionLike): DualQuaternion {
1251
+ return multiply(this, dq, new DualQuaternion());
1266
1252
  }
1267
1253
 
1268
1254
  /**
1269
- * Rotate this dual quaternion by a quaternion (using the quaternion as the multiplier).
1270
- * @param q - The quaternion.
1271
- * @param out - The dual quaternion to store the result in.
1272
- * @returns The rotated dual quaternion.
1273
- * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
1255
+ * Normalize this dual quaternion.
1256
+ * @returns The normalized dual quaternion.
1274
1257
  */
1275
- public rotateByQuaternionPrepend<
1276
- T extends DualQuaternionLike = DualQuaternion
1277
- >(q: QuaternionLike, out: T = new DualQuaternion() as DualQuaternion & T): T {
1278
- return rotateByQuaternionPrepend(q, this, out);
1258
+ public normalize(): DualQuaternion {
1259
+ return normalize(this, new DualQuaternion());
1279
1260
  }
1280
1261
 
1281
1262
  /**
1282
1263
  * Rotate this dual quaternion around an axis.
1283
1264
  * @param axis - The axis.
1284
1265
  * @param r - The angle of the rotation in radians.
1285
- * @param out - The dual quaternion to store the result in.
1286
1266
  * @returns A normalized dual quaternion.
1287
1267
  */
1288
- public rotateAroundAxis<T extends DualQuaternionLike = DualQuaternion>(
1289
- axis: Vector3Like,
1290
- r: number,
1291
- out: T = new DualQuaternion() as DualQuaternion & T
1292
- ): T {
1293
- return rotateAroundAxis(this, axis, r, out);
1294
- }
1295
-
1296
- /**
1297
- * Add another dual quaternion to this one.
1298
- * @param dq - The other dual quaternion.
1299
- * @param out - The dual quaternion to store the result in.
1300
- * @returns The sum.
1301
- */
1302
- public add<T extends DualQuaternionLike = DualQuaternion>(
1303
- dq: DualQuaternionLike,
1304
- out: T = new DualQuaternion() as DualQuaternion & T
1305
- ): T {
1306
- return add(this, dq, out);
1268
+ public rotateAroundAxis(axis: Vector3Like, r: number): DualQuaternion {
1269
+ return rotateAroundAxis(this, axis, r, new DualQuaternion());
1307
1270
  }
1308
1271
 
1309
1272
  /**
1310
- * Multiply this dual quaternion by another one.
1311
- * @param dq - The other dual quaternion.
1312
- * @param out - The dual quaternion to store the result in.
1313
- * @returns The product.
1273
+ * Rotate this dual quaternion by a quaternion (using the quaternion as the multiplicand).
1274
+ * @param q - The quaternion.
1275
+ * @returns The rotated dual quaternion.
1276
+ * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
1314
1277
  */
1315
- public multiply<T extends DualQuaternionLike = DualQuaternion>(
1316
- dq: DualQuaternionLike,
1317
- out: T = new DualQuaternion() as DualQuaternion & T
1318
- ): T {
1319
- return multiply(this, dq, out);
1278
+ public rotateByQuaternionAppend(q: QuaternionLike): DualQuaternion {
1279
+ return rotateByQuaternionAppend(this, q, new DualQuaternion());
1320
1280
  }
1321
1281
 
1322
1282
  /**
1323
- * Multiply this dual quaternion by a scalar.
1324
- * @param s - The scalar.
1325
- * @param out - The dual quaternion to store the result in.
1326
- * @returns The product.
1283
+ * Rotate this dual quaternion by a quaternion (using the quaternion as the multiplier).
1284
+ * @param q - The quaternion.
1285
+ * @returns The rotated dual quaternion.
1286
+ * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
1327
1287
  */
1328
- public scale<T extends DualQuaternionLike = DualQuaternion>(
1329
- s: number,
1330
- out: T = new DualQuaternion() as DualQuaternion & T
1331
- ): T {
1332
- return scale(this, s, out);
1288
+ public rotateByQuaternionPrepend(q: QuaternionLike): DualQuaternion {
1289
+ return rotateByQuaternionPrepend(q, this, new DualQuaternion());
1333
1290
  }
1334
1291
 
1335
1292
  /**
1336
- * Calculate the dot product of this and another dual quaternion.
1337
- * @param dq - The other dual quaternion.
1338
- * @returns The dot product.
1339
- * @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
1293
+ * Rotate this dual quaternion around the X-axis.
1294
+ * @param r - The angle to rotate by in radians.
1295
+ * @returns The rotated dual quaternion.
1340
1296
  */
1341
- public dot(dq: DualQuaternionLike): number {
1342
- return dot(this, dq);
1297
+ public rotateX(r: number): DualQuaternion {
1298
+ return rotateX(this, r, new DualQuaternion());
1343
1299
  }
1344
1300
 
1345
1301
  /**
1346
- * Perform a linear interpolation between this and another dual quaternion.
1347
- * @param dq - The other dual quaternion.
1348
- * @param t - The interpolation amount in `[0,1]`.
1349
- * @param out - The dual quaternion to store the result in.
1350
- * @returns The interpolated value.
1302
+ * Rotate this dual quaternion around the Y-axis.
1303
+ * @param r - The angle to rotate by in radians.
1304
+ * @returns The rotated dual quaternion.
1351
1305
  */
1352
- public lerp<T extends DualQuaternionLike = DualQuaternion>(
1353
- dq: DualQuaternionLike,
1354
- t: number,
1355
- out: T = new DualQuaternion() as DualQuaternion & T
1356
- ): T {
1357
- return lerp(this, dq, t, out);
1306
+ public rotateY(r: number): DualQuaternion {
1307
+ return rotateY(this, r, new DualQuaternion());
1358
1308
  }
1359
1309
 
1360
1310
  /**
1361
- * Calculate the inverse of this dual quaternion. If this dual quaternion is normalized, the conjugate is equivalent and faster to calculate.
1362
- * @param out - The dual quaternion to store the result in.
1363
- * @returns The inverse.
1311
+ * Rotate this dual quaternion around the Z-axis.
1312
+ * @param r - The angle to rotate by in radians.
1313
+ * @returns The rotated dual quaternion.
1364
1314
  */
1365
- public invert<T extends DualQuaternionLike = DualQuaternion>(
1366
- out: T = new DualQuaternion() as DualQuaternion & T
1367
- ): T {
1368
- return invert(this, out);
1315
+ public rotateZ(r: number): DualQuaternion {
1316
+ return rotateZ(this, r, new DualQuaternion());
1369
1317
  }
1370
1318
 
1371
1319
  /**
1372
- * Calculate the conjugate of this dual quaternion. If this dual quaternion is normalized, this is equivalent to its inverse and faster to calculate.
1373
- * @param out - The dual quaternion to store the result in.
1374
- * @returns The conjugate.
1320
+ * Multiply this dual quaternion by a scalar.
1321
+ * @param s - The scalar.
1322
+ * @returns The product.
1375
1323
  */
1376
- public conjugate<T extends DualQuaternionLike = DualQuaternion>(
1377
- out: T = new DualQuaternion() as DualQuaternion & T
1378
- ): T {
1379
- return conjugate(this, out);
1380
- }
1381
-
1382
- /** Get the magnitude (length) of this dual quaternion. */
1383
- public get magnitude(): number {
1384
- return getMagnitude(this);
1385
- }
1386
-
1387
- /** Get the squared magnitude (length) of this dual quaternion. */
1388
- public get squaredMagnitude(): number {
1389
- return getSquaredMagnitude(this);
1324
+ public scale(s: number): DualQuaternion {
1325
+ return scale(this, s, new DualQuaternion());
1390
1326
  }
1391
1327
 
1392
1328
  /**
1393
- * Normalize this dual quaternion.
1394
- * @param out - The dual quaternion to store the result in.
1395
- * @returns The normalized dual quaternion.
1329
+ * Set the real part of this dual quaternion.
1330
+ * @param q - The quaternion.
1396
1331
  */
1397
- public normalize<T extends DualQuaternionLike = DualQuaternion>(
1398
- out: T = new DualQuaternion() as DualQuaternion & T
1399
- ): T {
1400
- return normalize(this, out);
1332
+ public setDual(q: QuaternionLike): void {
1333
+ setDual(q, this);
1401
1334
  }
1402
1335
 
1403
1336
  /**
1404
- * Determine whether or not this dual quaternion is exactly equivalent to another.
1405
- * @param dq - The other dual quaternion.
1406
- * @returns Whether or not the dual quaternions are equivalent.
1337
+ * Set the real part of this dual quaternion.
1338
+ * @param q - The quaternion.
1407
1339
  */
1408
- public exactEquals(dq: DualQuaternionLike): boolean {
1409
- return exactEquals(this, dq);
1340
+ public setReal(q: QuaternionLike): void {
1341
+ setReal(q, this);
1410
1342
  }
1411
1343
 
1412
1344
  /**
1413
- * Determine whether or not this dual quaternion is roughly equivalent to another.
1414
- * @param dq - The other dual quaternion.
1415
- * @returns Whether or not the dual quaternions are equivalent.
1345
+ * Translate this dual quaternion by the given vector.
1346
+ * @param v - The vector.
1347
+ * @returns The translated dual quaternion.
1416
1348
  */
1417
- public equals(dq: DualQuaternionLike): boolean {
1418
- return equals(this, dq);
1349
+ public translate(v: Vector3Like): DualQuaternion {
1350
+ return translate(this, v, new DualQuaternion());
1419
1351
  }
1420
1352
  }