@lakuna/umath 1.3.3 → 1.3.5

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 (133) hide show
  1. package/README.md +7 -9
  2. package/dist/algorithms/combinations.d.ts.map +1 -1
  3. package/dist/algorithms/combinations.js +1 -1
  4. package/dist/algorithms/combinations.js.map +1 -1
  5. package/dist/algorithms/degreesToRadians.d.ts.map +1 -1
  6. package/dist/algorithms/factorial.d.ts.map +1 -1
  7. package/dist/algorithms/factorial.js +8 -5
  8. package/dist/algorithms/factorial.js.map +1 -1
  9. package/dist/algorithms/fibonacci.d.ts +1 -1
  10. package/dist/algorithms/fibonacci.d.ts.map +1 -1
  11. package/dist/algorithms/fibonacci.js +1 -1
  12. package/dist/algorithms/fibonacci.js.map +1 -1
  13. package/dist/algorithms/greatestCommonDivisor.js +5 -9
  14. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  15. package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
  16. package/dist/algorithms/hypergeometricPmf.js +1 -1
  17. package/dist/algorithms/hypergeometricPmf.js.map +1 -1
  18. package/dist/algorithms/isPrime.d.ts.map +1 -1
  19. package/dist/algorithms/isPrime.js +1 -1
  20. package/dist/algorithms/isPrime.js.map +1 -1
  21. package/dist/algorithms/permutations.d.ts.map +1 -1
  22. package/dist/algorithms/permutations.js +1 -1
  23. package/dist/algorithms/permutations.js.map +1 -1
  24. package/dist/algorithms/primeFactorization.d.ts +1 -1
  25. package/dist/algorithms/primeFactorization.d.ts.map +1 -1
  26. package/dist/algorithms/primeFactorization.js +4 -3
  27. package/dist/algorithms/primeFactorization.js.map +1 -1
  28. package/dist/algorithms/radiansToDegrees.d.ts.map +1 -1
  29. package/dist/algorithms/summation.d.ts.map +1 -1
  30. package/dist/algorithms/summation.js.map +1 -1
  31. package/dist/index.d.ts +32 -33
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +27 -27
  34. package/dist/index.js.map +1 -1
  35. package/dist/linalg/DualQuaternion.d.ts +50 -56
  36. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  37. package/dist/linalg/DualQuaternion.js +67 -61
  38. package/dist/linalg/DualQuaternion.js.map +1 -1
  39. package/dist/linalg/Matrix.d.ts +13 -12
  40. package/dist/linalg/Matrix.d.ts.map +1 -1
  41. package/dist/linalg/Matrix2.d.ts +30 -34
  42. package/dist/linalg/Matrix2.d.ts.map +1 -1
  43. package/dist/linalg/Matrix2.js +26 -23
  44. package/dist/linalg/Matrix2.js.map +1 -1
  45. package/dist/linalg/Matrix3.d.ts +47 -47
  46. package/dist/linalg/Matrix3.d.ts.map +1 -1
  47. package/dist/linalg/Matrix3.js +52 -43
  48. package/dist/linalg/Matrix3.js.map +1 -1
  49. package/dist/linalg/Matrix4.d.ts +83 -102
  50. package/dist/linalg/Matrix4.d.ts.map +1 -1
  51. package/dist/linalg/Matrix4.js +105 -89
  52. package/dist/linalg/Matrix4.js.map +1 -1
  53. package/dist/linalg/Quaternion.d.ts +36 -49
  54. package/dist/linalg/Quaternion.d.ts.map +1 -1
  55. package/dist/linalg/Quaternion.js +33 -25
  56. package/dist/linalg/Quaternion.js.map +1 -1
  57. package/dist/linalg/SlowMatrix.d.ts +9 -9
  58. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  59. package/dist/linalg/SlowMatrix.js +76 -27
  60. package/dist/linalg/SlowMatrix.js.map +1 -1
  61. package/dist/linalg/SlowSquareMatrix.d.ts +3 -3
  62. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  63. package/dist/linalg/SlowSquareMatrix.js +53 -21
  64. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  65. package/dist/linalg/SquareMatrix.d.ts +3 -3
  66. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  67. package/dist/linalg/Vector.d.ts +25 -24
  68. package/dist/linalg/Vector.d.ts.map +1 -1
  69. package/dist/linalg/Vector2.d.ts +35 -52
  70. package/dist/linalg/Vector2.d.ts.map +1 -1
  71. package/dist/linalg/Vector2.js +8 -6
  72. package/dist/linalg/Vector2.js.map +1 -1
  73. package/dist/linalg/Vector3.d.ts +43 -63
  74. package/dist/linalg/Vector3.d.ts.map +1 -1
  75. package/dist/linalg/Vector3.js +46 -58
  76. package/dist/linalg/Vector3.js.map +1 -1
  77. package/dist/linalg/Vector4.d.ts +34 -45
  78. package/dist/linalg/Vector4.d.ts.map +1 -1
  79. package/dist/linalg/Vector4.js +6 -2
  80. package/dist/linalg/Vector4.js.map +1 -1
  81. package/dist/types/AxisAngle.d.ts +1 -1
  82. package/dist/types/AxisAngle.d.ts.map +1 -1
  83. package/dist/utility/BigNumber.d.ts +5 -8
  84. package/dist/utility/BigNumber.d.ts.map +1 -1
  85. package/dist/utility/BigNumber.js +5 -5
  86. package/dist/utility/BigNumber.js.map +1 -1
  87. package/dist/utility/MagnitudeError.d.ts.map +1 -1
  88. package/dist/utility/MagnitudeError.js +1 -1
  89. package/dist/utility/MagnitudeError.js.map +1 -1
  90. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  91. package/dist/utility/MatrixSizeError.js.map +1 -1
  92. package/dist/utility/PartialMatrixError.d.ts.map +1 -1
  93. package/dist/utility/PartialMatrixError.js.map +1 -1
  94. package/dist/utility/epsilon.d.ts.map +1 -1
  95. package/dist/utility/epsilon.js.map +1 -1
  96. package/package.json +20 -51
  97. package/src/algorithms/combinations.ts +5 -5
  98. package/src/algorithms/degreesToRadians.ts +4 -4
  99. package/src/algorithms/factorial.ts +14 -9
  100. package/src/algorithms/fibonacci.ts +3 -3
  101. package/src/algorithms/greatestCommonDivisor.ts +15 -19
  102. package/src/algorithms/hypergeometricPmf.ts +6 -7
  103. package/src/algorithms/isPrime.ts +5 -5
  104. package/src/algorithms/permutations.ts +5 -5
  105. package/src/algorithms/primeFactorization.ts +9 -9
  106. package/src/algorithms/radiansToDegrees.ts +4 -4
  107. package/src/algorithms/summation.ts +6 -6
  108. package/src/index.ts +35 -33
  109. package/src/linalg/DualQuaternion.ts +528 -780
  110. package/src/linalg/Matrix.ts +35 -36
  111. package/src/linalg/Matrix2.ts +253 -402
  112. package/src/linalg/Matrix3.ts +502 -720
  113. package/src/linalg/Matrix4.ts +1032 -1574
  114. package/src/linalg/Quaternion.ts +400 -679
  115. package/src/linalg/SlowMatrix.ts +124 -75
  116. package/src/linalg/SlowSquareMatrix.ts +92 -63
  117. package/src/linalg/SquareMatrix.ts +7 -7
  118. package/src/linalg/Vector.ts +71 -70
  119. package/src/linalg/Vector2.ts +342 -552
  120. package/src/linalg/Vector3.ts +502 -815
  121. package/src/linalg/Vector4.ts +347 -530
  122. package/src/types/AxisAngle.ts +1 -1
  123. package/src/utility/BigNumber.ts +36 -45
  124. package/src/utility/MagnitudeError.ts +4 -4
  125. package/src/utility/MatrixSizeError.ts +2 -3
  126. package/src/utility/PartialMatrixError.ts +2 -3
  127. package/src/utility/SingularMatrixError.ts +2 -2
  128. package/src/utility/epsilon.ts +1 -4
  129. package/dist/types/IntegerRepresentation.d.ts +0 -2
  130. package/dist/types/IntegerRepresentation.d.ts.map +0 -1
  131. package/dist/types/IntegerRepresentation.js +0 -2
  132. package/dist/types/IntegerRepresentation.js.map +0 -1
  133. package/src/types/IntegerRepresentation.ts +0 -2
@@ -1,48 +1,70 @@
1
1
  import {
2
+ type Matrix4Like,
2
3
  getRotation as getMatrix4Rotation,
3
- getTranslation as getMatrix4Translation,
4
- type Matrix4Like
5
- } from "#Matrix4";
4
+ getTranslation as getMatrix4Translation
5
+ } from "./Matrix4.js";
6
6
  import Quaternion, {
7
7
  type QuaternionLike,
8
+ createQuaternionLike,
8
9
  rotateX as quaternionRotateX,
9
10
  rotateY as quaternionRotateY,
10
11
  rotateZ as quaternionRotateZ
11
- } from "#Quaternion";
12
- import Vector3, { type Vector3Like } from "#Vector3";
12
+ } from "./Quaternion.js";
13
+ import Vector3, { type Vector3Like, createVector3Like } from "./Vector3.js";
13
14
  import {
14
- copy as xetReal,
15
15
  dot,
16
16
  getMagnitude,
17
17
  getSquaredMagnitude,
18
- type Vector4Like
19
- } from "#Vector4";
20
- import epsilon from "#epsilon";
18
+ copy as xetReal
19
+ } from "./Vector4.js";
20
+ import epsilon from "../utility/epsilon.js";
21
21
 
22
22
  /** A complex number that is commonly used to describe transformations. */
23
- export type DualQuaternionLike =
24
- | DualQuaternion
25
- | [number, number, number, number, number, number, number, number];
23
+ export interface DualQuaternionLike extends Record<number, number> {
24
+ /** The first real component of this dual quaternion. */
25
+ 0: number;
26
+
27
+ /** The second real component of this dual quaternion. */
28
+ 1: number;
29
+
30
+ /** The third real component of this dual quaternion. */
31
+ 2: number;
32
+
33
+ /** The fourth real component of this dual quaternion. */
34
+ 3: number;
35
+
36
+ /** The first dual component of this dual quaternion. */
37
+ 4: number;
38
+
39
+ /** The second dual component of this dual quaternion. */
40
+ 5: number;
41
+
42
+ /** The third dual component of this dual quaternion. */
43
+ 6: number;
44
+
45
+ /** The fourth dual component of this dual quaternion. */
46
+ 7: number;
47
+ }
26
48
 
27
49
  /**
28
- * Creates a dual quaternion-like object.
50
+ * Create a dual quaternion-like object.
29
51
  * @returns A dual quaternion-like object.
30
52
  */
31
- export function createDualQuaternionLike(): DualQuaternionLike {
32
- return new Float32Array(8) as DualQuaternionLike;
53
+ export function createDualQuaternionLike() {
54
+ return new Float32Array(8) as unknown as DualQuaternionLike;
33
55
  }
34
56
 
35
57
  /**
36
- * Creates a dual quaternion with the given values.
37
- * @param x1 The first real component.
38
- * @param y1 The second real component.
39
- * @param z1 The third real component.
40
- * @param w1 The fourth real component.
41
- * @param x2 The first dual component.
42
- * @param y2 The second dual component.
43
- * @param z2 The third dual component.
44
- * @param w2 The fourth dual component.
45
- * @param out The dual quaternion to store the result in.
58
+ * Create a dual quaternion with the given values.
59
+ * @param x1 - The first real component.
60
+ * @param y1 - The second real component.
61
+ * @param z1 - The third real component.
62
+ * @param w1 - The fourth real component.
63
+ * @param x2 - The first dual component.
64
+ * @param y2 - The second dual component.
65
+ * @param z2 - The third dual component.
66
+ * @param w2 - The fourth dual component.
67
+ * @param out - The dual quaternion to store the result in.
46
68
  * @returns A new dual quaternion.
47
69
  */
48
70
  export function fromValues<T extends DualQuaternionLike>(
@@ -55,7 +77,7 @@ export function fromValues<T extends DualQuaternionLike>(
55
77
  z2: number,
56
78
  w2: number,
57
79
  out: T
58
- ): T {
80
+ ) {
59
81
  out[0] = x1;
60
82
  out[1] = y1;
61
83
  out[2] = z1;
@@ -68,15 +90,15 @@ export function fromValues<T extends DualQuaternionLike>(
68
90
  }
69
91
 
70
92
  /**
71
- * Copies the values from one dual quaternion to another.
72
- * @param dualQuaternion The dual quaternion to copy.
73
- * @param out The dual quaternion to store the result in.
93
+ * Copy the values from one dual quaternion to another.
94
+ * @param dualQuaternion - The dual quaternion to copy.
95
+ * @param out - The dual quaternion to store the result in.
74
96
  * @returns The copy.
75
97
  */
76
98
  export function copy<T extends DualQuaternionLike>(
77
99
  dualQuaternion: DualQuaternionLike,
78
100
  out: T
79
- ): T {
101
+ ) {
80
102
  out[0] = dualQuaternion[0];
81
103
  out[1] = dualQuaternion[1];
82
104
  out[2] = dualQuaternion[2];
@@ -89,25 +111,25 @@ export function copy<T extends DualQuaternionLike>(
89
111
  }
90
112
 
91
113
  /**
92
- * Creates a dual quaternion from the given quaternion and translation.
93
- * @param quaternion The quaternion.
94
- * @param translation The translation.
95
- * @param out The dual quaternion to store the result in.
114
+ * Create a dual quaternion from the given quaternion and translation.
115
+ * @param quaternion - The quaternion.
116
+ * @param translation - The translation.
117
+ * @param out - The dual quaternion to store the result in.
96
118
  * @returns The dual quaternion.
97
119
  */
98
120
  export function fromRotationTranslation<T extends DualQuaternionLike>(
99
121
  quaternion: QuaternionLike,
100
122
  translation: Vector3Like,
101
123
  out: T
102
- ): T {
103
- const x: number = quaternion[0];
104
- const y: number = quaternion[1];
105
- const z: number = quaternion[2];
106
- const w: number = quaternion[3];
124
+ ) {
125
+ const x = quaternion[0];
126
+ const y = quaternion[1];
127
+ const z = quaternion[2];
128
+ const w = quaternion[3];
107
129
 
108
- const ax: number = translation[0] * 0.5;
109
- const ay: number = translation[1] * 0.5;
110
- const az: number = translation[2] * 0.5;
130
+ const ax = translation[0] * 0.5;
131
+ const ay = translation[1] * 0.5;
132
+ const az = translation[2] * 0.5;
111
133
 
112
134
  out[0] = x;
113
135
  out[1] = y;
@@ -121,15 +143,15 @@ export function fromRotationTranslation<T extends DualQuaternionLike>(
121
143
  }
122
144
 
123
145
  /**
124
- * Creates a dual quaternion from the given translation.
125
- * @param translation The translation.
126
- * @param out The dual quaternion to store the result in.
146
+ * Create a dual quaternion from the given translation.
147
+ * @param translation - The translation.
148
+ * @param out - The dual quaternion to store the result in.
127
149
  * @returns The dual quaternion.
128
150
  */
129
151
  export function fromTranslation<T extends DualQuaternionLike>(
130
152
  translation: Vector3Like,
131
153
  out: T
132
- ): T {
154
+ ) {
133
155
  out[0] = 0;
134
156
  out[1] = 0;
135
157
  out[2] = 0;
@@ -142,15 +164,15 @@ export function fromTranslation<T extends DualQuaternionLike>(
142
164
  }
143
165
 
144
166
  /**
145
- * Creates a dual quaternion from the given quaternion.
146
- * @param quaternion The quaternion.
147
- * @param out The dual quaternion to store the result in.
167
+ * Create a dual quaternion from the given quaternion.
168
+ * @param quaternion - The quaternion.
169
+ * @param out - The dual quaternion to store the result in.
148
170
  * @returns The dual quaternion.
149
171
  */
150
172
  export function fromRotation<T extends DualQuaternionLike>(
151
173
  quaternion: QuaternionLike,
152
174
  out: T
153
- ): T {
175
+ ) {
154
176
  out[0] = quaternion[0];
155
177
  out[1] = quaternion[1];
156
178
  out[2] = quaternion[2];
@@ -162,24 +184,20 @@ export function fromRotation<T extends DualQuaternionLike>(
162
184
  return out;
163
185
  }
164
186
 
165
- /**
166
- * A quaternion that is used to store intermediary values for some functions.
167
- */
168
- const rotation: QuaternionLike = new Float32Array(4) as QuaternionLike;
169
-
170
- /** A vector that is used to store intermediary values for some functions. */
171
- const translation: Vector3Like = new Float32Array(4) as Vector3Like;
187
+ // Used to store intermediary values for some functions.
188
+ const rotation = createQuaternionLike();
189
+ const translation = createVector3Like();
172
190
 
173
191
  /**
174
- * Creates a dual quaternion from the given four-by-four matrix.
175
- * @param matrix The matrix.
176
- * @param out The dual quaternion to store the result in.
192
+ * Create a dual quaternion from the given four-by-four matrix.
193
+ * @param matrix - The matrix.
194
+ * @param out - The dual quaternion to store the result in.
177
195
  * @returns The dual quaternion.
178
196
  */
179
197
  export function fromMatrix4<T extends DualQuaternionLike>(
180
198
  matrix: Matrix4Like,
181
199
  out: T
182
- ): T {
200
+ ) {
183
201
  return fromRotationTranslation(
184
202
  getMatrix4Rotation(matrix, rotation),
185
203
  getMatrix4Translation(matrix, translation),
@@ -188,11 +206,11 @@ export function fromMatrix4<T extends DualQuaternionLike>(
188
206
  }
189
207
 
190
208
  /**
191
- * Sets a dual quaternion to the identity dual quaternion.
192
- * @param out The dual quaternion to store the result in.
209
+ * Set a dual quaternion to the identity dual quaternion.
210
+ * @param out - The dual quaternion to store the result in.
193
211
  * @returns The identity dual quaternion.
194
212
  */
195
- export function identity<T extends DualQuaternionLike>(out: T): T {
213
+ export function identity<T extends DualQuaternionLike>(out: T) {
196
214
  out[0] = 0;
197
215
  out[1] = 0;
198
216
  out[2] = 0;
@@ -205,15 +223,15 @@ export function identity<T extends DualQuaternionLike>(out: T): T {
205
223
  }
206
224
 
207
225
  /**
208
- * Gets the dual part of a dual quaternion.
209
- * @param dualQuaternion The dual quaternion.
210
- * @param out The quaternion to store the result in.
226
+ * Get the dual part of a dual quaternion.
227
+ * @param dualQuaternion - The dual quaternion.
228
+ * @param out - The quaternion to store the result in.
211
229
  * @returns The dual part.
212
230
  */
213
231
  export function getDual<T extends QuaternionLike>(
214
232
  dualQuaternion: DualQuaternionLike,
215
233
  out: T
216
- ): T {
234
+ ) {
217
235
  out[0] = dualQuaternion[4];
218
236
  out[1] = dualQuaternion[5];
219
237
  out[2] = dualQuaternion[6];
@@ -222,15 +240,15 @@ export function getDual<T extends QuaternionLike>(
222
240
  }
223
241
 
224
242
  /**
225
- * Sets the dual part of a dual quaternion.
226
- * @param quaternion The quaternion to set as the dual part.
227
- * @param out The dual quaternion to store the result in.
243
+ * Set the dual part of a dual quaternion.
244
+ * @param quaternion - The quaternion to set as the dual part.
245
+ * @param out - The dual quaternion to store the result in.
228
246
  * @returns The dual quaternion.
229
247
  */
230
248
  export function setDual<T extends DualQuaternionLike>(
231
249
  quaternion: QuaternionLike,
232
250
  out: T
233
- ): T {
251
+ ) {
234
252
  out[4] = quaternion[0];
235
253
  out[5] = quaternion[1];
236
254
  out[6] = quaternion[2];
@@ -239,23 +257,23 @@ export function setDual<T extends DualQuaternionLike>(
239
257
  }
240
258
 
241
259
  /**
242
- * Gets the translation of a normalized dual quaternion.
243
- * @param dualQuaternion The dual quaternion.
244
- * @param out The vector to store the result in.
260
+ * Get the translation of a normalized dual quaternion.
261
+ * @param dualQuaternion - The dual quaternion.
262
+ * @param out - The vector to store the result in.
245
263
  * @returns The translation.
246
264
  */
247
265
  export function getTranslation<T extends Vector3Like>(
248
266
  dualQuaternion: DualQuaternionLike,
249
267
  out: T
250
- ): T {
251
- const ax: number = dualQuaternion[4];
252
- const ay: number = dualQuaternion[5];
253
- const az: number = dualQuaternion[6];
254
- const aw: number = dualQuaternion[7];
255
- const bx: number = -dualQuaternion[0];
256
- const by: number = -dualQuaternion[1];
257
- const bz: number = -dualQuaternion[2];
258
- const bw: number = dualQuaternion[3];
268
+ ) {
269
+ const ax = dualQuaternion[4];
270
+ const ay = dualQuaternion[5];
271
+ const az = dualQuaternion[6];
272
+ const aw = dualQuaternion[7];
273
+ const bx = -dualQuaternion[0];
274
+ const by = -dualQuaternion[1];
275
+ const bz = -dualQuaternion[2];
276
+ const bw = dualQuaternion[3];
259
277
 
260
278
  out[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;
261
279
  out[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;
@@ -264,30 +282,30 @@ export function getTranslation<T extends Vector3Like>(
264
282
  }
265
283
 
266
284
  /**
267
- * Translates a dual quaternion by the given vector.
268
- * @param dualQuaternion The dual quaternion.
269
- * @param vector The vector.
270
- * @param out The dual quaternion to store the result in.
285
+ * Translate a dual quaternion by the given vector.
286
+ * @param dualQuaternion - The dual quaternion.
287
+ * @param vector - The vector.
288
+ * @param out - The dual quaternion to store the result in.
271
289
  * @returns The translated dual quaternion.
272
290
  */
273
291
  export function translate<T extends DualQuaternionLike>(
274
292
  dualQuaternion: DualQuaternionLike,
275
293
  vector: Vector3Like,
276
294
  out: T
277
- ): T {
278
- const ax1: number = dualQuaternion[0];
279
- const ay1: number = dualQuaternion[1];
280
- const az1: number = dualQuaternion[2];
281
- const aw1: number = dualQuaternion[3];
295
+ ) {
296
+ const ax1 = dualQuaternion[0];
297
+ const ay1 = dualQuaternion[1];
298
+ const az1 = dualQuaternion[2];
299
+ const aw1 = dualQuaternion[3];
282
300
 
283
- const bx1: number = vector[0] * 0.5;
284
- const by1: number = vector[1] * 0.5;
285
- const bz1: number = vector[2] * 0.5;
301
+ const bx1 = vector[0] * 0.5;
302
+ const by1 = vector[1] * 0.5;
303
+ const bz1 = vector[2] * 0.5;
286
304
 
287
- const ax2: number = dualQuaternion[4];
288
- const ay2: number = dualQuaternion[5];
289
- const az2: number = dualQuaternion[6];
290
- const aw2: number = dualQuaternion[7];
305
+ const ax2 = dualQuaternion[4];
306
+ const ay2 = dualQuaternion[5];
307
+ const az2 = dualQuaternion[6];
308
+ const aw2 = dualQuaternion[7];
291
309
 
292
310
  out[0] = ax1;
293
311
  out[1] = ay1;
@@ -301,17 +319,17 @@ export function translate<T extends DualQuaternionLike>(
301
319
  }
302
320
 
303
321
  /**
304
- * Rotates a dual quaternion around the X-axis.
305
- * @param dualQuaternion The dual quaternion.
306
- * @param radians The angle to rotate by in radians.
307
- * @param out The dual quaternion to store the result in.
322
+ * Rotate a dual quaternion around the X-axis.
323
+ * @param dualQuaternion - The dual quaternion.
324
+ * @param radians - The angle to rotate by in radians.
325
+ * @param out - The dual quaternion to store the result in.
308
326
  * @returns The rotated dual quaternion.
309
327
  */
310
328
  export function rotateX<T extends DualQuaternionLike>(
311
329
  dualQuaternion: DualQuaternionLike,
312
330
  radians: number,
313
331
  out: T
314
- ): T {
332
+ ) {
315
333
  let bx = -dualQuaternion[0];
316
334
  let by = -dualQuaternion[1];
317
335
  let bz = -dualQuaternion[2];
@@ -327,11 +345,7 @@ export function rotateX<T extends DualQuaternionLike>(
327
345
  const az1 = az * bw + aw * bz + ax * by - ay * bx;
328
346
  const aw1 = aw * bw - ax * bx - ay * by - az * bz;
329
347
 
330
- quaternionRotateX(
331
- dualQuaternion as unknown as QuaternionLike,
332
- radians,
333
- out as unknown as QuaternionLike
334
- );
348
+ quaternionRotateX(dualQuaternion, radians, out);
335
349
 
336
350
  bx = out[0];
337
351
  by = out[1];
@@ -346,37 +360,33 @@ export function rotateX<T extends DualQuaternionLike>(
346
360
  }
347
361
 
348
362
  /**
349
- * Rotates a dual quaternion around the Y-axis.
350
- * @param dualQuaternion The dual quaternion.
351
- * @param radians The angle to rotate by in radians.
352
- * @param out The dual quaternion to store the result in.
363
+ * Rotate a dual quaternion around the Y-axis.
364
+ * @param dualQuaternion - The dual quaternion.
365
+ * @param radians - The angle to rotate by in radians.
366
+ * @param out - The dual quaternion to store the result in.
353
367
  * @returns The rotated dual quaternion.
354
368
  */
355
369
  export function rotateY<T extends DualQuaternionLike>(
356
370
  dualQuaternion: DualQuaternionLike,
357
371
  radians: number,
358
372
  out: T
359
- ): T {
360
- let bx: number = -dualQuaternion[0];
361
- let by: number = -dualQuaternion[1];
362
- let bz: number = -dualQuaternion[2];
363
- let bw: number = dualQuaternion[3];
364
-
365
- const ax: number = dualQuaternion[4];
366
- const ay: number = dualQuaternion[5];
367
- const az: number = dualQuaternion[6];
368
- const aw: number = dualQuaternion[7];
369
-
370
- const ax1: number = ax * bw + aw * bx + ay * bz - az * by;
371
- const ay1: number = ay * bw + aw * by + az * bx - ax * bz;
372
- const az1: number = az * bw + aw * bz + ax * by - ay * bx;
373
- const aw1: number = aw * bw - ax * bx - ay * by - az * bz;
374
-
375
- quaternionRotateY(
376
- dualQuaternion as unknown as QuaternionLike,
377
- radians,
378
- out as unknown as QuaternionLike
379
- );
373
+ ) {
374
+ let bx = -dualQuaternion[0];
375
+ let by = -dualQuaternion[1];
376
+ let bz = -dualQuaternion[2];
377
+ let bw = dualQuaternion[3];
378
+
379
+ const ax = dualQuaternion[4];
380
+ const ay = dualQuaternion[5];
381
+ const az = dualQuaternion[6];
382
+ const aw = dualQuaternion[7];
383
+
384
+ const ax1 = ax * bw + aw * bx + ay * bz - az * by;
385
+ const ay1 = ay * bw + aw * by + az * bx - ax * bz;
386
+ const az1 = az * bw + aw * bz + ax * by - ay * bx;
387
+ const aw1 = aw * bw - ax * bx - ay * by - az * bz;
388
+
389
+ quaternionRotateY(dualQuaternion, radians, out);
380
390
 
381
391
  bx = out[0];
382
392
  by = out[1];
@@ -391,37 +401,33 @@ export function rotateY<T extends DualQuaternionLike>(
391
401
  }
392
402
 
393
403
  /**
394
- * Rotates a dual quaternion around the Z-axis.
395
- * @param dualQuaternion The dual quaternion.
396
- * @param radians The angle to rotate by in radians.
397
- * @param out The dual quaternion to store the result in.
404
+ * Rotate a dual quaternion around the Z-axis.
405
+ * @param dualQuaternion - The dual quaternion.
406
+ * @param radians - The angle to rotate by in radians.
407
+ * @param out - The dual quaternion to store the result in.
398
408
  * @returns The rotated dual quaternion.
399
409
  */
400
410
  export function rotateZ<T extends DualQuaternionLike>(
401
411
  dualQuaternion: DualQuaternionLike,
402
412
  radians: number,
403
413
  out: T
404
- ): T {
405
- let bx: number = -dualQuaternion[0];
406
- let by: number = -dualQuaternion[1];
407
- let bz: number = -dualQuaternion[2];
408
- let bw: number = dualQuaternion[3];
409
-
410
- const ax: number = dualQuaternion[4];
411
- const ay: number = dualQuaternion[5];
412
- const az: number = dualQuaternion[6];
413
- const aw: number = dualQuaternion[7];
414
-
415
- const ax1: number = ax * bw + aw * bx + ay * bz - az * by;
416
- const ay1: number = ay * bw + aw * by + az * bx - ax * bz;
417
- const az1: number = az * bw + aw * bz + ax * by - ay * bx;
418
- const aw1: number = aw * bw - ax * bx - ay * by - az * bz;
419
-
420
- quaternionRotateZ(
421
- dualQuaternion as unknown as QuaternionLike,
422
- radians,
423
- out as unknown as QuaternionLike
424
- );
414
+ ) {
415
+ let bx = -dualQuaternion[0];
416
+ let by = -dualQuaternion[1];
417
+ let bz = -dualQuaternion[2];
418
+ let bw = dualQuaternion[3];
419
+
420
+ const ax = dualQuaternion[4];
421
+ const ay = dualQuaternion[5];
422
+ const az = dualQuaternion[6];
423
+ const aw = dualQuaternion[7];
424
+
425
+ const ax1 = ax * bw + aw * bx + ay * bz - az * by;
426
+ const ay1 = ay * bw + aw * by + az * bx - ax * bz;
427
+ const az1 = az * bw + aw * bz + ax * by - ay * bx;
428
+ const aw1 = aw * bw - ax * bx - ay * by - az * bz;
429
+
430
+ quaternionRotateZ(dualQuaternion, radians, out);
425
431
 
426
432
  bx = out[0];
427
433
  by = out[1];
@@ -436,26 +442,26 @@ export function rotateZ<T extends DualQuaternionLike>(
436
442
  }
437
443
 
438
444
  /**
439
- * Multiplies a dual quaternion by a quaternion.
440
- * @param dualQuaternion The dual quaternion.
441
- * @param quaternion The quaternion.
442
- * @param out The dual quaternion to store the result in.
445
+ * Multiply a dual quaternion by a quaternion.
446
+ * @param dualQuaternion - The dual quaternion.
447
+ * @param quaternion - The quaternion.
448
+ * @param out - The dual quaternion to store the result in.
443
449
  * @returns The rotated dual quaternion.
444
450
  */
445
451
  export function rotateByQuaternionAppend<T extends DualQuaternionLike>(
446
452
  dualQuaternion: DualQuaternionLike,
447
453
  quaternion: QuaternionLike,
448
454
  out: T
449
- ): T {
450
- const qx: number = quaternion[0];
451
- const qy: number = quaternion[1];
452
- const qz: number = quaternion[2];
453
- const qw: number = quaternion[3];
455
+ ) {
456
+ const qx = quaternion[0];
457
+ const qy = quaternion[1];
458
+ const qz = quaternion[2];
459
+ const qw = quaternion[3];
454
460
 
455
- let ax: number = dualQuaternion[0];
456
- let ay: number = dualQuaternion[1];
457
- let az: number = dualQuaternion[2];
458
- let aw: number = dualQuaternion[3];
461
+ let ax = dualQuaternion[0];
462
+ let ay = dualQuaternion[1];
463
+ let az = dualQuaternion[2];
464
+ let aw = dualQuaternion[3];
459
465
 
460
466
  out[0] = ax * qw + aw * qx + ay * qz - az * qy;
461
467
  out[1] = ay * qw + aw * qy + az * qx - ax * qz;
@@ -475,26 +481,26 @@ export function rotateByQuaternionAppend<T extends DualQuaternionLike>(
475
481
  }
476
482
 
477
483
  /**
478
- * Multiplies a quaternion by a dual quaternion.
479
- * @param quaternion The quaternion.
480
- * @param dualQuaternion The dual quaternion.
481
- * @param out The dual quaternion to store the result in.
484
+ * Multiply a quaternion by a dual quaternion.
485
+ * @param quaternion - The quaternion.
486
+ * @param dualQuaternion - The dual quaternion.
487
+ * @param out - The dual quaternion to store the result in.
482
488
  * @returns The rotated dual quaternion.
483
489
  */
484
490
  export function rotateByQuaternionPrepend<T extends DualQuaternionLike>(
485
491
  quaternion: QuaternionLike,
486
492
  dualQuaternion: DualQuaternionLike,
487
493
  out: T
488
- ): T {
489
- const qx: number = quaternion[0];
490
- const qy: number = quaternion[1];
491
- const qz: number = quaternion[2];
492
- const qw: number = quaternion[3];
493
-
494
- let bx: number = dualQuaternion[0];
495
- let by: number = dualQuaternion[1];
496
- let bz: number = dualQuaternion[2];
497
- let bw: number = dualQuaternion[3];
494
+ ) {
495
+ const qx = quaternion[0];
496
+ const qy = quaternion[1];
497
+ const qz = quaternion[2];
498
+ const qw = quaternion[3];
499
+
500
+ let bx = dualQuaternion[0];
501
+ let by = dualQuaternion[1];
502
+ let bz = dualQuaternion[2];
503
+ let bw = dualQuaternion[3];
498
504
 
499
505
  out[0] = qx * bw + qw * bx + qy * bz - qz * by;
500
506
  out[1] = qy * bw + qw * by + qz * bx - qx * bz;
@@ -514,11 +520,11 @@ export function rotateByQuaternionPrepend<T extends DualQuaternionLike>(
514
520
  }
515
521
 
516
522
  /**
517
- * Rotates a dual quaternion around an axis.
518
- * @param dualQuaternion The dual quaternion.
519
- * @param axis The axis.
520
- * @param radians The angle of the rotation in radians.
521
- * @param out The dual quaternion to store the result in.
523
+ * Rotate a dual quaternion around an axis.
524
+ * @param dualQuaternion - The dual quaternion.
525
+ * @param axis - The axis.
526
+ * @param radians - The angle of the rotation in radians.
527
+ * @param out - The dual quaternion to store the result in.
522
528
  * @returns A normalized dual quaternion.
523
529
  */
524
530
  export function rotateAroundAxis<T extends DualQuaternionLike>(
@@ -526,25 +532,25 @@ export function rotateAroundAxis<T extends DualQuaternionLike>(
526
532
  axis: Vector3Like,
527
533
  radians: number,
528
534
  out: T
529
- ): T {
535
+ ) {
530
536
  if (Math.abs(radians) < 0) {
531
537
  return copy(dualQuaternion, out);
532
538
  }
533
539
 
534
- const axisLength: number = Math.hypot(axis[0], axis[1], axis[2]);
540
+ const axisLength = Math.hypot(axis[0], axis[1], axis[2]);
535
541
 
536
- const r: number = radians * 0.5;
542
+ const r = radians * 0.5;
537
543
 
538
- const s: number = Math.sin(r);
539
- const bx: number = (s * axis[0]) / axisLength;
540
- const by: number = (s * axis[1]) / axisLength;
541
- const bz: number = (s * axis[2]) / axisLength;
542
- const bw: number = Math.cos(r);
544
+ const s = Math.sin(r);
545
+ const bx = (s * axis[0]) / axisLength;
546
+ const by = (s * axis[1]) / axisLength;
547
+ const bz = (s * axis[2]) / axisLength;
548
+ const bw = Math.cos(r);
543
549
 
544
- let x: number = dualQuaternion[0];
545
- let y: number = dualQuaternion[1];
546
- let z: number = dualQuaternion[2];
547
- let w: number = dualQuaternion[3];
550
+ let x = dualQuaternion[0];
551
+ let y = dualQuaternion[1];
552
+ let z = dualQuaternion[2];
553
+ let w = dualQuaternion[3];
548
554
 
549
555
  out[0] = x * bw + w * bx + y * bz - z * by;
550
556
  out[1] = y * bw + w * by + z * bx - x * bz;
@@ -564,17 +570,17 @@ export function rotateAroundAxis<T extends DualQuaternionLike>(
564
570
  }
565
571
 
566
572
  /**
567
- * Adds two dual quaternions.
568
- * @param a The augend.
569
- * @param b The addend.
570
- * @param out The dual quaternion to store the result in.
573
+ * Add two dual quaternions.
574
+ * @param a - The augend.
575
+ * @param b - The addend.
576
+ * @param out - The dual quaternion to store the result in.
571
577
  * @returns The sum.
572
578
  */
573
579
  export function add<T extends DualQuaternionLike>(
574
580
  a: DualQuaternionLike,
575
581
  b: DualQuaternionLike,
576
582
  out: T
577
- ): T {
583
+ ) {
578
584
  out[0] = a[0] + b[0];
579
585
  out[1] = a[1] + b[1];
580
586
  out[2] = a[2] + b[2];
@@ -587,36 +593,36 @@ export function add<T extends DualQuaternionLike>(
587
593
  }
588
594
 
589
595
  /**
590
- * Multiplies two dual quaternions.
591
- * @param a The multiplier.
592
- * @param b The multiplicand.
593
- * @param out The dual quaternion to store the result in.
596
+ * Multiply two dual quaternions.
597
+ * @param a - The multiplier.
598
+ * @param b - The multiplicand.
599
+ * @param out - The dual quaternion to store the result in.
594
600
  * @returns The product.
595
601
  */
596
602
  export function multiply<T extends DualQuaternionLike>(
597
603
  a: DualQuaternionLike,
598
604
  b: DualQuaternionLike,
599
605
  out: T
600
- ): T {
601
- const ax0: number = a[0];
602
- const ay0: number = a[1];
603
- const az0: number = a[2];
604
- const aw0: number = a[3];
605
-
606
- const ax1: number = a[4];
607
- const ay1: number = a[5];
608
- const az1: number = a[6];
609
- const aw1: number = a[7];
610
-
611
- const bx0: number = b[0];
612
- const by0: number = b[1];
613
- const bz0: number = b[2];
614
- const bw0: number = b[3];
615
-
616
- const bx1: number = b[4];
617
- const by1: number = b[5];
618
- const bz1: number = b[6];
619
- const bw1: number = b[7];
606
+ ) {
607
+ const ax0 = a[0];
608
+ const ay0 = a[1];
609
+ const az0 = a[2];
610
+ const aw0 = a[3];
611
+
612
+ const ax1 = a[4];
613
+ const ay1 = a[5];
614
+ const az1 = a[6];
615
+ const aw1 = a[7];
616
+
617
+ const bx0 = b[0];
618
+ const by0 = b[1];
619
+ const bz0 = b[2];
620
+ const bw0 = b[3];
621
+
622
+ const bx1 = b[4];
623
+ const by1 = b[5];
624
+ const bz1 = b[6];
625
+ const bw1 = b[7];
620
626
 
621
627
  out[0] = ax0 * bw0 + aw0 * bx0 + ay0 * bz0 - az0 * by0;
622
628
  out[1] = ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0;
@@ -662,17 +668,17 @@ export function multiply<T extends DualQuaternionLike>(
662
668
  }
663
669
 
664
670
  /**
665
- * Multiplies a dual quaternion by a scalar.
666
- * @param dualQuaternion The multiplicand.
667
- * @param scalar The multiplier.
668
- * @param out The dual quaternion to store the result in.
671
+ * Multiply a dual quaternion by a scalar.
672
+ * @param dualQuaternion - The multiplicand.
673
+ * @param scalar - The multiplier.
674
+ * @param out - The dual quaternion to store the result in.
669
675
  * @returns The sum.
670
676
  */
671
677
  export function scale<T extends DualQuaternionLike>(
672
678
  dualQuaternion: DualQuaternionLike,
673
679
  scalar: number,
674
680
  out: T
675
- ): T {
681
+ ) {
676
682
  out[0] = dualQuaternion[0] * scalar;
677
683
  out[1] = dualQuaternion[1] * scalar;
678
684
  out[2] = dualQuaternion[2] * scalar;
@@ -685,11 +691,11 @@ export function scale<T extends DualQuaternionLike>(
685
691
  }
686
692
 
687
693
  /**
688
- * Performs a linear interpolation between two dual quaternions.
689
- * @param a The first dual quaternion.
690
- * @param b The second dual quaternion.
691
- * @param t The interpolation amount in `[0,1]`.
692
- * @param out The dual quaternion to store the result in.
694
+ * Perform a linear interpolation between two dual quaternions.
695
+ * @param a - The first dual quaternion.
696
+ * @param b - The second dual quaternion.
697
+ * @param t - The interpolation amount in `[0,1]`.
698
+ * @param out - The dual quaternion to store the result in.
693
699
  * @returns The interpolated value.
694
700
  */
695
701
  export function lerp<T extends DualQuaternionLike>(
@@ -697,38 +703,32 @@ export function lerp<T extends DualQuaternionLike>(
697
703
  b: DualQuaternionLike,
698
704
  t: number,
699
705
  out: T
700
- ): T {
701
- const mt: number = 1 - t;
702
-
703
- if (dot(a as unknown as Vector4Like, b as unknown as Vector4Like) < epsilon) {
704
- t = -t;
705
- }
706
-
707
- out[0] = a[0] * mt + b[0] * t;
708
- out[1] = a[1] * mt + b[1] * t;
709
- out[2] = a[2] * mt + b[2] * t;
710
- out[3] = a[3] * mt + b[3] * t;
711
- out[4] = a[4] * mt + b[4] * t;
712
- out[5] = a[5] * mt + b[5] * t;
713
- out[6] = a[6] * mt + b[6] * t;
714
- out[7] = a[7] * mt + b[7] * t;
706
+ ) {
707
+ const mt = 1 - t;
708
+ const it = dot(a, b) < epsilon ? -t : t;
709
+
710
+ out[0] = a[0] * mt + b[0] * it;
711
+ out[1] = a[1] * mt + b[1] * it;
712
+ out[2] = a[2] * mt + b[2] * it;
713
+ out[3] = a[3] * mt + b[3] * it;
714
+ out[4] = a[4] * mt + b[4] * it;
715
+ out[5] = a[5] * mt + b[5] * it;
716
+ out[6] = a[6] * mt + b[6] * it;
717
+ out[7] = a[7] * mt + b[7] * it;
715
718
  return out;
716
719
  }
717
720
 
718
721
  /**
719
- * Calculates the inverse of a dual quaternion. If the dual quaternion is
720
- * normalized, the conjugate is equivalent and faster to calculate.
721
- * @param dualQuaternion The dual quaternion.
722
- * @param out The dual quaternion to store the result in.
722
+ * Calculate the inverse of a dual quaternion. If the dual quaternion is normalized, the conjugate is equivalent and faster to calculate.
723
+ * @param dualQuaternion - The dual quaternion.
724
+ * @param out - The dual quaternion to store the result in.
723
725
  * @returns The inverse.
724
726
  */
725
727
  export function invert<T extends DualQuaternionLike>(
726
728
  dualQuaternion: DualQuaternionLike,
727
729
  out: T
728
- ): T {
729
- const sqm: number = getSquaredMagnitude(
730
- dualQuaternion as unknown as Vector4Like
731
- );
730
+ ) {
731
+ const sqm = getSquaredMagnitude(dualQuaternion);
732
732
 
733
733
  out[0] = -dualQuaternion[0] / sqm;
734
734
  out[1] = -dualQuaternion[1] / sqm;
@@ -742,16 +742,15 @@ export function invert<T extends DualQuaternionLike>(
742
742
  }
743
743
 
744
744
  /**
745
- * Calculates the conjugate of a dual quaternion. If the dual quaternion is
746
- * normalized, this is equivalent to its inverse and faster to calculate.
747
- * @param dualQuaternion The dual quaternion.
748
- * @param out The dual quaternion to store the result in.
745
+ * Calculate the conjugate of a dual quaternion. If the dual quaternion is normalized, this is equivalent to its inverse and faster to calculate.
746
+ * @param dualQuaternion - The dual quaternion.
747
+ * @param out - The dual quaternion to store the result in.
749
748
  * @returns The conjugate.
750
749
  */
751
750
  export function conjugate<T extends DualQuaternionLike>(
752
751
  dualQuaternion: DualQuaternionLike,
753
752
  out: T
754
- ): T {
753
+ ) {
755
754
  out[0] = -dualQuaternion[0];
756
755
  out[1] = -dualQuaternion[1];
757
756
  out[2] = -dualQuaternion[2];
@@ -764,54 +763,49 @@ export function conjugate<T extends DualQuaternionLike>(
764
763
  }
765
764
 
766
765
  /**
767
- * Normalizes a dual quaternion.
768
- * @param dualQuaternion The dual quaternion.
769
- * @param out The dual quaternion to store the result in.
766
+ * Normalize a dual quaternion.
767
+ * @param dualQuaternion - The dual quaternion.
768
+ * @param out - The dual quaternion to store the result in.
770
769
  * @returns The normalized dual quaternion.
771
770
  */
772
771
  export function normalize<T extends DualQuaternionLike>(
773
772
  dualQuaternion: DualQuaternionLike,
774
773
  out: T
775
- ): T {
776
- let magnitude: number = getSquaredMagnitude(
777
- dualQuaternion as unknown as Vector4Like
778
- );
774
+ ) {
775
+ let magnitude = getSquaredMagnitude(dualQuaternion);
779
776
  if (magnitude > 0) {
780
777
  magnitude = Math.sqrt(magnitude);
781
778
 
782
- const a0: number = dualQuaternion[0] / magnitude;
783
- const a1: number = dualQuaternion[1] / magnitude;
784
- const a2: number = dualQuaternion[2] / magnitude;
785
- const a3: number = dualQuaternion[3] / magnitude;
786
- const b0: number = dualQuaternion[4];
787
- const b1: number = dualQuaternion[5];
788
- const b2: number = dualQuaternion[6];
789
- const b3: number = dualQuaternion[7];
779
+ const a0 = dualQuaternion[0] / magnitude;
780
+ const a1 = dualQuaternion[1] / magnitude;
781
+ const a2 = dualQuaternion[2] / magnitude;
782
+ const a3 = dualQuaternion[3] / magnitude;
783
+ const b0 = dualQuaternion[4];
784
+ const b1 = dualQuaternion[5];
785
+ const b2 = dualQuaternion[6];
786
+ const b3 = dualQuaternion[7];
790
787
 
791
- const a_dot_b: number = a0 * b0 + a1 * b1 + a2 * b2 + a3 * b3;
788
+ const aDotB = a0 * b0 + a1 * b1 + a2 * b2 + a3 * b3;
792
789
 
793
790
  out[0] = a0;
794
791
  out[1] = a1;
795
792
  out[2] = a2;
796
793
  out[3] = a3;
797
- out[4] = (b0 - a0 * a_dot_b) / magnitude;
798
- out[5] = (b1 - a1 * a_dot_b) / magnitude;
799
- out[6] = (b2 - a2 * a_dot_b) / magnitude;
800
- out[7] = (b3 - a3 * a_dot_b) / magnitude;
794
+ out[4] = (b0 - a0 * aDotB) / magnitude;
795
+ out[5] = (b1 - a1 * aDotB) / magnitude;
796
+ out[6] = (b2 - a2 * aDotB) / magnitude;
797
+ out[7] = (b3 - a3 * aDotB) / magnitude;
801
798
  }
802
799
  return out;
803
800
  }
804
801
 
805
802
  /**
806
- * Determines whether two dual quaternions are exactly equivalent.
807
- * @param a The first dual quaternion.
808
- * @param b The second dual quaternion.
809
- * @returns Whether the dual quaternions are equivalent.
803
+ * Determine whether or not two dual quaternions are exactly equivalent.
804
+ * @param a - The first dual quaternion.
805
+ * @param b - The second dual quaternion.
806
+ * @returns Whether or not the dual quaternions are equivalent.
810
807
  */
811
- export function exactEquals(
812
- a: DualQuaternionLike,
813
- b: DualQuaternionLike
814
- ): boolean {
808
+ export function exactEquals(a: DualQuaternionLike, b: DualQuaternionLike) {
815
809
  return (
816
810
  a[0] === b[0] &&
817
811
  a[1] === b[1] &&
@@ -825,29 +819,29 @@ export function exactEquals(
825
819
  }
826
820
 
827
821
  /**
828
- * Determines whether two dual quaternions are roughly equivalent.
829
- * @param a The first dual quaternion.
830
- * @param b The second dual quaternion.
831
- * @returns Whether the dual quaternions are equivalent.
822
+ * Determine whether or not two dual quaternions are roughly equivalent.
823
+ * @param a - The first dual quaternion.
824
+ * @param b - The second dual quaternion.
825
+ * @returns Whether or not the dual quaternions are equivalent.
832
826
  */
833
- export function equals(a: DualQuaternionLike, b: DualQuaternionLike): boolean {
834
- const a0: number = a[0];
835
- const a1: number = a[1];
836
- const a2: number = a[2];
837
- const a3: number = a[3];
838
- const a4: number = a[4];
839
- const a5: number = a[5];
840
- const a6: number = a[6];
841
- const a7: number = a[7];
842
-
843
- const b0: number = b[0];
844
- const b1: number = b[1];
845
- const b2: number = b[2];
846
- const b3: number = b[3];
847
- const b4: number = b[4];
848
- const b5: number = b[5];
849
- const b6: number = b[6];
850
- const b7: number = b[7];
827
+ export function equals(a: DualQuaternionLike, b: DualQuaternionLike) {
828
+ const a0 = a[0];
829
+ const a1 = a[1];
830
+ const a2 = a[2];
831
+ const a3 = a[3];
832
+ const a4 = a[4];
833
+ const a5 = a[5];
834
+ const a6 = a[6];
835
+ const a7 = a[7];
836
+
837
+ const b0 = b[0];
838
+ const b1 = b[1];
839
+ const b2 = b[2];
840
+ const b3 = b[3];
841
+ const b4 = b[4];
842
+ const b5 = b[5];
843
+ const b6 = b[6];
844
+ const b7 = b[7];
851
845
 
852
846
  return (
853
847
  Math.abs(a0 - b0) <= epsilon * Math.max(1, Math.abs(a0), Math.abs(b0)) &&
@@ -865,41 +859,21 @@ export function equals(a: DualQuaternionLike, b: DualQuaternionLike): boolean {
865
859
  * A complex number that is commonly used to describe transformations.
866
860
  * @see [Dual quaternion](https://en.wikipedia.org/wiki/Dual_quaternion)
867
861
  */
868
- export default class DualQuaternion extends Float32Array {
869
- /**
870
- * Creates a dual quaternion with the given values.
871
- * @param x1 The first real component.
872
- * @param y1 The second real component.
873
- * @param z1 The third real component.
874
- * @param w1 The fourth real component.
875
- * @param x2 The first dual component.
876
- * @param y2 The second dual component.
877
- * @param z2 The third dual component.
878
- * @param w2 The fourth dual component.
879
- * @returns A new dual quaternion.
880
- */
881
- public static fromValues(
882
- x1: number,
883
- y1: number,
884
- z1: number,
885
- w1: number,
886
- x2: number,
887
- y2: number,
888
- z2: number,
889
- w2: number
890
- ): DualQuaternion;
891
-
862
+ export default class DualQuaternion
863
+ extends Float32Array
864
+ implements DualQuaternionLike
865
+ {
892
866
  /**
893
- * Creates a dual quaternion with the given values.
894
- * @param x1 The first real component.
895
- * @param y1 The second real component.
896
- * @param z1 The third real component.
897
- * @param w1 The fourth real component.
898
- * @param x2 The first dual component.
899
- * @param y2 The second dual component.
900
- * @param z2 The third dual component.
901
- * @param w2 The fourth dual component.
902
- * @param out The dual quaternion to store the result in.
867
+ * Create a dual quaternion with the given values.
868
+ * @param x1 - The first real component.
869
+ * @param y1 - The second real component.
870
+ * @param z1 - The third real component.
871
+ * @param w1 - The fourth real component.
872
+ * @param x2 - The first dual component.
873
+ * @param y2 - The second dual component.
874
+ * @param z2 - The third dual component.
875
+ * @param w2 - The fourth dual component.
876
+ * @param out - The dual quaternion to store the result in.
903
877
  * @returns A new dual quaternion.
904
878
  */
905
879
  public static fromValues<T extends DualQuaternionLike>(
@@ -911,132 +885,67 @@ export default class DualQuaternion extends Float32Array {
911
885
  y2: number,
912
886
  z2: number,
913
887
  w2: number,
914
- out: T
915
- ): T;
916
-
917
- public static fromValues<T extends DualQuaternionLike>(
918
- x1: number,
919
- y1: number,
920
- z1: number,
921
- w1: number,
922
- x2: number,
923
- y2: number,
924
- z2: number,
925
- w2: number,
926
- out: T = new DualQuaternion() as T
927
- ): T {
888
+ out = new DualQuaternion() as unknown as T
889
+ ) {
928
890
  return fromValues(x1, y1, z1, w1, x2, y2, z2, w2, out);
929
891
  }
930
892
 
931
893
  /**
932
- * Creates a dual quaternion from the given quaternion and translation.
933
- * @param quaternion The quaternion.
934
- * @param translation The translation.
894
+ * Create a dual quaternion from the given quaternion and translation.
895
+ * @param q - The quaternion.
896
+ * @param t - The translation.
897
+ * @param out - The dual quaternion to store the result in.
935
898
  * @returns The dual quaternion.
936
899
  */
937
- public static fromRotationTranslation(
938
- quaternion: QuaternionLike,
939
- translation: Vector3Like
940
- ): DualQuaternion;
941
-
942
- /**
943
- * Creates a dual quaternion from the given quaternion and translation.
944
- * @param quaternion The quaternion.
945
- * @param translation The translation.
946
- * @param out The dual quaternion to store the result in.
947
- * @returns The dual quaternion.
948
- */
949
- public static fromRotationTranslation<T extends DualQuaternionLike>(
950
- quaternion: QuaternionLike,
951
- translation: Vector3Like,
952
- out: T
953
- ): T;
954
-
955
900
  public static fromRotationTranslation<T extends DualQuaternionLike>(
956
- quaternion: QuaternionLike,
957
- translation: Vector3Like,
958
- out: T = new DualQuaternion() as T
959
- ): T {
960
- return fromRotationTranslation(quaternion, translation, out);
901
+ q: QuaternionLike,
902
+ t: Vector3Like,
903
+ out = new DualQuaternion() as unknown as T
904
+ ) {
905
+ return fromRotationTranslation(q, t, out);
961
906
  }
962
907
 
963
908
  /**
964
- * Creates a dual quaternion from the given translation.
965
- * @param translation The translation.
966
- * @returns The dual quaternion.
967
- */
968
- public static fromTranslation(translation: Vector3Like): DualQuaternion;
969
-
970
- /**
971
- * Creates a dual quaternion from the given translation.
972
- * @param translation The translation.
973
- * @param out The dual quaternion to store the result in.
909
+ * Create a dual quaternion from the given translation.
910
+ * @param t - The translation.
911
+ * @param out - The dual quaternion to store the result in.
974
912
  * @returns The dual quaternion.
975
913
  */
976
914
  public static fromTranslation<T extends DualQuaternionLike>(
977
- translation: Vector3Like,
978
- out: T
979
- ): T;
980
-
981
- public static fromTranslation<T extends DualQuaternionLike>(
982
- translation: Vector3Like,
983
- out: T = new DualQuaternion() as T
984
- ): T {
985
- return fromTranslation(translation, out);
915
+ t: Vector3Like,
916
+ out = new DualQuaternion() as unknown as T
917
+ ) {
918
+ return fromTranslation(t, out);
986
919
  }
987
920
 
988
921
  /**
989
- * Creates a dual quaternion from the given quaternion.
990
- * @param quaternion The quaternion.
991
- * @returns The dual quaternion.
992
- */
993
- public static fromRotation(quaternion: QuaternionLike): DualQuaternion;
994
-
995
- /**
996
- * Creates a dual quaternion from the given quaternion.
997
- * @param quaternion The quaternion.
998
- * @param out The dual quaternion to store the result in.
922
+ * Create a dual quaternion from the given quaternion.
923
+ * @param q - The quaternion.
924
+ * @param out - The dual quaternion to store the result in.
999
925
  * @returns The dual quaternion.
1000
926
  */
1001
927
  public static fromRotation<T extends DualQuaternionLike>(
1002
- quaternion: QuaternionLike,
1003
- out: T
1004
- ): T;
1005
-
1006
- public static fromRotation<T extends DualQuaternionLike>(
1007
- quaternion: QuaternionLike,
1008
- out: T = new DualQuaternion() as T
1009
- ): T {
1010
- return fromRotation(quaternion, out);
928
+ q: QuaternionLike,
929
+ out = new DualQuaternion() as unknown as T
930
+ ) {
931
+ return fromRotation(q, out);
1011
932
  }
1012
933
 
1013
934
  /**
1014
- * Creates a dual quaternion from the given four-by-four matrix.
1015
- * @param matrix The matrix.
1016
- * @returns The dual quaternion.
1017
- */
1018
- public static fromMatrix4(matrix: Matrix4Like): DualQuaternion;
1019
-
1020
- /**
1021
- * Creates a dual quaternion from the given four-by-four matrix.
1022
- * @param matrix The matrix.
1023
- * @param out The dual quaternion to store the result in.
935
+ * Create a dual quaternion from the given four-by-four matrix.
936
+ * @param matrix - The matrix.
937
+ * @param out - The dual quaternion to store the result in.
1024
938
  * @returns The dual quaternion.
1025
939
  */
1026
940
  public static fromMatrix4<T extends DualQuaternionLike>(
1027
941
  matrix: Matrix4Like,
1028
- out: T
1029
- ): T;
1030
-
1031
- public static fromMatrix4<T extends DualQuaternionLike>(
1032
- matrix: Matrix4Like,
1033
- out: T = new DualQuaternion() as T
1034
- ): T {
942
+ out = new DualQuaternion() as unknown as T
943
+ ) {
1035
944
  return fromMatrix4(matrix, out);
1036
945
  }
1037
946
 
1038
947
  /**
1039
- * Creates an identity dual quaternion.
948
+ * Create an identity dual quaternion.
1040
949
  * @see [Dual quaternion](https://en.wikipedia.org/wiki/Dual_quaternion)
1041
950
  */
1042
951
  public constructor() {
@@ -1044,485 +953,324 @@ export default class DualQuaternion extends Float32Array {
1044
953
  this[3] = 1;
1045
954
  }
1046
955
 
956
+ /** The first real component of this dual quaternion. */
957
+ public 0: number;
958
+
959
+ /** The second real component of this dual quaternion. */
960
+ public 1: number;
961
+
962
+ /** The third real component of this dual quaternion. */
963
+ public 2: number;
964
+
965
+ /** The fourth real component of this dual quaternion. */
966
+ public 3: number;
967
+
968
+ /** The first dual component of this dual quaternion. */
969
+ public 4: number;
970
+
971
+ /** The second dual component of this dual quaternion. */
972
+ public 5: number;
973
+
974
+ /** The third dual component of this dual quaternion. */
975
+ public 6: number;
976
+
977
+ /** The fourth dual component of this dual quaternion. */
978
+ public 7: number;
979
+
1047
980
  /**
1048
- * Copies the values from another dual quaternion to this one.
1049
- * @param dualQuaternion The dual quaternion to copy.
981
+ * Copy the values from another dual quaternion to this one.
982
+ * @param dualQuaternion - The dual quaternion to copy.
1050
983
  * @returns This dual quaternion.
1051
984
  */
1052
- public copy(dualQuaternion: DualQuaternionLike): this {
985
+ public copy(dualQuaternion: DualQuaternionLike) {
1053
986
  return copy(dualQuaternion, this);
1054
987
  }
1055
988
 
1056
989
  /**
1057
- * Creates a copy of this dual quaternion.
1058
- * @returns The copy.
1059
- */
1060
- public clone(): DualQuaternion;
1061
-
1062
- /**
1063
- * Copies the values from this dual quaternion to another one.
1064
- * @param out The dual quaternion to store the result in.
990
+ * Copy the values from this dual quaternion to another one.
991
+ * @param out - The dual quaternion to store the result in.
1065
992
  * @returns The copy.
1066
993
  */
1067
- public clone<T extends DualQuaternionLike>(out: T): T;
1068
-
1069
994
  public clone<T extends DualQuaternionLike>(
1070
- out: T = new DualQuaternion() as T
1071
- ): T {
995
+ out = new DualQuaternion() as unknown as T
996
+ ) {
1072
997
  return copy(this, out);
1073
998
  }
1074
999
 
1075
1000
  /**
1076
- * Sets this dual quaternion to the identity dual quaternion.
1001
+ * Set this dual quaternion to the identity dual quaternion.
1077
1002
  * @returns The identity dual quaternion.
1078
1003
  */
1079
- public identity(): this {
1004
+ public identity() {
1080
1005
  return identity(this);
1081
1006
  }
1082
1007
 
1083
1008
  /**
1084
- * Gets the real part of this dual quaternion.
1009
+ * Get the real part of this dual quaternion.
1010
+ * @param out - The quaternion to store the result in.
1085
1011
  * @returns The real part.
1086
1012
  */
1087
- public getReal(): Quaternion;
1088
-
1089
- /**
1090
- * Gets the real part of this dual quaternion.
1091
- * @param out The quaternion to store the result in.
1092
- * @returns The real part.
1093
- */
1094
- public getReal<T extends QuaternionLike>(out: T): T;
1095
-
1096
- public getReal<T extends QuaternionLike>(out: T = new Quaternion() as T): T {
1097
- return xetReal(this as unknown as Vector4Like, out as Vector4Like) as T;
1013
+ public getReal<T extends QuaternionLike>(
1014
+ out = new Quaternion() as unknown as T
1015
+ ) {
1016
+ return xetReal(this, out);
1098
1017
  }
1099
1018
 
1100
1019
  /**
1101
- * Sets the real part of this dual quaternion.
1102
- * @param quaternion The quaternion.
1020
+ * Set the real part of this dual quaternion.
1021
+ * @param q - The quaternion.
1103
1022
  */
1104
- public setReal(quaternion: QuaternionLike): void {
1105
- xetReal(quaternion as Vector4Like, this as unknown as Vector4Like);
1023
+ public setReal(q: QuaternionLike) {
1024
+ xetReal(q, this);
1106
1025
  }
1107
1026
 
1108
1027
  /**
1109
- * Gets the dual part of this dual quaternion.
1028
+ * Get the dual part of this dual quaternion.
1029
+ * @param out - The quaternion to store the result in.
1110
1030
  * @returns The dual part.
1111
1031
  */
1112
- public getDual(): Quaternion;
1113
-
1114
- /**
1115
- * Gets the dual part of this dual quaternion.
1116
- * @param out The quaternion to store the result in.
1117
- * @returns The dual part.
1118
- */
1119
- public getDual<T extends QuaternionLike>(out: T): T;
1120
-
1121
- public getDual<T extends QuaternionLike>(out: T = new Quaternion() as T): T {
1032
+ public getDual<T extends QuaternionLike>(
1033
+ out = new Quaternion() as unknown as T
1034
+ ) {
1122
1035
  return getDual(this, out);
1123
1036
  }
1124
1037
 
1125
1038
  /**
1126
- * Sets the real part of this dual quaternion.
1127
- * @param quaternion The quaternion.
1039
+ * Set the real part of this dual quaternion.
1040
+ * @param q - The quaternion.
1128
1041
  */
1129
- public setDual(quaternion: QuaternionLike): void {
1130
- setDual(quaternion, this);
1042
+ public setDual(q: QuaternionLike): void {
1043
+ setDual(q, this);
1131
1044
  }
1132
1045
 
1133
1046
  /**
1134
- * Gets the translation of this normalized dual quaternion.
1047
+ * Get the translation of this normalized dual quaternion.
1048
+ * @param out - The vector to store the result in.
1135
1049
  * @returns The translation.
1136
1050
  */
1137
- public getTranslation(): Vector3;
1138
-
1139
- /**
1140
- * Gets the translation of this normalized dual quaternion.
1141
- * @param out The vector to store the result in.
1142
- * @returns The translation.
1143
- */
1144
- public getTranslation<T extends Vector3Like>(out: T): T;
1145
-
1146
- public getTranslation<T extends Vector3Like>(out: T = new Vector3() as T): T {
1051
+ public getTranslation<T extends Vector3Like>(
1052
+ out = new Vector3() as unknown as T
1053
+ ) {
1147
1054
  return getTranslation(this, out);
1148
1055
  }
1149
1056
 
1150
1057
  /**
1151
- * Translates this dual quaternion by the given vector.
1152
- * @param vector The vector.
1058
+ * Translate this dual quaternion by the given vector.
1059
+ * @param v - The vector.
1060
+ * @param out - The dual quaternion to store the result in.
1153
1061
  * @returns The translated dual quaternion.
1154
1062
  */
1155
- public translate(vector: Vector3Like): DualQuaternion;
1156
-
1157
- /**
1158
- * Translates this dual quaternion by the given vector.
1159
- * @param vector The vector.
1160
- * @param out The dual quaternion to store the result in.
1161
- * @returns The translated dual quaternion.
1162
- */
1163
- public translate<T extends DualQuaternionLike>(
1164
- vector: Vector3Like,
1165
- out: T
1166
- ): T;
1167
-
1168
1063
  public translate<T extends DualQuaternionLike>(
1169
- vector: Vector3Like,
1170
- out: T = new DualQuaternion() as T
1171
- ): T {
1172
- return translate(this, vector, out);
1064
+ v: Vector3Like,
1065
+ out = new DualQuaternion() as unknown as T
1066
+ ) {
1067
+ return translate(this, v, out);
1173
1068
  }
1174
1069
 
1175
1070
  /**
1176
- * Rotates this dual quaternion around the X-axis.
1177
- * @param radians The angle to rotate by in radians.
1178
- * @returns The rotated dual quaternion.
1179
- */
1180
- public rotateX(radians: number): DualQuaternion;
1181
-
1182
- /**
1183
- * Rotates this dual quaternion around the X-axis.
1184
- * @param radians The angle to rotate by in radians.
1185
- * @param out The dual quaternion to store the result in.
1071
+ * Rotate this dual quaternion around the X-axis.
1072
+ * @param r - The angle to rotate by in radians.
1073
+ * @param out - The dual quaternion to store the result in.
1186
1074
  * @returns The rotated dual quaternion.
1187
1075
  */
1188
- public rotateX<T extends DualQuaternionLike>(radians: number, out: T): T;
1189
-
1190
1076
  public rotateX<T extends DualQuaternionLike>(
1191
- radians: number,
1192
- out: T = new DualQuaternion() as T
1193
- ): T {
1194
- return rotateX(this, radians, out);
1077
+ r: number,
1078
+ out = new DualQuaternion() as unknown as T
1079
+ ) {
1080
+ return rotateX(this, r, out);
1195
1081
  }
1196
1082
 
1197
1083
  /**
1198
- * Rotates this dual quaternion around the Y-axis.
1199
- * @param radians The angle to rotate by in radians.
1200
- * @returns The rotated dual quaternion.
1201
- */
1202
- public rotateY(radians: number): DualQuaternion;
1203
-
1204
- /**
1205
- * Rotates this dual quaternion around the Y-axis.
1206
- * @param radians The angle to rotate by in radians.
1207
- * @param out The dual quaternion to store the result in.
1084
+ * Rotate this dual quaternion around the Y-axis.
1085
+ * @param r - The angle to rotate by in radians.
1086
+ * @param out - The dual quaternion to store the result in.
1208
1087
  * @returns The rotated dual quaternion.
1209
1088
  */
1210
- public rotateY<T extends DualQuaternionLike>(radians: number, out: T): T;
1211
-
1212
1089
  public rotateY<T extends DualQuaternionLike>(
1213
- radians: number,
1214
- out: T = new DualQuaternion() as T
1215
- ): T {
1216
- return rotateY(this, radians, out);
1090
+ r: number,
1091
+ out = new DualQuaternion() as unknown as T
1092
+ ) {
1093
+ return rotateY(this, r, out);
1217
1094
  }
1218
1095
 
1219
1096
  /**
1220
- * Rotates this dual quaternion around the Z-axis.
1221
- * @param radians The angle to rotate by in radians.
1097
+ * Rotate this dual quaternion around the Z-axis.
1098
+ * @param r - The angle to rotate by in radians.
1099
+ * @param out - The dual quaternion to store the result in.
1222
1100
  * @returns The rotated dual quaternion.
1223
1101
  */
1224
- public rotateZ(radians: number): DualQuaternion;
1225
-
1226
- /**
1227
- * Rotates this dual quaternion around the Z-axis.
1228
- * @param radians The angle to rotate by in radians.
1229
- * @param out The dual quaternion to store the result in.
1230
- * @returns The rotated dual quaternion.
1231
- */
1232
- public rotateZ<T extends DualQuaternionLike>(radians: number, out: T): T;
1233
-
1234
1102
  public rotateZ<T extends DualQuaternionLike>(
1235
- radians: number,
1236
- out: T = new DualQuaternion() as T
1237
- ): T {
1238
- return rotateZ(this, radians, out);
1103
+ r: number,
1104
+ out = new DualQuaternion() as unknown as T
1105
+ ) {
1106
+ return rotateZ(this, r, out);
1239
1107
  }
1240
1108
 
1241
1109
  /**
1242
- * Multiplies this dual quaternion by a quaternion.
1243
- * @param quaternion The quaternion.
1244
- * @returns The rotated dual quaternion.
1245
- * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
1246
- */
1247
- public rotateByQuaternionAppend(quaternion: QuaternionLike): DualQuaternion;
1248
-
1249
- /**
1250
- * Multiplies this dual quaternion by a quaternion.
1251
- * @param quaternion The quaternion.
1252
- * @param out The dual quaternion to store the result in.
1110
+ * Multiply this dual quaternion by a quaternion.
1111
+ * @param q - The quaternion.
1112
+ * @param out - The dual quaternion to store the result in.
1253
1113
  * @returns The rotated dual quaternion.
1254
1114
  * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
1255
1115
  */
1256
1116
  public rotateByQuaternionAppend<T extends DualQuaternionLike>(
1257
- quaternion: QuaternionLike,
1258
- out: T
1259
- ): T;
1260
-
1261
- public rotateByQuaternionAppend<T extends DualQuaternionLike>(
1262
- quaternion: QuaternionLike,
1263
- out: T = new DualQuaternion() as T
1264
- ): T {
1265
- return rotateByQuaternionAppend(this, quaternion, out);
1117
+ q: QuaternionLike,
1118
+ out = new DualQuaternion() as unknown as T
1119
+ ) {
1120
+ return rotateByQuaternionAppend(this, q, out);
1266
1121
  }
1267
1122
 
1268
1123
  /**
1269
- * Multiplies a quaternion by this dual quaternion.
1270
- * @param quaternion The quaternion.
1271
- * @returns The rotated dual quaternion.
1272
- * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
1273
- */
1274
- public rotateByQuaternionPrepend(quaternion: QuaternionLike): DualQuaternion;
1275
-
1276
- /**
1277
- * Multiplies a quaternion by this dual quaternion.
1278
- * @param quaternion The quaternion.
1279
- * @param out The dual quaternion to store the result in.
1124
+ * Multiply a quaternion by this dual quaternion.
1125
+ * @param q - The quaternion.
1126
+ * @param out - The dual quaternion to store the result in.
1280
1127
  * @returns The rotated dual quaternion.
1281
1128
  * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
1282
1129
  */
1283
1130
  public rotateByQuaternionPrepend<T extends DualQuaternionLike>(
1284
- quaternion: QuaternionLike,
1285
- out: T
1286
- ): T;
1287
-
1288
- public rotateByQuaternionPrepend<T extends DualQuaternionLike>(
1289
- quaternion: QuaternionLike,
1290
- out: T = new DualQuaternion() as T
1291
- ): T {
1292
- return rotateByQuaternionPrepend(quaternion, this, out);
1131
+ q: QuaternionLike,
1132
+ out = new DualQuaternion() as unknown as T
1133
+ ) {
1134
+ return rotateByQuaternionPrepend(q, this, out);
1293
1135
  }
1294
1136
 
1295
1137
  /**
1296
- * Rotates this dual quaternion around an axis.
1297
- * @param axis The axis.
1298
- * @param radians The angle of the rotation in radians.
1138
+ * Rotate this dual quaternion around an axis.
1139
+ * @param axis - The axis.
1140
+ * @param r - The angle of the rotation in radians.
1141
+ * @param out - The dual quaternion to store the result in.
1299
1142
  * @returns A normalized dual quaternion.
1300
1143
  */
1301
- public rotateAroundAxis(axis: Vector3Like, radians: number): DualQuaternion;
1302
-
1303
- /**
1304
- * Rotates this dual quaternion around an axis.
1305
- * @param axis The axis.
1306
- * @param radians The angle of the rotation in radians.
1307
- * @param out The dual quaternion to store the result in.
1308
- * @returns A normalized dual quaternion.
1309
- */
1310
- public rotateAroundAxis<T extends DualQuaternionLike>(
1311
- axis: Vector3Like,
1312
- radians: number,
1313
- out: T
1314
- ): T;
1315
-
1316
1144
  public rotateAroundAxis<T extends DualQuaternionLike>(
1317
1145
  axis: Vector3Like,
1318
- radians: number,
1319
- out: T = new DualQuaternion() as T
1320
- ): T {
1321
- return rotateAroundAxis(this, axis, radians, out);
1146
+ r: number,
1147
+ out = new DualQuaternion() as unknown as T
1148
+ ) {
1149
+ return rotateAroundAxis(this, axis, r, out);
1322
1150
  }
1323
1151
 
1324
1152
  /**
1325
- * Adds another dual quaternion to this one.
1326
- * @param dualQuaternion The other dual quaternion.
1327
- * @returns The sum.
1328
- */
1329
- public add(dualQuaternion: DualQuaternionLike): DualQuaternion;
1330
-
1331
- /**
1332
- * Adds another dual quaternion to this one.
1333
- * @param dualQuaternion The other dual quaternion.
1334
- * @param out The dual quaternion to store the result in.
1153
+ * Add another dual quaternion to this one.
1154
+ * @param dq - The other dual quaternion.
1155
+ * @param out - The dual quaternion to store the result in.
1335
1156
  * @returns The sum.
1336
1157
  */
1337
1158
  public add<T extends DualQuaternionLike>(
1338
- dualQuaternion: DualQuaternionLike,
1339
- out: T
1340
- ): T;
1341
-
1342
- public add<T extends DualQuaternionLike>(
1343
- dualQuaternion: DualQuaternionLike,
1344
- out: T = new DualQuaternion() as T
1345
- ): T {
1346
- return add(this, dualQuaternion, out);
1159
+ dq: DualQuaternionLike,
1160
+ out = new DualQuaternion() as unknown as T
1161
+ ) {
1162
+ return add(this, dq, out);
1347
1163
  }
1348
1164
 
1349
1165
  /**
1350
- * Multiplies this dual quaternion by another one.
1351
- * @param dualQuaternion The other dual quaternion.
1352
- * @returns The product.
1353
- */
1354
- public multiply(dualQuaternion: DualQuaternionLike): DualQuaternion;
1355
-
1356
- /**
1357
- * Multiplies this dual quaternion by another one.
1358
- * @param dualQuaternion The other dual quaternion.
1359
- * @param out The dual quaternion to store the result in.
1166
+ * Multiply this dual quaternion by another one.
1167
+ * @param dq - The other dual quaternion.
1168
+ * @param out - The dual quaternion to store the result in.
1360
1169
  * @returns The product.
1361
1170
  */
1362
1171
  public multiply<T extends DualQuaternionLike>(
1363
- dualQuaternion: DualQuaternionLike,
1364
- out: T
1365
- ): T;
1366
-
1367
- public multiply<T extends DualQuaternionLike>(
1368
- dualQuaternion: DualQuaternionLike,
1369
- out: T = new DualQuaternion() as T
1370
- ): T {
1371
- return multiply(this, dualQuaternion, out);
1172
+ dq: DualQuaternionLike,
1173
+ out = new DualQuaternion() as unknown as T
1174
+ ) {
1175
+ return multiply(this, dq, out);
1372
1176
  }
1373
1177
 
1374
1178
  /**
1375
- * Multiplies this dual quaternion by a scalar.
1376
- * @param scalar The scalar.
1377
- * @returns The product.
1378
- */
1379
- public scale(scalar: number): DualQuaternion;
1380
-
1381
- /**
1382
- * Multiplies this dual quaternion by a scalar.
1383
- * @param scalar The scalar.
1384
- * @param out The dual quaternion to store the result in.
1179
+ * Multiply this dual quaternion by a scalar.
1180
+ * @param s - The scalar.
1181
+ * @param out - The dual quaternion to store the result in.
1385
1182
  * @returns The product.
1386
1183
  */
1387
- public scale<T extends DualQuaternionLike>(scalar: number, out: T): T;
1388
-
1389
1184
  public scale<T extends DualQuaternionLike>(
1390
- scalar: number,
1391
- out: T = new DualQuaternion() as T
1392
- ): T {
1393
- return scale(this, scalar, out);
1185
+ s: number,
1186
+ out = new DualQuaternion() as unknown as T
1187
+ ) {
1188
+ return scale(this, s, out);
1394
1189
  }
1395
1190
 
1396
1191
  /**
1397
- * Calculates the dot product of this and another dual quaternion.
1398
- * @param dualQuaternion The other dual quaternion.
1192
+ * Calculate the dot product of this and another dual quaternion.
1193
+ * @param dq - The other dual quaternion.
1399
1194
  * @returns The dot product.
1400
1195
  * @see [Dot product](https://en.wikipedia.org/wiki/Dot_product)
1401
1196
  */
1402
- public dot(dualQuaternion: DualQuaternionLike): number {
1403
- return dot(
1404
- this as unknown as Vector4Like,
1405
- dualQuaternion as unknown as Vector4Like
1406
- );
1197
+ public dot(dq: DualQuaternionLike) {
1198
+ return dot(this, dq);
1407
1199
  }
1408
1200
 
1409
1201
  /**
1410
- * Performs a linear interpolation between this and another dual quaternion.
1411
- * @param dualQuaternion The other dual quaternion.
1412
- * @param t The interpolation amount in `[0,1]`.
1202
+ * Perform a linear interpolation between this and another dual quaternion.
1203
+ * @param dq - The other dual quaternion.
1204
+ * @param t - The interpolation amount in `[0,1]`.
1205
+ * @param out - The dual quaternion to store the result in.
1413
1206
  * @returns The interpolated value.
1414
1207
  */
1415
- public lerp(dualQuaternion: DualQuaternionLike, t: number): DualQuaternion;
1416
-
1417
- /**
1418
- * Performs a linear interpolation between this and another dual quaternion.
1419
- * @param dualQuaternion The other dual quaternion.
1420
- * @param t The interpolation amount in `[0,1]`.
1421
- * @param out The dual quaternion to store the result in.
1422
- * @returns The interpolated value.
1423
- */
1424
- public lerp<T extends DualQuaternionLike>(
1425
- dualQuaternion: DualQuaternionLike,
1426
- t: number,
1427
- out: T
1428
- ): T;
1429
-
1430
1208
  public lerp<T extends DualQuaternionLike>(
1431
- dualQuaternion: DualQuaternionLike,
1209
+ dq: DualQuaternionLike,
1432
1210
  t: number,
1433
- out: T = new DualQuaternion() as T
1434
- ): T {
1435
- return lerp(this, dualQuaternion, t, out);
1211
+ out = new DualQuaternion() as unknown as T
1212
+ ) {
1213
+ return lerp(this, dq, t, out);
1436
1214
  }
1437
1215
 
1438
1216
  /**
1439
- * Calculates the inverse of this dual quaternion. If this dual quaternion
1440
- * is normalized, the conjugate is equivalent and faster to calculate.
1441
- * @returns The inverse.
1442
- */
1443
- public invert(): DualQuaternion;
1444
-
1445
- /**
1446
- * Calculates the inverse of this dual quaternion. If this dual quaternion
1447
- * is normalized, the conjugate is equivalent and faster to calculate.
1448
- * @param out The dual quaternion to store the result in.
1217
+ * Calculate the inverse of this dual quaternion. If this dual quaternion is normalized, the conjugate is equivalent and faster to calculate.
1218
+ * @param out - The dual quaternion to store the result in.
1449
1219
  * @returns The inverse.
1450
1220
  */
1451
- public invert<T extends DualQuaternionLike>(out: T): T;
1452
-
1453
1221
  public invert<T extends DualQuaternionLike>(
1454
- out: T = new DualQuaternion() as T
1455
- ): T {
1222
+ out = new DualQuaternion() as unknown as T
1223
+ ) {
1456
1224
  return invert(this, out);
1457
1225
  }
1458
1226
 
1459
1227
  /**
1460
- * Calculates the conjugate of this dual quaternion. If this dual
1461
- * quaternion is normalized, this is equivalent to its inverse and faster
1462
- * to calculate.
1463
- * @returns The conjugate.
1464
- */
1465
- public conjugate(): DualQuaternion;
1466
-
1467
- /**
1468
- * Calculates the conjugate of this dual quaternion. If this dual
1469
- * quaternion is normalized, this is equivalent to its inverse and faster
1470
- * to calculate.
1471
- * @param out The dual quaternion to store the result in.
1228
+ * Calculate the conjugate of this dual quaternion. If this dual quaternion is normalized, this is equivalent to its inverse and faster to calculate.
1229
+ * @param out - The dual quaternion to store the result in.
1472
1230
  * @returns The conjugate.
1473
1231
  */
1474
- public conjugate<T extends DualQuaternionLike>(out: T): T;
1475
-
1476
1232
  public conjugate<T extends DualQuaternionLike>(
1477
- out: T = new DualQuaternion() as T
1478
- ): T {
1233
+ out = new DualQuaternion() as unknown as T
1234
+ ) {
1479
1235
  return conjugate(this, out);
1480
1236
  }
1481
1237
 
1482
- /** The magnitude (length) of this dual quaternion. */
1483
- public get magnitude(): number {
1484
- return getMagnitude(this as unknown as Vector4Like);
1238
+ /** Get the magnitude (length) of this dual quaternion. */
1239
+ public get magnitude() {
1240
+ return getMagnitude(this);
1485
1241
  }
1486
1242
 
1487
- /** The squared magnitude (length) of this dual quaternion. */
1488
- public get squaredMagnitude(): number {
1489
- return getSquaredMagnitude(this as unknown as Vector4Like);
1243
+ /** Get the squared magnitude (length) of this dual quaternion. */
1244
+ public get squaredMagnitude() {
1245
+ return getSquaredMagnitude(this);
1490
1246
  }
1491
1247
 
1492
1248
  /**
1493
- * Normalizes this dual quaternion.
1494
- * @returns The normalized dual quaternion.
1495
- */
1496
- public normalize(): DualQuaternion;
1497
-
1498
- /**
1499
- * Normalizes this dual quaternion.
1500
- * @param out The dual quaternion to store the result in.
1249
+ * Normalize this dual quaternion.
1250
+ * @param out - The dual quaternion to store the result in.
1501
1251
  * @returns The normalized dual quaternion.
1502
1252
  */
1503
- public normalize<T extends DualQuaternionLike>(out: T): T;
1504
-
1505
1253
  public normalize<T extends DualQuaternionLike>(
1506
- out: T = new DualQuaternion() as T
1507
- ): T {
1254
+ out = new DualQuaternion() as unknown as T
1255
+ ) {
1508
1256
  return normalize(this, out);
1509
1257
  }
1510
1258
 
1511
1259
  /**
1512
- * Determines whether this dual quaternion is exactly equivalent to another.
1513
- * @param dualQuaternion The other dual quaternion.
1514
- * @returns Whether the dual quaternions are equivalent.
1260
+ * Determine whether or not this dual quaternion is exactly equivalent to another.
1261
+ * @param dq - The other dual quaternion.
1262
+ * @returns Whether or not the dual quaternions are equivalent.
1515
1263
  */
1516
- public exactEquals(dualQuaternion: DualQuaternionLike): boolean {
1517
- return exactEquals(this, dualQuaternion);
1264
+ public exactEquals(dq: DualQuaternionLike) {
1265
+ return exactEquals(this, dq);
1518
1266
  }
1519
1267
 
1520
1268
  /**
1521
- * Determines whether this dual quaternion is roughly equivalent to another.
1522
- * @param dualQuaternion The other dual quaternion.
1523
- * @returns Whether the dual quaternions are equivalent.
1269
+ * Determine whether or not this dual quaternion is roughly equivalent to another.
1270
+ * @param dq - The other dual quaternion.
1271
+ * @returns Whether or not the dual quaternions are equivalent.
1524
1272
  */
1525
- public equals(dualQuaternion: DualQuaternionLike): boolean {
1526
- return equals(this, dualQuaternion);
1273
+ public equals(dq: DualQuaternionLike) {
1274
+ return equals(this, dq);
1527
1275
  }
1528
1276
  }