@lakuna/umath 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/algorithms/combinations.js +1 -1
- package/dist/algorithms/combinations.js.map +1 -1
- package/dist/algorithms/degreesToRadians.js +1 -1
- package/dist/algorithms/degreesToRadians.js.map +1 -1
- package/dist/algorithms/factorial.js.map +1 -1
- package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
- package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
- package/dist/algorithms/hypergeometricPmf.js +1 -1
- package/dist/algorithms/hypergeometricPmf.js.map +1 -1
- package/dist/algorithms/permutations.js +1 -1
- package/dist/algorithms/permutations.js.map +1 -1
- package/dist/algorithms/radiansToDegrees.js +1 -1
- package/dist/algorithms/radiansToDegrees.js.map +1 -1
- package/dist/algorithms/summation.d.ts.map +1 -1
- package/dist/algorithms/summation.js.map +1 -1
- package/dist/index.d.ts +33 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -27
- package/dist/index.js.map +1 -1
- package/dist/linalg/DualQuaternion.d.ts +3 -3
- package/dist/linalg/DualQuaternion.d.ts.map +1 -1
- package/dist/linalg/DualQuaternion.js +60 -28
- package/dist/linalg/DualQuaternion.js.map +1 -1
- package/dist/linalg/Matrix2.d.ts +3 -8
- package/dist/linalg/Matrix2.d.ts.map +1 -1
- package/dist/linalg/Matrix2.js +9 -12
- package/dist/linalg/Matrix2.js.map +1 -1
- package/dist/linalg/Matrix3.d.ts +5 -15
- package/dist/linalg/Matrix3.d.ts.map +1 -1
- package/dist/linalg/Matrix3.js +23 -23
- package/dist/linalg/Matrix3.js.map +1 -1
- package/dist/linalg/Matrix4.d.ts +8 -5
- package/dist/linalg/Matrix4.d.ts.map +1 -1
- package/dist/linalg/Matrix4.js +57 -40
- package/dist/linalg/Matrix4.js.map +1 -1
- package/dist/linalg/Quaternion.d.ts +3 -3
- package/dist/linalg/Quaternion.d.ts.map +1 -1
- package/dist/linalg/Quaternion.js +16 -9
- package/dist/linalg/Quaternion.js.map +1 -1
- package/dist/linalg/SlowMatrix.d.ts +1 -1
- package/dist/linalg/SlowMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowMatrix.js +12 -6
- package/dist/linalg/SlowMatrix.js.map +1 -1
- package/dist/linalg/SlowSquareMatrix.d.ts +2 -2
- package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowSquareMatrix.js +9 -5
- package/dist/linalg/SlowSquareMatrix.js.map +1 -1
- package/dist/linalg/SquareMatrix.d.ts +1 -1
- package/dist/linalg/SquareMatrix.d.ts.map +1 -1
- package/dist/linalg/Vector2.d.ts +5 -5
- package/dist/linalg/Vector2.d.ts.map +1 -1
- package/dist/linalg/Vector2.js +5 -6
- package/dist/linalg/Vector2.js.map +1 -1
- package/dist/linalg/Vector3.d.ts +4 -4
- package/dist/linalg/Vector3.d.ts.map +1 -1
- package/dist/linalg/Vector3.js +7 -9
- package/dist/linalg/Vector3.js.map +1 -1
- package/dist/linalg/Vector4.d.ts +3 -3
- package/dist/linalg/Vector4.d.ts.map +1 -1
- package/dist/linalg/Vector4.js +6 -9
- package/dist/linalg/Vector4.js.map +1 -1
- package/dist/types/AxisAngle.d.ts +1 -1
- package/dist/types/AxisAngle.d.ts.map +1 -1
- package/dist/utility/BigNumber.d.ts +1 -1
- package/dist/utility/BigNumber.d.ts.map +1 -1
- package/dist/utility/BigNumber.js +3 -2
- package/dist/utility/BigNumber.js.map +1 -1
- package/package.json +37 -6
- package/src/algorithms/combinations.ts +1 -1
- package/src/algorithms/degreesToRadians.ts +1 -1
- package/src/algorithms/factorial.ts +2 -2
- package/src/algorithms/greatestCommonDivisor.ts +10 -3
- package/src/algorithms/hypergeometricPmf.ts +8 -3
- package/src/algorithms/permutations.ts +1 -1
- package/src/algorithms/radiansToDegrees.ts +1 -1
- package/src/algorithms/summation.ts +5 -1
- package/src/index.ts +36 -33
- package/src/linalg/DualQuaternion.ts +409 -116
- package/src/linalg/Matrix.ts +1 -1
- package/src/linalg/Matrix2.ts +159 -63
- package/src/linalg/Matrix3.ts +300 -107
- package/src/linalg/Matrix4.ts +775 -206
- package/src/linalg/Quaternion.ts +311 -80
- package/src/linalg/SlowMatrix.ts +17 -9
- package/src/linalg/SlowSquareMatrix.ts +24 -13
- package/src/linalg/SquareMatrix.ts +1 -1
- package/src/linalg/Vector2.ts +361 -223
- package/src/linalg/Vector3.ts +318 -89
- package/src/linalg/Vector4.ts +177 -53
- package/src/types/AxisAngle.ts +1 -1
- package/src/utility/BigNumber.ts +18 -7
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
getRotation as getMatrix4Rotation,
|
|
3
|
+
getTranslation as getMatrix4Translation,
|
|
4
|
+
type Matrix4Like
|
|
5
|
+
} from "#Matrix4";
|
|
6
|
+
import Quaternion, {
|
|
7
|
+
type QuaternionLike,
|
|
8
|
+
rotateX as quaternionRotateX,
|
|
9
|
+
rotateY as quaternionRotateY,
|
|
10
|
+
rotateZ as quaternionRotateZ
|
|
11
|
+
} from "#Quaternion";
|
|
12
|
+
import Vector3, { type Vector3Like } from "#Vector3";
|
|
13
|
+
import {
|
|
14
|
+
copy as xetReal,
|
|
15
|
+
dot,
|
|
16
|
+
getMagnitude,
|
|
17
|
+
getSquaredMagnitude,
|
|
18
|
+
type Vector4Like
|
|
19
|
+
} from "#Vector4";
|
|
20
|
+
import epsilon from "#epsilon";
|
|
6
21
|
|
|
7
22
|
/** A complex number that is commonly used to describe transformations. */
|
|
8
|
-
export type DualQuaternionLike =
|
|
23
|
+
export type DualQuaternionLike =
|
|
24
|
+
| DualQuaternion
|
|
25
|
+
| [number, number, number, number, number, number, number, number];
|
|
9
26
|
|
|
10
27
|
/**
|
|
11
28
|
* Creates a dual quaternion with the given values.
|
|
@@ -20,7 +37,17 @@ export type DualQuaternionLike = DualQuaternion | [number, number, number, numbe
|
|
|
20
37
|
* @param out The dual quaternion to store the result in.
|
|
21
38
|
* @returns A new dual quaternion.
|
|
22
39
|
*/
|
|
23
|
-
export function fromValues<T extends DualQuaternionLike>(
|
|
40
|
+
export function fromValues<T extends DualQuaternionLike>(
|
|
41
|
+
x1: number,
|
|
42
|
+
y1: number,
|
|
43
|
+
z1: number,
|
|
44
|
+
w1: number,
|
|
45
|
+
x2: number,
|
|
46
|
+
y2: number,
|
|
47
|
+
z2: number,
|
|
48
|
+
w2: number,
|
|
49
|
+
out: T
|
|
50
|
+
): T {
|
|
24
51
|
out[0] = x1;
|
|
25
52
|
out[1] = y1;
|
|
26
53
|
out[2] = z1;
|
|
@@ -38,7 +65,10 @@ export function fromValues<T extends DualQuaternionLike>(x1: number, y1: number,
|
|
|
38
65
|
* @param out The dual quaternion to store the result in.
|
|
39
66
|
* @returns The copy.
|
|
40
67
|
*/
|
|
41
|
-
export function copy<T extends DualQuaternionLike>(
|
|
68
|
+
export function copy<T extends DualQuaternionLike>(
|
|
69
|
+
dualQuaternion: DualQuaternionLike,
|
|
70
|
+
out: T
|
|
71
|
+
): T {
|
|
42
72
|
out[0] = dualQuaternion[0];
|
|
43
73
|
out[1] = dualQuaternion[1];
|
|
44
74
|
out[2] = dualQuaternion[2];
|
|
@@ -57,12 +87,16 @@ export function copy<T extends DualQuaternionLike>(dualQuaternion: DualQuaternio
|
|
|
57
87
|
* @param out The dual quaternion to store the result in.
|
|
58
88
|
* @returns The dual quaternion.
|
|
59
89
|
*/
|
|
60
|
-
export function fromRotationTranslation<T extends DualQuaternionLike>(
|
|
90
|
+
export function fromRotationTranslation<T extends DualQuaternionLike>(
|
|
91
|
+
quaternion: QuaternionLike,
|
|
92
|
+
translation: Vector3Like,
|
|
93
|
+
out: T
|
|
94
|
+
): T {
|
|
61
95
|
const x: number = quaternion[0];
|
|
62
96
|
const y: number = quaternion[1];
|
|
63
97
|
const z: number = quaternion[2];
|
|
64
98
|
const w: number = quaternion[3];
|
|
65
|
-
|
|
99
|
+
|
|
66
100
|
const ax: number = translation[0] * 0.5;
|
|
67
101
|
const ay: number = translation[1] * 0.5;
|
|
68
102
|
const az: number = translation[2] * 0.5;
|
|
@@ -84,7 +118,10 @@ export function fromRotationTranslation<T extends DualQuaternionLike>(quaternion
|
|
|
84
118
|
* @param out The dual quaternion to store the result in.
|
|
85
119
|
* @returns The dual quaternion.
|
|
86
120
|
*/
|
|
87
|
-
export function fromTranslation<T extends DualQuaternionLike>(
|
|
121
|
+
export function fromTranslation<T extends DualQuaternionLike>(
|
|
122
|
+
translation: Vector3Like,
|
|
123
|
+
out: T
|
|
124
|
+
): T {
|
|
88
125
|
out[0] = 0;
|
|
89
126
|
out[1] = 0;
|
|
90
127
|
out[2] = 0;
|
|
@@ -102,7 +139,10 @@ export function fromTranslation<T extends DualQuaternionLike>(translation: Vecto
|
|
|
102
139
|
* @param out The dual quaternion to store the result in.
|
|
103
140
|
* @returns The dual quaternion.
|
|
104
141
|
*/
|
|
105
|
-
export function fromRotation<T extends DualQuaternionLike>(
|
|
142
|
+
export function fromRotation<T extends DualQuaternionLike>(
|
|
143
|
+
quaternion: QuaternionLike,
|
|
144
|
+
out: T
|
|
145
|
+
): T {
|
|
106
146
|
out[0] = quaternion[0];
|
|
107
147
|
out[1] = quaternion[1];
|
|
108
148
|
out[2] = quaternion[2];
|
|
@@ -126,8 +166,15 @@ const translation: Vector3Like = new Float32Array(4) as Vector3Like;
|
|
|
126
166
|
* @param out The dual quaternion to store the result in.
|
|
127
167
|
* @returns The dual quaternion.
|
|
128
168
|
*/
|
|
129
|
-
export function fromMatrix4<T extends DualQuaternionLike>(
|
|
130
|
-
|
|
169
|
+
export function fromMatrix4<T extends DualQuaternionLike>(
|
|
170
|
+
matrix: Matrix4Like,
|
|
171
|
+
out: T
|
|
172
|
+
): T {
|
|
173
|
+
return fromRotationTranslation(
|
|
174
|
+
getMatrix4Rotation(matrix, rotation),
|
|
175
|
+
getMatrix4Translation(matrix, translation),
|
|
176
|
+
out
|
|
177
|
+
);
|
|
131
178
|
}
|
|
132
179
|
|
|
133
180
|
/**
|
|
@@ -153,7 +200,10 @@ export function identity<T extends DualQuaternionLike>(out: T): T {
|
|
|
153
200
|
* @param out The quaternion to store the result in.
|
|
154
201
|
* @returns The dual part.
|
|
155
202
|
*/
|
|
156
|
-
export function getDual<T extends QuaternionLike>(
|
|
203
|
+
export function getDual<T extends QuaternionLike>(
|
|
204
|
+
dualQuaternion: DualQuaternionLike,
|
|
205
|
+
out: T
|
|
206
|
+
): T {
|
|
157
207
|
out[0] = dualQuaternion[4];
|
|
158
208
|
out[1] = dualQuaternion[5];
|
|
159
209
|
out[2] = dualQuaternion[6];
|
|
@@ -167,7 +217,10 @@ export function getDual<T extends QuaternionLike>(dualQuaternion: DualQuaternion
|
|
|
167
217
|
* @param out The dual quaternion to store the result in.
|
|
168
218
|
* @returns The dual quaternion.
|
|
169
219
|
*/
|
|
170
|
-
export function setDual<T extends DualQuaternionLike>(
|
|
220
|
+
export function setDual<T extends DualQuaternionLike>(
|
|
221
|
+
quaternion: QuaternionLike,
|
|
222
|
+
out: T
|
|
223
|
+
): T {
|
|
171
224
|
out[4] = quaternion[0];
|
|
172
225
|
out[5] = quaternion[1];
|
|
173
226
|
out[6] = quaternion[2];
|
|
@@ -181,7 +234,10 @@ export function setDual<T extends DualQuaternionLike>(quaternion: QuaternionLike
|
|
|
181
234
|
* @param out The vector to store the result in.
|
|
182
235
|
* @returns The translation.
|
|
183
236
|
*/
|
|
184
|
-
export function getTranslation<T extends Vector3Like>(
|
|
237
|
+
export function getTranslation<T extends Vector3Like>(
|
|
238
|
+
dualQuaternion: DualQuaternionLike,
|
|
239
|
+
out: T
|
|
240
|
+
): T {
|
|
185
241
|
const ax: number = dualQuaternion[4];
|
|
186
242
|
const ay: number = dualQuaternion[5];
|
|
187
243
|
const az: number = dualQuaternion[6];
|
|
@@ -204,7 +260,11 @@ export function getTranslation<T extends Vector3Like>(dualQuaternion: DualQuater
|
|
|
204
260
|
* @param out The dual quaternion to store the result in.
|
|
205
261
|
* @returns The translated dual quaternion.
|
|
206
262
|
*/
|
|
207
|
-
export function translate<T extends DualQuaternionLike>(
|
|
263
|
+
export function translate<T extends DualQuaternionLike>(
|
|
264
|
+
dualQuaternion: DualQuaternionLike,
|
|
265
|
+
vector: Vector3Like,
|
|
266
|
+
out: T
|
|
267
|
+
): T {
|
|
208
268
|
const ax1: number = dualQuaternion[0];
|
|
209
269
|
const ay1: number = dualQuaternion[1];
|
|
210
270
|
const az1: number = dualQuaternion[2];
|
|
@@ -237,7 +297,11 @@ export function translate<T extends DualQuaternionLike>(dualQuaternion: DualQuat
|
|
|
237
297
|
* @param out The dual quaternion to store the result in.
|
|
238
298
|
* @returns The rotated dual quaternion.
|
|
239
299
|
*/
|
|
240
|
-
export function rotateX<T extends DualQuaternionLike>(
|
|
300
|
+
export function rotateX<T extends DualQuaternionLike>(
|
|
301
|
+
dualQuaternion: DualQuaternionLike,
|
|
302
|
+
radians: number,
|
|
303
|
+
out: T
|
|
304
|
+
): T {
|
|
241
305
|
let bx = -dualQuaternion[0];
|
|
242
306
|
let by = -dualQuaternion[1];
|
|
243
307
|
let bz = -dualQuaternion[2];
|
|
@@ -253,7 +317,11 @@ export function rotateX<T extends DualQuaternionLike>(dualQuaternion: DualQuater
|
|
|
253
317
|
const az1 = az * bw + aw * bz + ax * by - ay * bx;
|
|
254
318
|
const aw1 = aw * bw - ax * bx - ay * by - az * bz;
|
|
255
319
|
|
|
256
|
-
quaternionRotateX(
|
|
320
|
+
quaternionRotateX(
|
|
321
|
+
dualQuaternion as unknown as QuaternionLike,
|
|
322
|
+
radians,
|
|
323
|
+
out as unknown as QuaternionLike
|
|
324
|
+
);
|
|
257
325
|
|
|
258
326
|
bx = out[0];
|
|
259
327
|
by = out[1];
|
|
@@ -274,7 +342,11 @@ export function rotateX<T extends DualQuaternionLike>(dualQuaternion: DualQuater
|
|
|
274
342
|
* @param out The dual quaternion to store the result in.
|
|
275
343
|
* @returns The rotated dual quaternion.
|
|
276
344
|
*/
|
|
277
|
-
export function rotateY<T extends DualQuaternionLike>(
|
|
345
|
+
export function rotateY<T extends DualQuaternionLike>(
|
|
346
|
+
dualQuaternion: DualQuaternionLike,
|
|
347
|
+
radians: number,
|
|
348
|
+
out: T
|
|
349
|
+
): T {
|
|
278
350
|
let bx: number = -dualQuaternion[0];
|
|
279
351
|
let by: number = -dualQuaternion[1];
|
|
280
352
|
let bz: number = -dualQuaternion[2];
|
|
@@ -290,7 +362,11 @@ export function rotateY<T extends DualQuaternionLike>(dualQuaternion: DualQuater
|
|
|
290
362
|
const az1: number = az * bw + aw * bz + ax * by - ay * bx;
|
|
291
363
|
const aw1: number = aw * bw - ax * bx - ay * by - az * bz;
|
|
292
364
|
|
|
293
|
-
quaternionRotateY(
|
|
365
|
+
quaternionRotateY(
|
|
366
|
+
dualQuaternion as unknown as QuaternionLike,
|
|
367
|
+
radians,
|
|
368
|
+
out as unknown as QuaternionLike
|
|
369
|
+
);
|
|
294
370
|
|
|
295
371
|
bx = out[0];
|
|
296
372
|
by = out[1];
|
|
@@ -311,7 +387,11 @@ export function rotateY<T extends DualQuaternionLike>(dualQuaternion: DualQuater
|
|
|
311
387
|
* @param out The dual quaternion to store the result in.
|
|
312
388
|
* @returns The rotated dual quaternion.
|
|
313
389
|
*/
|
|
314
|
-
export function rotateZ<T extends DualQuaternionLike>(
|
|
390
|
+
export function rotateZ<T extends DualQuaternionLike>(
|
|
391
|
+
dualQuaternion: DualQuaternionLike,
|
|
392
|
+
radians: number,
|
|
393
|
+
out: T
|
|
394
|
+
): T {
|
|
315
395
|
let bx: number = -dualQuaternion[0];
|
|
316
396
|
let by: number = -dualQuaternion[1];
|
|
317
397
|
let bz: number = -dualQuaternion[2];
|
|
@@ -327,7 +407,11 @@ export function rotateZ<T extends DualQuaternionLike>(dualQuaternion: DualQuater
|
|
|
327
407
|
const az1: number = az * bw + aw * bz + ax * by - ay * bx;
|
|
328
408
|
const aw1: number = aw * bw - ax * bx - ay * by - az * bz;
|
|
329
409
|
|
|
330
|
-
quaternionRotateZ(
|
|
410
|
+
quaternionRotateZ(
|
|
411
|
+
dualQuaternion as unknown as QuaternionLike,
|
|
412
|
+
radians,
|
|
413
|
+
out as unknown as QuaternionLike
|
|
414
|
+
);
|
|
331
415
|
|
|
332
416
|
bx = out[0];
|
|
333
417
|
by = out[1];
|
|
@@ -348,7 +432,11 @@ export function rotateZ<T extends DualQuaternionLike>(dualQuaternion: DualQuater
|
|
|
348
432
|
* @param out The dual quaternion to store the result in.
|
|
349
433
|
* @returns The rotated dual quaternion.
|
|
350
434
|
*/
|
|
351
|
-
export function rotateByQuaternionAppend<T extends DualQuaternionLike>(
|
|
435
|
+
export function rotateByQuaternionAppend<T extends DualQuaternionLike>(
|
|
436
|
+
dualQuaternion: DualQuaternionLike,
|
|
437
|
+
quaternion: QuaternionLike,
|
|
438
|
+
out: T
|
|
439
|
+
): T {
|
|
352
440
|
const qx: number = quaternion[0];
|
|
353
441
|
const qy: number = quaternion[1];
|
|
354
442
|
const qz: number = quaternion[2];
|
|
@@ -383,7 +471,11 @@ export function rotateByQuaternionAppend<T extends DualQuaternionLike>(dualQuate
|
|
|
383
471
|
* @param out The dual quaternion to store the result in.
|
|
384
472
|
* @returns The rotated dual quaternion.
|
|
385
473
|
*/
|
|
386
|
-
export function rotateByQuaternionPrepend<T extends DualQuaternionLike>(
|
|
474
|
+
export function rotateByQuaternionPrepend<T extends DualQuaternionLike>(
|
|
475
|
+
quaternion: QuaternionLike,
|
|
476
|
+
dualQuaternion: DualQuaternionLike,
|
|
477
|
+
out: T
|
|
478
|
+
): T {
|
|
387
479
|
const qx: number = quaternion[0];
|
|
388
480
|
const qy: number = quaternion[1];
|
|
389
481
|
const qz: number = quaternion[2];
|
|
@@ -419,7 +511,12 @@ export function rotateByQuaternionPrepend<T extends DualQuaternionLike>(quaterni
|
|
|
419
511
|
* @param out The dual quaternion to store the result in.
|
|
420
512
|
* @returns A normalized dual quaternion.
|
|
421
513
|
*/
|
|
422
|
-
export function rotateAroundAxis<T extends DualQuaternionLike>(
|
|
514
|
+
export function rotateAroundAxis<T extends DualQuaternionLike>(
|
|
515
|
+
dualQuaternion: DualQuaternionLike,
|
|
516
|
+
axis: Vector3Like,
|
|
517
|
+
radians: number,
|
|
518
|
+
out: T
|
|
519
|
+
): T {
|
|
423
520
|
if (Math.abs(radians) < 0) {
|
|
424
521
|
return copy(dualQuaternion, out);
|
|
425
522
|
}
|
|
@@ -429,9 +526,9 @@ export function rotateAroundAxis<T extends DualQuaternionLike>(dualQuaternion: D
|
|
|
429
526
|
const r: number = radians * 0.5;
|
|
430
527
|
|
|
431
528
|
const s: number = Math.sin(r);
|
|
432
|
-
const bx: number = s * axis[0] / axisLength;
|
|
433
|
-
const by: number = s * axis[1] / axisLength;
|
|
434
|
-
const bz: number = s * axis[2] / axisLength;
|
|
529
|
+
const bx: number = (s * axis[0]) / axisLength;
|
|
530
|
+
const by: number = (s * axis[1]) / axisLength;
|
|
531
|
+
const bz: number = (s * axis[2]) / axisLength;
|
|
435
532
|
const bw: number = Math.cos(r);
|
|
436
533
|
|
|
437
534
|
let x: number = dualQuaternion[0];
|
|
@@ -463,7 +560,11 @@ export function rotateAroundAxis<T extends DualQuaternionLike>(dualQuaternion: D
|
|
|
463
560
|
* @param out The dual quaternion to store the result in.
|
|
464
561
|
* @returns The sum.
|
|
465
562
|
*/
|
|
466
|
-
export function add<T extends DualQuaternionLike>(
|
|
563
|
+
export function add<T extends DualQuaternionLike>(
|
|
564
|
+
a: DualQuaternionLike,
|
|
565
|
+
b: DualQuaternionLike,
|
|
566
|
+
out: T
|
|
567
|
+
): T {
|
|
467
568
|
out[0] = a[0] + b[0];
|
|
468
569
|
out[1] = a[1] + b[1];
|
|
469
570
|
out[2] = a[2] + b[2];
|
|
@@ -482,7 +583,11 @@ export function add<T extends DualQuaternionLike>(a: DualQuaternionLike, b: Dual
|
|
|
482
583
|
* @param out The dual quaternion to store the result in.
|
|
483
584
|
* @returns The product.
|
|
484
585
|
*/
|
|
485
|
-
export function multiply<T extends DualQuaternionLike>(
|
|
586
|
+
export function multiply<T extends DualQuaternionLike>(
|
|
587
|
+
a: DualQuaternionLike,
|
|
588
|
+
b: DualQuaternionLike,
|
|
589
|
+
out: T
|
|
590
|
+
): T {
|
|
486
591
|
const ax0: number = a[0];
|
|
487
592
|
const ay0: number = a[1];
|
|
488
593
|
const az0: number = a[2];
|
|
@@ -507,10 +612,42 @@ export function multiply<T extends DualQuaternionLike>(a: DualQuaternionLike, b:
|
|
|
507
612
|
out[1] = ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0;
|
|
508
613
|
out[2] = az0 * bw0 + aw0 * bz0 + ax0 * by0 - ay0 * bx0;
|
|
509
614
|
out[3] = aw0 * bw0 - ax0 * bx0 - ay0 * by0 - az0 * bz0;
|
|
510
|
-
out[4] =
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
615
|
+
out[4] =
|
|
616
|
+
ax0 * bw1 +
|
|
617
|
+
aw0 * bx1 +
|
|
618
|
+
ay0 * bz1 -
|
|
619
|
+
az0 * by1 +
|
|
620
|
+
ax1 * bw0 +
|
|
621
|
+
aw1 * bx0 +
|
|
622
|
+
ay1 * bz0 -
|
|
623
|
+
az1 * by0;
|
|
624
|
+
out[5] =
|
|
625
|
+
ay0 * bw1 +
|
|
626
|
+
aw0 * by1 +
|
|
627
|
+
az0 * bx1 -
|
|
628
|
+
ax0 * bz1 +
|
|
629
|
+
ay1 * bw0 +
|
|
630
|
+
aw1 * by0 +
|
|
631
|
+
az1 * bx0 -
|
|
632
|
+
ax1 * bz0;
|
|
633
|
+
out[6] =
|
|
634
|
+
az0 * bw1 +
|
|
635
|
+
aw0 * bz1 +
|
|
636
|
+
ax0 * by1 -
|
|
637
|
+
ay0 * bx1 +
|
|
638
|
+
az1 * bw0 +
|
|
639
|
+
aw1 * bz0 +
|
|
640
|
+
ax1 * by0 -
|
|
641
|
+
ay1 * bx0;
|
|
642
|
+
out[7] =
|
|
643
|
+
aw0 * bw1 -
|
|
644
|
+
ax0 * bx1 -
|
|
645
|
+
ay0 * by1 -
|
|
646
|
+
az0 * bz1 +
|
|
647
|
+
aw1 * bw0 -
|
|
648
|
+
ax1 * bx0 -
|
|
649
|
+
ay1 * by0 -
|
|
650
|
+
az1 * bz0;
|
|
514
651
|
return out;
|
|
515
652
|
}
|
|
516
653
|
|
|
@@ -521,7 +658,11 @@ export function multiply<T extends DualQuaternionLike>(a: DualQuaternionLike, b:
|
|
|
521
658
|
* @param out The dual quaternion to store the result in.
|
|
522
659
|
* @returns The sum.
|
|
523
660
|
*/
|
|
524
|
-
export function scale<T extends DualQuaternionLike>(
|
|
661
|
+
export function scale<T extends DualQuaternionLike>(
|
|
662
|
+
dualQuaternion: DualQuaternionLike,
|
|
663
|
+
scalar: number,
|
|
664
|
+
out: T
|
|
665
|
+
): T {
|
|
525
666
|
out[0] = dualQuaternion[0] * scalar;
|
|
526
667
|
out[1] = dualQuaternion[1] * scalar;
|
|
527
668
|
out[2] = dualQuaternion[2] * scalar;
|
|
@@ -541,7 +682,12 @@ export function scale<T extends DualQuaternionLike>(dualQuaternion: DualQuaterni
|
|
|
541
682
|
* @param out The dual quaternion to store the result in.
|
|
542
683
|
* @returns The interpolated value.
|
|
543
684
|
*/
|
|
544
|
-
export function lerp<T extends DualQuaternionLike>(
|
|
685
|
+
export function lerp<T extends DualQuaternionLike>(
|
|
686
|
+
a: DualQuaternionLike,
|
|
687
|
+
b: DualQuaternionLike,
|
|
688
|
+
t: number,
|
|
689
|
+
out: T
|
|
690
|
+
): T {
|
|
545
691
|
const mt: number = 1 - t;
|
|
546
692
|
|
|
547
693
|
if (dot(a as unknown as Vector4Like, b as unknown as Vector4Like) < epsilon) {
|
|
@@ -565,8 +711,13 @@ export function lerp<T extends DualQuaternionLike>(a: DualQuaternionLike, b: Dua
|
|
|
565
711
|
* @param out The dual quaternion to store the result in.
|
|
566
712
|
* @returns The inverse.
|
|
567
713
|
*/
|
|
568
|
-
export function invert<T extends DualQuaternionLike>(
|
|
569
|
-
|
|
714
|
+
export function invert<T extends DualQuaternionLike>(
|
|
715
|
+
dualQuaternion: DualQuaternionLike,
|
|
716
|
+
out: T
|
|
717
|
+
): T {
|
|
718
|
+
const sqm: number = getSquaredMagnitude(
|
|
719
|
+
dualQuaternion as unknown as Vector4Like
|
|
720
|
+
);
|
|
570
721
|
|
|
571
722
|
out[0] = -dualQuaternion[0] / sqm;
|
|
572
723
|
out[1] = -dualQuaternion[1] / sqm;
|
|
@@ -585,7 +736,10 @@ export function invert<T extends DualQuaternionLike>(dualQuaternion: DualQuatern
|
|
|
585
736
|
* @param out The dual quaternion to store the result in.
|
|
586
737
|
* @returns The conjugate.
|
|
587
738
|
*/
|
|
588
|
-
export function conjugate<T extends DualQuaternionLike>(
|
|
739
|
+
export function conjugate<T extends DualQuaternionLike>(
|
|
740
|
+
dualQuaternion: DualQuaternionLike,
|
|
741
|
+
out: T
|
|
742
|
+
): T {
|
|
589
743
|
out[0] = -dualQuaternion[0];
|
|
590
744
|
out[1] = -dualQuaternion[1];
|
|
591
745
|
out[2] = -dualQuaternion[2];
|
|
@@ -603,8 +757,13 @@ export function conjugate<T extends DualQuaternionLike>(dualQuaternion: DualQuat
|
|
|
603
757
|
* @param out The dual quaternion to store the result in.
|
|
604
758
|
* @returns The normalized dual quaternion.
|
|
605
759
|
*/
|
|
606
|
-
export function normalize<T extends DualQuaternionLike>(
|
|
607
|
-
|
|
760
|
+
export function normalize<T extends DualQuaternionLike>(
|
|
761
|
+
dualQuaternion: DualQuaternionLike,
|
|
762
|
+
out: T
|
|
763
|
+
): T {
|
|
764
|
+
let magnitude: number = getSquaredMagnitude(
|
|
765
|
+
dualQuaternion as unknown as Vector4Like
|
|
766
|
+
);
|
|
608
767
|
if (magnitude > 0) {
|
|
609
768
|
magnitude = Math.sqrt(magnitude);
|
|
610
769
|
|
|
@@ -637,15 +796,20 @@ export function normalize<T extends DualQuaternionLike>(dualQuaternion: DualQuat
|
|
|
637
796
|
* @param b The second dual quaternion.
|
|
638
797
|
* @returns Whether the dual quaternions are equivalent.
|
|
639
798
|
*/
|
|
640
|
-
export function exactEquals(
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
799
|
+
export function exactEquals(
|
|
800
|
+
a: DualQuaternionLike,
|
|
801
|
+
b: DualQuaternionLike
|
|
802
|
+
): boolean {
|
|
803
|
+
return (
|
|
804
|
+
a[0] === b[0] &&
|
|
805
|
+
a[1] === b[1] &&
|
|
806
|
+
a[2] === b[2] &&
|
|
807
|
+
a[3] === b[3] &&
|
|
808
|
+
a[4] === b[4] &&
|
|
809
|
+
a[5] === b[5] &&
|
|
810
|
+
a[6] === b[6] &&
|
|
811
|
+
a[7] === b[7]
|
|
812
|
+
);
|
|
649
813
|
}
|
|
650
814
|
|
|
651
815
|
/**
|
|
@@ -673,14 +837,16 @@ export function equals(a: DualQuaternionLike, b: DualQuaternionLike): boolean {
|
|
|
673
837
|
const b6: number = b[6];
|
|
674
838
|
const b7: number = b[7];
|
|
675
839
|
|
|
676
|
-
return
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
840
|
+
return (
|
|
841
|
+
Math.abs(a0 - b0) <= epsilon * Math.max(1, Math.abs(a0), Math.abs(b0)) &&
|
|
842
|
+
Math.abs(a1 - b1) <= epsilon * Math.max(1, Math.abs(a1), Math.abs(b1)) &&
|
|
843
|
+
Math.abs(a2 - b2) <= epsilon * Math.max(1, Math.abs(a2), Math.abs(b2)) &&
|
|
844
|
+
Math.abs(a3 - b3) <= epsilon * Math.max(1, Math.abs(a3), Math.abs(b3)) &&
|
|
845
|
+
Math.abs(a4 - b4) <= epsilon * Math.max(1, Math.abs(a4), Math.abs(b4)) &&
|
|
846
|
+
Math.abs(a5 - b5) <= epsilon * Math.max(1, Math.abs(a5), Math.abs(b5)) &&
|
|
847
|
+
Math.abs(a6 - b6) <= epsilon * Math.max(1, Math.abs(a6), Math.abs(b6)) &&
|
|
848
|
+
Math.abs(a7 - b7) <= epsilon * Math.max(1, Math.abs(a7), Math.abs(b7))
|
|
849
|
+
);
|
|
684
850
|
}
|
|
685
851
|
|
|
686
852
|
/**
|
|
@@ -700,7 +866,16 @@ export default class DualQuaternion extends Float32Array {
|
|
|
700
866
|
* @param w2 The fourth dual component.
|
|
701
867
|
* @returns A new dual quaternion.
|
|
702
868
|
*/
|
|
703
|
-
public static fromValues(
|
|
869
|
+
public static fromValues(
|
|
870
|
+
x1: number,
|
|
871
|
+
y1: number,
|
|
872
|
+
z1: number,
|
|
873
|
+
w1: number,
|
|
874
|
+
x2: number,
|
|
875
|
+
y2: number,
|
|
876
|
+
z2: number,
|
|
877
|
+
w2: number
|
|
878
|
+
): DualQuaternion;
|
|
704
879
|
|
|
705
880
|
/**
|
|
706
881
|
* Creates a dual quaternion with the given values.
|
|
@@ -715,9 +890,29 @@ export default class DualQuaternion extends Float32Array {
|
|
|
715
890
|
* @param out The dual quaternion to store the result in.
|
|
716
891
|
* @returns A new dual quaternion.
|
|
717
892
|
*/
|
|
718
|
-
public static fromValues<T extends DualQuaternionLike>(
|
|
719
|
-
|
|
720
|
-
|
|
893
|
+
public static fromValues<T extends DualQuaternionLike>(
|
|
894
|
+
x1: number,
|
|
895
|
+
y1: number,
|
|
896
|
+
z1: number,
|
|
897
|
+
w1: number,
|
|
898
|
+
x2: number,
|
|
899
|
+
y2: number,
|
|
900
|
+
z2: number,
|
|
901
|
+
w2: number,
|
|
902
|
+
out: T
|
|
903
|
+
): T;
|
|
904
|
+
|
|
905
|
+
public static fromValues<T extends DualQuaternionLike>(
|
|
906
|
+
x1: number,
|
|
907
|
+
y1: number,
|
|
908
|
+
z1: number,
|
|
909
|
+
w1: number,
|
|
910
|
+
x2: number,
|
|
911
|
+
y2: number,
|
|
912
|
+
z2: number,
|
|
913
|
+
w2: number,
|
|
914
|
+
out: T = new DualQuaternion() as T
|
|
915
|
+
): T {
|
|
721
916
|
return fromValues(x1, y1, z1, w1, x2, y2, z2, w2, out);
|
|
722
917
|
}
|
|
723
918
|
|
|
@@ -727,7 +922,10 @@ export default class DualQuaternion extends Float32Array {
|
|
|
727
922
|
* @param translation The translation.
|
|
728
923
|
* @returns The dual quaternion.
|
|
729
924
|
*/
|
|
730
|
-
public static fromRotationTranslation(
|
|
925
|
+
public static fromRotationTranslation(
|
|
926
|
+
quaternion: QuaternionLike,
|
|
927
|
+
translation: Vector3Like
|
|
928
|
+
): DualQuaternion;
|
|
731
929
|
|
|
732
930
|
/**
|
|
733
931
|
* Creates a dual quaternion from the given quaternion and translation.
|
|
@@ -736,9 +934,17 @@ export default class DualQuaternion extends Float32Array {
|
|
|
736
934
|
* @param out The dual quaternion to store the result in.
|
|
737
935
|
* @returns The dual quaternion.
|
|
738
936
|
*/
|
|
739
|
-
public static fromRotationTranslation<T extends DualQuaternionLike>(
|
|
740
|
-
|
|
741
|
-
|
|
937
|
+
public static fromRotationTranslation<T extends DualQuaternionLike>(
|
|
938
|
+
quaternion: QuaternionLike,
|
|
939
|
+
translation: Vector3Like,
|
|
940
|
+
out: T
|
|
941
|
+
): T;
|
|
942
|
+
|
|
943
|
+
public static fromRotationTranslation<T extends DualQuaternionLike>(
|
|
944
|
+
quaternion: QuaternionLike,
|
|
945
|
+
translation: Vector3Like,
|
|
946
|
+
out: T = new DualQuaternion() as T
|
|
947
|
+
): T {
|
|
742
948
|
return fromRotationTranslation(quaternion, translation, out);
|
|
743
949
|
}
|
|
744
950
|
|
|
@@ -755,9 +961,15 @@ export default class DualQuaternion extends Float32Array {
|
|
|
755
961
|
* @param out The dual quaternion to store the result in.
|
|
756
962
|
* @returns The dual quaternion.
|
|
757
963
|
*/
|
|
758
|
-
public static fromTranslation<T extends DualQuaternionLike>(
|
|
759
|
-
|
|
760
|
-
|
|
964
|
+
public static fromTranslation<T extends DualQuaternionLike>(
|
|
965
|
+
translation: Vector3Like,
|
|
966
|
+
out: T
|
|
967
|
+
): T;
|
|
968
|
+
|
|
969
|
+
public static fromTranslation<T extends DualQuaternionLike>(
|
|
970
|
+
translation: Vector3Like,
|
|
971
|
+
out: T = new DualQuaternion() as T
|
|
972
|
+
): T {
|
|
761
973
|
return fromTranslation(translation, out);
|
|
762
974
|
}
|
|
763
975
|
|
|
@@ -774,9 +986,15 @@ export default class DualQuaternion extends Float32Array {
|
|
|
774
986
|
* @param out The dual quaternion to store the result in.
|
|
775
987
|
* @returns The dual quaternion.
|
|
776
988
|
*/
|
|
777
|
-
public static fromRotation<T extends DualQuaternionLike>(
|
|
778
|
-
|
|
779
|
-
|
|
989
|
+
public static fromRotation<T extends DualQuaternionLike>(
|
|
990
|
+
quaternion: QuaternionLike,
|
|
991
|
+
out: T
|
|
992
|
+
): T;
|
|
993
|
+
|
|
994
|
+
public static fromRotation<T extends DualQuaternionLike>(
|
|
995
|
+
quaternion: QuaternionLike,
|
|
996
|
+
out: T = new DualQuaternion() as T
|
|
997
|
+
): T {
|
|
780
998
|
return fromRotation(quaternion, out);
|
|
781
999
|
}
|
|
782
1000
|
|
|
@@ -793,9 +1011,15 @@ export default class DualQuaternion extends Float32Array {
|
|
|
793
1011
|
* @param out The dual quaternion to store the result in.
|
|
794
1012
|
* @returns The dual quaternion.
|
|
795
1013
|
*/
|
|
796
|
-
public static fromMatrix4<T extends DualQuaternionLike>(
|
|
797
|
-
|
|
798
|
-
|
|
1014
|
+
public static fromMatrix4<T extends DualQuaternionLike>(
|
|
1015
|
+
matrix: Matrix4Like,
|
|
1016
|
+
out: T
|
|
1017
|
+
): T;
|
|
1018
|
+
|
|
1019
|
+
public static fromMatrix4<T extends DualQuaternionLike>(
|
|
1020
|
+
matrix: Matrix4Like,
|
|
1021
|
+
out: T = new DualQuaternion() as T
|
|
1022
|
+
): T {
|
|
799
1023
|
return fromMatrix4(matrix, out);
|
|
800
1024
|
}
|
|
801
1025
|
|
|
@@ -829,8 +1053,10 @@ export default class DualQuaternion extends Float32Array {
|
|
|
829
1053
|
* @returns The copy.
|
|
830
1054
|
*/
|
|
831
1055
|
public clone<T extends DualQuaternionLike>(out: T): T;
|
|
832
|
-
|
|
833
|
-
public clone<T extends DualQuaternionLike>(
|
|
1056
|
+
|
|
1057
|
+
public clone<T extends DualQuaternionLike>(
|
|
1058
|
+
out: T = new DualQuaternion() as T
|
|
1059
|
+
): T {
|
|
834
1060
|
return copy(this, out);
|
|
835
1061
|
}
|
|
836
1062
|
|
|
@@ -904,7 +1130,7 @@ export default class DualQuaternion extends Float32Array {
|
|
|
904
1130
|
* @returns The translation.
|
|
905
1131
|
*/
|
|
906
1132
|
public getTranslation<T extends Vector3Like>(out: T): T;
|
|
907
|
-
|
|
1133
|
+
|
|
908
1134
|
public getTranslation<T extends Vector3Like>(out: T = new Vector3() as T): T {
|
|
909
1135
|
return getTranslation(this, out);
|
|
910
1136
|
}
|
|
@@ -922,9 +1148,15 @@ export default class DualQuaternion extends Float32Array {
|
|
|
922
1148
|
* @param out The dual quaternion to store the result in.
|
|
923
1149
|
* @returns The translated dual quaternion.
|
|
924
1150
|
*/
|
|
925
|
-
public translate<T extends DualQuaternionLike>(
|
|
926
|
-
|
|
927
|
-
|
|
1151
|
+
public translate<T extends DualQuaternionLike>(
|
|
1152
|
+
vector: Vector3Like,
|
|
1153
|
+
out: T
|
|
1154
|
+
): T;
|
|
1155
|
+
|
|
1156
|
+
public translate<T extends DualQuaternionLike>(
|
|
1157
|
+
vector: Vector3Like,
|
|
1158
|
+
out: T = new DualQuaternion() as T
|
|
1159
|
+
): T {
|
|
928
1160
|
return translate(this, vector, out);
|
|
929
1161
|
}
|
|
930
1162
|
|
|
@@ -942,8 +1174,11 @@ export default class DualQuaternion extends Float32Array {
|
|
|
942
1174
|
* @returns The rotated dual quaternion.
|
|
943
1175
|
*/
|
|
944
1176
|
public rotateX<T extends DualQuaternionLike>(radians: number, out: T): T;
|
|
945
|
-
|
|
946
|
-
public rotateX<T extends DualQuaternionLike>(
|
|
1177
|
+
|
|
1178
|
+
public rotateX<T extends DualQuaternionLike>(
|
|
1179
|
+
radians: number,
|
|
1180
|
+
out: T = new DualQuaternion() as T
|
|
1181
|
+
): T {
|
|
947
1182
|
return rotateX(this, radians, out);
|
|
948
1183
|
}
|
|
949
1184
|
|
|
@@ -961,8 +1196,11 @@ export default class DualQuaternion extends Float32Array {
|
|
|
961
1196
|
* @returns The rotated dual quaternion.
|
|
962
1197
|
*/
|
|
963
1198
|
public rotateY<T extends DualQuaternionLike>(radians: number, out: T): T;
|
|
964
|
-
|
|
965
|
-
public rotateY<T extends DualQuaternionLike>(
|
|
1199
|
+
|
|
1200
|
+
public rotateY<T extends DualQuaternionLike>(
|
|
1201
|
+
radians: number,
|
|
1202
|
+
out: T = new DualQuaternion() as T
|
|
1203
|
+
): T {
|
|
966
1204
|
return rotateY(this, radians, out);
|
|
967
1205
|
}
|
|
968
1206
|
|
|
@@ -980,8 +1218,11 @@ export default class DualQuaternion extends Float32Array {
|
|
|
980
1218
|
* @returns The rotated dual quaternion.
|
|
981
1219
|
*/
|
|
982
1220
|
public rotateZ<T extends DualQuaternionLike>(radians: number, out: T): T;
|
|
983
|
-
|
|
984
|
-
public rotateZ<T extends DualQuaternionLike>(
|
|
1221
|
+
|
|
1222
|
+
public rotateZ<T extends DualQuaternionLike>(
|
|
1223
|
+
radians: number,
|
|
1224
|
+
out: T = new DualQuaternion() as T
|
|
1225
|
+
): T {
|
|
985
1226
|
return rotateZ(this, radians, out);
|
|
986
1227
|
}
|
|
987
1228
|
|
|
@@ -1000,9 +1241,15 @@ export default class DualQuaternion extends Float32Array {
|
|
|
1000
1241
|
* @returns The rotated dual quaternion.
|
|
1001
1242
|
* @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
|
|
1002
1243
|
*/
|
|
1003
|
-
public rotateByQuaternionAppend<T extends DualQuaternionLike>(
|
|
1004
|
-
|
|
1005
|
-
|
|
1244
|
+
public rotateByQuaternionAppend<T extends DualQuaternionLike>(
|
|
1245
|
+
quaternion: QuaternionLike,
|
|
1246
|
+
out: T
|
|
1247
|
+
): T;
|
|
1248
|
+
|
|
1249
|
+
public rotateByQuaternionAppend<T extends DualQuaternionLike>(
|
|
1250
|
+
quaternion: QuaternionLike,
|
|
1251
|
+
out: T = new DualQuaternion() as T
|
|
1252
|
+
): T {
|
|
1006
1253
|
return rotateByQuaternionAppend(this, quaternion, out);
|
|
1007
1254
|
}
|
|
1008
1255
|
|
|
@@ -1021,9 +1268,15 @@ export default class DualQuaternion extends Float32Array {
|
|
|
1021
1268
|
* @returns The rotated dual quaternion.
|
|
1022
1269
|
* @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
|
|
1023
1270
|
*/
|
|
1024
|
-
public rotateByQuaternionPrepend<T extends DualQuaternionLike>(
|
|
1025
|
-
|
|
1026
|
-
|
|
1271
|
+
public rotateByQuaternionPrepend<T extends DualQuaternionLike>(
|
|
1272
|
+
quaternion: QuaternionLike,
|
|
1273
|
+
out: T
|
|
1274
|
+
): T;
|
|
1275
|
+
|
|
1276
|
+
public rotateByQuaternionPrepend<T extends DualQuaternionLike>(
|
|
1277
|
+
quaternion: QuaternionLike,
|
|
1278
|
+
out: T = new DualQuaternion() as T
|
|
1279
|
+
): T {
|
|
1027
1280
|
return rotateByQuaternionPrepend(quaternion, this, out);
|
|
1028
1281
|
}
|
|
1029
1282
|
|
|
@@ -1042,9 +1295,17 @@ export default class DualQuaternion extends Float32Array {
|
|
|
1042
1295
|
* @param out The dual quaternion to store the result in.
|
|
1043
1296
|
* @returns A normalized dual quaternion.
|
|
1044
1297
|
*/
|
|
1045
|
-
public rotateAroundAxis<T extends DualQuaternionLike>(
|
|
1046
|
-
|
|
1047
|
-
|
|
1298
|
+
public rotateAroundAxis<T extends DualQuaternionLike>(
|
|
1299
|
+
axis: Vector3Like,
|
|
1300
|
+
radians: number,
|
|
1301
|
+
out: T
|
|
1302
|
+
): T;
|
|
1303
|
+
|
|
1304
|
+
public rotateAroundAxis<T extends DualQuaternionLike>(
|
|
1305
|
+
axis: Vector3Like,
|
|
1306
|
+
radians: number,
|
|
1307
|
+
out: T = new DualQuaternion() as T
|
|
1308
|
+
): T {
|
|
1048
1309
|
return rotateAroundAxis(this, axis, radians, out);
|
|
1049
1310
|
}
|
|
1050
1311
|
|
|
@@ -1061,9 +1322,15 @@ export default class DualQuaternion extends Float32Array {
|
|
|
1061
1322
|
* @param out The dual quaternion to store the result in.
|
|
1062
1323
|
* @returns The sum.
|
|
1063
1324
|
*/
|
|
1064
|
-
public add<T extends DualQuaternionLike>(
|
|
1065
|
-
|
|
1066
|
-
|
|
1325
|
+
public add<T extends DualQuaternionLike>(
|
|
1326
|
+
dualQuaternion: DualQuaternionLike,
|
|
1327
|
+
out: T
|
|
1328
|
+
): T;
|
|
1329
|
+
|
|
1330
|
+
public add<T extends DualQuaternionLike>(
|
|
1331
|
+
dualQuaternion: DualQuaternionLike,
|
|
1332
|
+
out: T = new DualQuaternion() as T
|
|
1333
|
+
): T {
|
|
1067
1334
|
return add(this, dualQuaternion, out);
|
|
1068
1335
|
}
|
|
1069
1336
|
|
|
@@ -1080,9 +1347,15 @@ export default class DualQuaternion extends Float32Array {
|
|
|
1080
1347
|
* @param out The dual quaternion to store the result in.
|
|
1081
1348
|
* @returns The product.
|
|
1082
1349
|
*/
|
|
1083
|
-
public multiply<T extends DualQuaternionLike>(
|
|
1084
|
-
|
|
1085
|
-
|
|
1350
|
+
public multiply<T extends DualQuaternionLike>(
|
|
1351
|
+
dualQuaternion: DualQuaternionLike,
|
|
1352
|
+
out: T
|
|
1353
|
+
): T;
|
|
1354
|
+
|
|
1355
|
+
public multiply<T extends DualQuaternionLike>(
|
|
1356
|
+
dualQuaternion: DualQuaternionLike,
|
|
1357
|
+
out: T = new DualQuaternion() as T
|
|
1358
|
+
): T {
|
|
1086
1359
|
return multiply(this, dualQuaternion, out);
|
|
1087
1360
|
}
|
|
1088
1361
|
|
|
@@ -1100,8 +1373,11 @@ export default class DualQuaternion extends Float32Array {
|
|
|
1100
1373
|
* @returns The product.
|
|
1101
1374
|
*/
|
|
1102
1375
|
public scale<T extends DualQuaternionLike>(scalar: number, out: T): T;
|
|
1103
|
-
|
|
1104
|
-
public scale<T extends DualQuaternionLike>(
|
|
1376
|
+
|
|
1377
|
+
public scale<T extends DualQuaternionLike>(
|
|
1378
|
+
scalar: number,
|
|
1379
|
+
out: T = new DualQuaternion() as T
|
|
1380
|
+
): T {
|
|
1105
1381
|
return scale(this, scalar, out);
|
|
1106
1382
|
}
|
|
1107
1383
|
|
|
@@ -1112,7 +1388,10 @@ export default class DualQuaternion extends Float32Array {
|
|
|
1112
1388
|
* @see [Dot product](https://en.wikipedia.org/wiki/Dot_product)
|
|
1113
1389
|
*/
|
|
1114
1390
|
public dot(dualQuaternion: DualQuaternionLike): number {
|
|
1115
|
-
return dot(
|
|
1391
|
+
return dot(
|
|
1392
|
+
this as unknown as Vector4Like,
|
|
1393
|
+
dualQuaternion as unknown as Vector4Like
|
|
1394
|
+
);
|
|
1116
1395
|
}
|
|
1117
1396
|
|
|
1118
1397
|
/**
|
|
@@ -1130,9 +1409,17 @@ export default class DualQuaternion extends Float32Array {
|
|
|
1130
1409
|
* @param out The dual quaternion to store the result in.
|
|
1131
1410
|
* @returns The interpolated value.
|
|
1132
1411
|
*/
|
|
1133
|
-
public lerp<T extends DualQuaternionLike>(
|
|
1134
|
-
|
|
1135
|
-
|
|
1412
|
+
public lerp<T extends DualQuaternionLike>(
|
|
1413
|
+
dualQuaternion: DualQuaternionLike,
|
|
1414
|
+
t: number,
|
|
1415
|
+
out: T
|
|
1416
|
+
): T;
|
|
1417
|
+
|
|
1418
|
+
public lerp<T extends DualQuaternionLike>(
|
|
1419
|
+
dualQuaternion: DualQuaternionLike,
|
|
1420
|
+
t: number,
|
|
1421
|
+
out: T = new DualQuaternion() as T
|
|
1422
|
+
): T {
|
|
1136
1423
|
return lerp(this, dualQuaternion, t, out);
|
|
1137
1424
|
}
|
|
1138
1425
|
|
|
@@ -1148,8 +1435,10 @@ export default class DualQuaternion extends Float32Array {
|
|
|
1148
1435
|
* @returns The inverse.
|
|
1149
1436
|
*/
|
|
1150
1437
|
public invert<T extends DualQuaternionLike>(out: T): T;
|
|
1151
|
-
|
|
1152
|
-
public invert<T extends DualQuaternionLike>(
|
|
1438
|
+
|
|
1439
|
+
public invert<T extends DualQuaternionLike>(
|
|
1440
|
+
out: T = new DualQuaternion() as T
|
|
1441
|
+
): T {
|
|
1153
1442
|
return invert(this, out);
|
|
1154
1443
|
}
|
|
1155
1444
|
|
|
@@ -1165,8 +1454,10 @@ export default class DualQuaternion extends Float32Array {
|
|
|
1165
1454
|
* @returns The conjugate.
|
|
1166
1455
|
*/
|
|
1167
1456
|
public conjugate<T extends DualQuaternionLike>(out: T): T;
|
|
1168
|
-
|
|
1169
|
-
public conjugate<T extends DualQuaternionLike>(
|
|
1457
|
+
|
|
1458
|
+
public conjugate<T extends DualQuaternionLike>(
|
|
1459
|
+
out: T = new DualQuaternion() as T
|
|
1460
|
+
): T {
|
|
1170
1461
|
return conjugate(this, out);
|
|
1171
1462
|
}
|
|
1172
1463
|
|
|
@@ -1192,8 +1483,10 @@ export default class DualQuaternion extends Float32Array {
|
|
|
1192
1483
|
* @returns The normalized dual quaternion.
|
|
1193
1484
|
*/
|
|
1194
1485
|
public normalize<T extends DualQuaternionLike>(out: T): T;
|
|
1195
|
-
|
|
1196
|
-
public normalize<T extends DualQuaternionLike>(
|
|
1486
|
+
|
|
1487
|
+
public normalize<T extends DualQuaternionLike>(
|
|
1488
|
+
out: T = new DualQuaternion() as T
|
|
1489
|
+
): T {
|
|
1197
1490
|
return normalize(this, out);
|
|
1198
1491
|
}
|
|
1199
1492
|
|