@lakuna/umath 1.5.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
- package/dist/algorithms/greatestCommonDivisor.js +14 -4
- package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
- package/dist/index.d.ts +15 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/linalg/DualQuaternion.d.ts +131 -154
- package/dist/linalg/DualQuaternion.d.ts.map +1 -1
- package/dist/linalg/DualQuaternion.js +188 -203
- package/dist/linalg/DualQuaternion.js.map +1 -1
- package/dist/linalg/Matrix.d.ts +24 -24
- package/dist/linalg/Matrix.d.ts.map +1 -1
- package/dist/linalg/Matrix2.d.ts +74 -88
- package/dist/linalg/Matrix2.d.ts.map +1 -1
- package/dist/linalg/Matrix2.js +114 -124
- package/dist/linalg/Matrix2.js.map +1 -1
- package/dist/linalg/Matrix3.d.ts +118 -139
- package/dist/linalg/Matrix3.d.ts.map +1 -1
- package/dist/linalg/Matrix3.js +169 -201
- package/dist/linalg/Matrix3.js.map +1 -1
- package/dist/linalg/Matrix4.d.ts +217 -257
- package/dist/linalg/Matrix4.d.ts.map +1 -1
- package/dist/linalg/Matrix4.js +310 -374
- package/dist/linalg/Matrix4.js.map +1 -1
- package/dist/linalg/Quaternion.d.ts +120 -151
- package/dist/linalg/Quaternion.d.ts.map +1 -1
- package/dist/linalg/Quaternion.js +187 -204
- package/dist/linalg/Quaternion.js.map +1 -1
- package/dist/linalg/SlowMatrix.d.ts +5 -5
- package/dist/linalg/SlowMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowMatrix.js +63 -89
- package/dist/linalg/SlowMatrix.js.map +1 -1
- package/dist/linalg/SlowSquareMatrix.d.ts +6 -6
- package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowSquareMatrix.js +15 -15
- package/dist/linalg/SlowSquareMatrix.js.map +1 -1
- package/dist/linalg/SlowVector.d.ts +165 -0
- package/dist/linalg/SlowVector.d.ts.map +1 -0
- package/dist/linalg/SlowVector.js +369 -0
- package/dist/linalg/SlowVector.js.map +1 -0
- package/dist/linalg/SquareMatrix.d.ts +8 -8
- package/dist/linalg/SquareMatrix.d.ts.map +1 -1
- package/dist/linalg/Vector.d.ts +84 -84
- package/dist/linalg/Vector.d.ts.map +1 -1
- package/dist/linalg/Vector2.d.ts +115 -137
- package/dist/linalg/Vector2.d.ts.map +1 -1
- package/dist/linalg/Vector2.js +164 -188
- package/dist/linalg/Vector2.js.map +1 -1
- package/dist/linalg/Vector3.d.ts +141 -167
- package/dist/linalg/Vector3.d.ts.map +1 -1
- package/dist/linalg/Vector3.js +200 -237
- package/dist/linalg/Vector3.js.map +1 -1
- package/dist/linalg/Vector4.d.ts +111 -131
- package/dist/linalg/Vector4.d.ts.map +1 -1
- package/dist/linalg/Vector4.js +163 -187
- package/dist/linalg/Vector4.js.map +1 -1
- package/dist/types/AxisAngle.d.ts +2 -2
- package/dist/types/AxisAngle.d.ts.map +1 -1
- package/dist/types/FieldOfView.d.ts +2 -2
- package/dist/types/FieldOfView.d.ts.map +1 -1
- package/dist/utility/BigNumber.d.ts +21 -11
- package/dist/utility/BigNumber.d.ts.map +1 -1
- package/dist/utility/BigNumber.js +42 -31
- package/dist/utility/BigNumber.js.map +1 -1
- package/dist/utility/MatrixSizeError.d.ts +1 -1
- package/dist/utility/MatrixSizeError.d.ts.map +1 -1
- package/dist/utility/MatrixSizeError.js +1 -1
- package/dist/utility/MatrixSizeError.js.map +1 -1
- package/dist/utility/VectorSizeError.d.ts +12 -0
- package/dist/utility/VectorSizeError.d.ts.map +1 -0
- package/dist/utility/VectorSizeError.js +15 -0
- package/dist/utility/VectorSizeError.js.map +1 -0
- package/dist/utility/createAxisAngleLike.d.ts +10 -0
- package/dist/utility/createAxisAngleLike.d.ts.map +1 -0
- package/dist/utility/createAxisAngleLike.js +10 -0
- package/dist/utility/createAxisAngleLike.js.map +1 -0
- package/package.json +11 -11
- package/src/algorithms/greatestCommonDivisor.ts +19 -7
- package/src/index.ts +24 -13
- package/src/linalg/DualQuaternion.ts +224 -292
- package/src/linalg/Matrix.ts +28 -28
- package/src/linalg/Matrix2.ts +138 -180
- package/src/linalg/Matrix3.ts +211 -286
- package/src/linalg/Matrix4.ts +466 -584
- package/src/linalg/Quaternion.ts +221 -294
- package/src/linalg/SlowMatrix.ts +97 -95
- package/src/linalg/SlowSquareMatrix.ts +19 -18
- package/src/linalg/SlowVector.ts +450 -0
- package/src/linalg/SquareMatrix.ts +9 -9
- package/src/linalg/Vector.ts +90 -90
- package/src/linalg/Vector2.ts +181 -266
- package/src/linalg/Vector3.ts +230 -342
- package/src/linalg/Vector4.ts +183 -257
- package/src/types/AxisAngle.ts +3 -3
- package/src/types/FieldOfView.ts +3 -3
- package/src/utility/BigNumber.ts +63 -41
- package/src/utility/MatrixSizeError.ts +1 -1
- package/src/utility/VectorSizeError.ts +14 -0
- package/src/utility/createAxisAngleLike.ts +14 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import approxRelative from "../algorithms/approxRelative.js";
|
|
2
|
+
import epsilon from "../utility/epsilon.js";
|
|
1
3
|
import { getScaling as matrix4GetScaling } from "./Matrix4.js";
|
|
2
4
|
import Quaternion, { rotateX as quaternionRotateX, rotateY as quaternionRotateY, rotateZ as quaternionRotateZ } from "./Quaternion.js";
|
|
3
5
|
import Vector3, { createVector3Like, fromValues as vector3FromValues } from "./Vector3.js";
|
|
4
6
|
import { copy as vector4Copy, dot as vector4Dot, fromValues as vector4FromValues, getMagnitude as vector4GetMagnitude, getSquaredMagnitude as vector4GetSquaredMagnitude } from "./Vector4.js";
|
|
5
|
-
import approxRelative from "../algorithms/approxRelative.js";
|
|
6
|
-
import epsilon from "../utility/epsilon.js";
|
|
7
7
|
/**
|
|
8
8
|
* Create a dual quaternion-like object.
|
|
9
9
|
* @returns A dual quaternion-like object.
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
-
export const createDualQuaternionLike = () =>
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export const createDualQuaternionLike = () =>
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
14
|
+
new Float32Array(8);
|
|
15
15
|
/**
|
|
16
16
|
* Create a dual quaternion with the given values.
|
|
17
17
|
* @param x1 - The first real component.
|
|
@@ -103,13 +103,13 @@ export const fromMatrix4 = (matrix, out) => {
|
|
|
103
103
|
const sm32 = matrix[9] * is2;
|
|
104
104
|
const sm33 = matrix[10] * is3;
|
|
105
105
|
const trace = sm11 + sm22 + sm33;
|
|
106
|
-
// eslint-disable-next-line init-declarations
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/init-declarations
|
|
107
107
|
let x;
|
|
108
|
-
// eslint-disable-next-line init-declarations
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/init-declarations
|
|
109
109
|
let y;
|
|
110
|
-
// eslint-disable-next-line init-declarations
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/init-declarations
|
|
111
111
|
let z;
|
|
112
|
-
// eslint-disable-next-line init-declarations
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/init-declarations
|
|
113
113
|
let w;
|
|
114
114
|
if (trace > 0) {
|
|
115
115
|
const s = Math.sqrt(trace + 1) * 2;
|
|
@@ -404,7 +404,7 @@ export const rotateAroundAxis = (dualQuaternion, axis, radians, out) => {
|
|
|
404
404
|
const ax = axis[0];
|
|
405
405
|
const ay = axis[1];
|
|
406
406
|
const az = axis[2];
|
|
407
|
-
const axisLength = Math.
|
|
407
|
+
const axisLength = Math.hypot(ax, ay, az);
|
|
408
408
|
const r = radians / 2;
|
|
409
409
|
const s = Math.sin(r);
|
|
410
410
|
const bx = (s * ax) / axisLength;
|
|
@@ -618,83 +618,116 @@ export const equals = (a, b) => approxRelative(a[0], b[0]) &&
|
|
|
618
618
|
* @public
|
|
619
619
|
*/
|
|
620
620
|
export default class DualQuaternion extends Float32Array {
|
|
621
|
+
/** The first real component of this dual quaternion. */
|
|
622
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
623
|
+
0;
|
|
624
|
+
/** The second real component of this dual quaternion. */
|
|
625
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
626
|
+
1;
|
|
627
|
+
/** The third real component of this dual quaternion. */
|
|
628
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
629
|
+
2;
|
|
630
|
+
/** The fourth real component of this dual quaternion. */
|
|
631
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
632
|
+
3;
|
|
633
|
+
/** The first dual component of this dual quaternion. */
|
|
634
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
635
|
+
4;
|
|
636
|
+
/** The second dual component of this dual quaternion. */
|
|
637
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
638
|
+
5;
|
|
639
|
+
/** The third dual component of this dual quaternion. */
|
|
640
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
641
|
+
6;
|
|
642
|
+
/** The fourth dual component of this dual quaternion. */
|
|
643
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
644
|
+
7;
|
|
645
|
+
/** Get the magnitude (length) of this dual quaternion. */
|
|
646
|
+
get magnitude() {
|
|
647
|
+
return getMagnitude(this);
|
|
648
|
+
}
|
|
649
|
+
/** Get the squared magnitude (length) of this dual quaternion. */
|
|
650
|
+
get squaredMagnitude() {
|
|
651
|
+
return getSquaredMagnitude(this);
|
|
652
|
+
}
|
|
621
653
|
/**
|
|
622
|
-
* Create
|
|
623
|
-
* @
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
*
|
|
631
|
-
* @param
|
|
632
|
-
* @returns
|
|
654
|
+
* Create an identity dual quaternion.
|
|
655
|
+
* @see {@link https://en.wikipedia.org/wiki/Dual_quaternion | Dual quaternion}
|
|
656
|
+
*/
|
|
657
|
+
constructor() {
|
|
658
|
+
super(8);
|
|
659
|
+
this[3] = 1;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Create a dual quaternion from the given four-by-four matrix.
|
|
663
|
+
* @param matrix - The matrix.
|
|
664
|
+
* @returns The dual quaternion.
|
|
665
|
+
*/
|
|
666
|
+
static fromMatrix4(matrix) {
|
|
667
|
+
return fromMatrix4(matrix, new DualQuaternion());
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Create a dual quaternion from the given rotation.
|
|
671
|
+
* @param q - The rotation quaternion.
|
|
672
|
+
* @returns The dual quaternion.
|
|
633
673
|
*/
|
|
634
|
-
static
|
|
635
|
-
return
|
|
674
|
+
static fromRotation(q) {
|
|
675
|
+
return fromRotation(q, new DualQuaternion());
|
|
636
676
|
}
|
|
637
677
|
/**
|
|
638
678
|
* Create a dual quaternion from the given rotation and translation.
|
|
639
679
|
* @param q - The rotation quaternion.
|
|
640
680
|
* @param t - The translation vector.
|
|
641
|
-
* @param out - The dual quaternion to store the result in.
|
|
642
681
|
* @returns The dual quaternion.
|
|
643
682
|
*/
|
|
644
|
-
static fromRotationTranslation(q, t
|
|
645
|
-
return fromRotationTranslation(q, t,
|
|
683
|
+
static fromRotationTranslation(q, t) {
|
|
684
|
+
return fromRotationTranslation(q, t, new DualQuaternion());
|
|
646
685
|
}
|
|
647
686
|
/**
|
|
648
687
|
* Create a dual quaternion from the given translation.
|
|
649
688
|
* @param t - The translation vector.
|
|
650
|
-
* @param out - The dual quaternion to store the result in.
|
|
651
689
|
* @returns The dual quaternion.
|
|
652
690
|
*/
|
|
653
|
-
static fromTranslation(t
|
|
654
|
-
return fromTranslation(t,
|
|
691
|
+
static fromTranslation(t) {
|
|
692
|
+
return fromTranslation(t, new DualQuaternion());
|
|
655
693
|
}
|
|
656
694
|
/**
|
|
657
|
-
* Create a dual quaternion
|
|
658
|
-
* @param
|
|
659
|
-
* @param
|
|
660
|
-
* @
|
|
695
|
+
* Create a dual quaternion with the given values.
|
|
696
|
+
* @param x1 - The first real component.
|
|
697
|
+
* @param y1 - The second real component.
|
|
698
|
+
* @param z1 - The third real component.
|
|
699
|
+
* @param w1 - The fourth real component.
|
|
700
|
+
* @param x2 - The first dual component.
|
|
701
|
+
* @param y2 - The second dual component.
|
|
702
|
+
* @param z2 - The third dual component.
|
|
703
|
+
* @param w2 - The fourth dual component.
|
|
704
|
+
* @returns A new dual quaternion.
|
|
661
705
|
*/
|
|
662
|
-
static
|
|
663
|
-
return
|
|
706
|
+
static fromValues(x1, y1, z1, w1, x2, y2, z2, w2) {
|
|
707
|
+
return fromValues(x1, y1, z1, w1, x2, y2, z2, w2, new DualQuaternion());
|
|
664
708
|
}
|
|
665
709
|
/**
|
|
666
|
-
*
|
|
667
|
-
* @param
|
|
668
|
-
* @
|
|
669
|
-
* @returns The dual quaternion.
|
|
710
|
+
* Add another dual quaternion to this one.
|
|
711
|
+
* @param dq - The other dual quaternion.
|
|
712
|
+
* @returns The sum.
|
|
670
713
|
*/
|
|
671
|
-
|
|
672
|
-
return
|
|
714
|
+
add(dq) {
|
|
715
|
+
return add(this, dq, new DualQuaternion());
|
|
673
716
|
}
|
|
674
717
|
/**
|
|
675
|
-
*
|
|
676
|
-
* @
|
|
718
|
+
* Copy the values from this dual quaternion to another one.
|
|
719
|
+
* @returns The copy.
|
|
677
720
|
*/
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
721
|
+
clone() {
|
|
722
|
+
return copy(this, new DualQuaternion());
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Calculate the conjugate of this dual quaternion. If this dual quaternion is normalized, this is equivalent to its inverse and faster to calculate.
|
|
726
|
+
* @returns The conjugate.
|
|
727
|
+
*/
|
|
728
|
+
conjugate() {
|
|
729
|
+
return conjugate(this, new DualQuaternion());
|
|
681
730
|
}
|
|
682
|
-
/** The first real component of this dual quaternion. */
|
|
683
|
-
0;
|
|
684
|
-
/** The second real component of this dual quaternion. */
|
|
685
|
-
1;
|
|
686
|
-
/** The third real component of this dual quaternion. */
|
|
687
|
-
2;
|
|
688
|
-
/** The fourth real component of this dual quaternion. */
|
|
689
|
-
3;
|
|
690
|
-
/** The first dual component of this dual quaternion. */
|
|
691
|
-
4;
|
|
692
|
-
/** The second dual component of this dual quaternion. */
|
|
693
|
-
5;
|
|
694
|
-
/** The third dual component of this dual quaternion. */
|
|
695
|
-
6;
|
|
696
|
-
/** The fourth dual component of this dual quaternion. */
|
|
697
|
-
7;
|
|
698
731
|
/**
|
|
699
732
|
* Copy the values from another dual quaternion to this one.
|
|
700
733
|
* @param dualQuaternion - The dual quaternion to copy.
|
|
@@ -704,217 +737,169 @@ export default class DualQuaternion extends Float32Array {
|
|
|
704
737
|
return copy(dualQuaternion, this);
|
|
705
738
|
}
|
|
706
739
|
/**
|
|
707
|
-
*
|
|
708
|
-
* @param
|
|
709
|
-
* @returns The
|
|
710
|
-
|
|
711
|
-
clone(out = new DualQuaternion()) {
|
|
712
|
-
return copy(this, out);
|
|
713
|
-
}
|
|
714
|
-
/**
|
|
715
|
-
* Set this dual quaternion to the identity dual quaternion.
|
|
716
|
-
* @returns The identity dual quaternion.
|
|
740
|
+
* Calculate the dot product of this and another dual quaternion.
|
|
741
|
+
* @param dq - The other dual quaternion.
|
|
742
|
+
* @returns The dot product.
|
|
743
|
+
* @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
|
|
717
744
|
*/
|
|
718
|
-
|
|
719
|
-
return
|
|
745
|
+
dot(dq) {
|
|
746
|
+
return dot(this, dq);
|
|
720
747
|
}
|
|
721
748
|
/**
|
|
722
|
-
*
|
|
723
|
-
* @param
|
|
724
|
-
* @returns
|
|
749
|
+
* Determine whether or not this dual quaternion is roughly equivalent to another.
|
|
750
|
+
* @param dq - The other dual quaternion.
|
|
751
|
+
* @returns Whether or not the dual quaternions are equivalent.
|
|
725
752
|
*/
|
|
726
|
-
|
|
727
|
-
return
|
|
753
|
+
equals(dq) {
|
|
754
|
+
return equals(this, dq);
|
|
728
755
|
}
|
|
729
756
|
/**
|
|
730
|
-
*
|
|
731
|
-
* @param
|
|
757
|
+
* Determine whether or not this dual quaternion is exactly equivalent to another.
|
|
758
|
+
* @param dq - The other dual quaternion.
|
|
759
|
+
* @returns Whether or not the dual quaternions are equivalent.
|
|
732
760
|
*/
|
|
733
|
-
|
|
734
|
-
|
|
761
|
+
exactEquals(dq) {
|
|
762
|
+
return exactEquals(this, dq);
|
|
735
763
|
}
|
|
736
764
|
/**
|
|
737
765
|
* Get the dual part of this dual quaternion.
|
|
738
|
-
* @param out - The quaternion to store the result in.
|
|
739
766
|
* @returns The dual part.
|
|
740
767
|
*/
|
|
741
|
-
getDual(
|
|
742
|
-
return getDual(this,
|
|
768
|
+
getDual() {
|
|
769
|
+
return getDual(this, new Quaternion());
|
|
743
770
|
}
|
|
744
771
|
/**
|
|
745
|
-
*
|
|
746
|
-
* @
|
|
772
|
+
* Get the real part of this dual quaternion.
|
|
773
|
+
* @returns The real part.
|
|
747
774
|
*/
|
|
748
|
-
|
|
749
|
-
|
|
775
|
+
getReal() {
|
|
776
|
+
return getReal(this, new Quaternion());
|
|
750
777
|
}
|
|
751
778
|
/**
|
|
752
779
|
* Get the translation of this normalized dual quaternion.
|
|
753
|
-
* @param out - The vector to store the result in.
|
|
754
780
|
* @returns The translation.
|
|
755
781
|
*/
|
|
756
|
-
getTranslation(
|
|
757
|
-
return getTranslation(this,
|
|
782
|
+
getTranslation() {
|
|
783
|
+
return getTranslation(this, new Vector3());
|
|
758
784
|
}
|
|
759
785
|
/**
|
|
760
|
-
*
|
|
761
|
-
* @
|
|
762
|
-
* @param out - The dual quaternion to store the result in.
|
|
763
|
-
* @returns The translated dual quaternion.
|
|
786
|
+
* Set this dual quaternion to the identity dual quaternion.
|
|
787
|
+
* @returns The identity dual quaternion.
|
|
764
788
|
*/
|
|
765
|
-
|
|
766
|
-
return
|
|
789
|
+
identity() {
|
|
790
|
+
return identity(this);
|
|
767
791
|
}
|
|
768
792
|
/**
|
|
769
|
-
*
|
|
770
|
-
* @
|
|
771
|
-
* @param out - The dual quaternion to store the result in.
|
|
772
|
-
* @returns The rotated dual quaternion.
|
|
793
|
+
* Calculate the inverse of this dual quaternion. If this dual quaternion is normalized, the conjugate is equivalent and faster to calculate.
|
|
794
|
+
* @returns The inverse.
|
|
773
795
|
*/
|
|
774
|
-
|
|
775
|
-
return
|
|
796
|
+
invert() {
|
|
797
|
+
return invert(this, new DualQuaternion());
|
|
776
798
|
}
|
|
777
799
|
/**
|
|
778
|
-
*
|
|
779
|
-
* @param
|
|
780
|
-
* @param
|
|
781
|
-
* @returns The
|
|
800
|
+
* Perform a linear interpolation between this and another dual quaternion.
|
|
801
|
+
* @param dq - The other dual quaternion.
|
|
802
|
+
* @param t - The interpolation amount in `[0,1]`.
|
|
803
|
+
* @returns The interpolated value.
|
|
782
804
|
*/
|
|
783
|
-
|
|
784
|
-
return
|
|
805
|
+
lerp(dq, t) {
|
|
806
|
+
return lerp(this, dq, t, new DualQuaternion());
|
|
785
807
|
}
|
|
786
808
|
/**
|
|
787
|
-
*
|
|
788
|
-
* @param
|
|
789
|
-
* @
|
|
790
|
-
|
|
809
|
+
* Multiply this dual quaternion by another one.
|
|
810
|
+
* @param dq - The other dual quaternion.
|
|
811
|
+
* @returns The product.
|
|
812
|
+
*/
|
|
813
|
+
multiply(dq) {
|
|
814
|
+
return multiply(this, dq, new DualQuaternion());
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Normalize this dual quaternion.
|
|
818
|
+
* @returns The normalized dual quaternion.
|
|
791
819
|
*/
|
|
792
|
-
|
|
793
|
-
return
|
|
820
|
+
normalize() {
|
|
821
|
+
return normalize(this, new DualQuaternion());
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Rotate this dual quaternion around an axis.
|
|
825
|
+
* @param axis - The axis.
|
|
826
|
+
* @param r - The angle of the rotation in radians.
|
|
827
|
+
* @returns A normalized dual quaternion.
|
|
828
|
+
*/
|
|
829
|
+
rotateAroundAxis(axis, r) {
|
|
830
|
+
return rotateAroundAxis(this, axis, r, new DualQuaternion());
|
|
794
831
|
}
|
|
795
832
|
/**
|
|
796
833
|
* Rotate this dual quaternion by a quaternion (using the quaternion as the multiplicand).
|
|
797
834
|
* @param q - The quaternion.
|
|
798
|
-
* @param out - The dual quaternion to store the result in.
|
|
799
835
|
* @returns The rotated dual quaternion.
|
|
800
836
|
* @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
|
|
801
837
|
*/
|
|
802
|
-
rotateByQuaternionAppend(q
|
|
803
|
-
return rotateByQuaternionAppend(this, q,
|
|
838
|
+
rotateByQuaternionAppend(q) {
|
|
839
|
+
return rotateByQuaternionAppend(this, q, new DualQuaternion());
|
|
804
840
|
}
|
|
805
841
|
/**
|
|
806
842
|
* Rotate this dual quaternion by a quaternion (using the quaternion as the multiplier).
|
|
807
843
|
* @param q - The quaternion.
|
|
808
|
-
* @param out - The dual quaternion to store the result in.
|
|
809
844
|
* @returns The rotated dual quaternion.
|
|
810
845
|
* @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
|
|
811
846
|
*/
|
|
812
|
-
rotateByQuaternionPrepend(q
|
|
813
|
-
return rotateByQuaternionPrepend(q, this,
|
|
847
|
+
rotateByQuaternionPrepend(q) {
|
|
848
|
+
return rotateByQuaternionPrepend(q, this, new DualQuaternion());
|
|
814
849
|
}
|
|
815
850
|
/**
|
|
816
|
-
* Rotate this dual quaternion around
|
|
817
|
-
* @param
|
|
818
|
-
* @
|
|
819
|
-
* @param out - The dual quaternion to store the result in.
|
|
820
|
-
* @returns A normalized dual quaternion.
|
|
851
|
+
* Rotate this dual quaternion around the X-axis.
|
|
852
|
+
* @param r - The angle to rotate by in radians.
|
|
853
|
+
* @returns The rotated dual quaternion.
|
|
821
854
|
*/
|
|
822
|
-
|
|
823
|
-
return
|
|
855
|
+
rotateX(r) {
|
|
856
|
+
return rotateX(this, r, new DualQuaternion());
|
|
824
857
|
}
|
|
825
858
|
/**
|
|
826
|
-
*
|
|
827
|
-
* @param
|
|
828
|
-
* @
|
|
829
|
-
* @returns The sum.
|
|
859
|
+
* Rotate this dual quaternion around the Y-axis.
|
|
860
|
+
* @param r - The angle to rotate by in radians.
|
|
861
|
+
* @returns The rotated dual quaternion.
|
|
830
862
|
*/
|
|
831
|
-
|
|
832
|
-
return
|
|
863
|
+
rotateY(r) {
|
|
864
|
+
return rotateY(this, r, new DualQuaternion());
|
|
833
865
|
}
|
|
834
866
|
/**
|
|
835
|
-
*
|
|
836
|
-
* @param
|
|
837
|
-
* @
|
|
838
|
-
* @returns The product.
|
|
867
|
+
* Rotate this dual quaternion around the Z-axis.
|
|
868
|
+
* @param r - The angle to rotate by in radians.
|
|
869
|
+
* @returns The rotated dual quaternion.
|
|
839
870
|
*/
|
|
840
|
-
|
|
841
|
-
return
|
|
871
|
+
rotateZ(r) {
|
|
872
|
+
return rotateZ(this, r, new DualQuaternion());
|
|
842
873
|
}
|
|
843
874
|
/**
|
|
844
875
|
* Multiply this dual quaternion by a scalar.
|
|
845
876
|
* @param s - The scalar.
|
|
846
|
-
* @param out - The dual quaternion to store the result in.
|
|
847
877
|
* @returns The product.
|
|
848
878
|
*/
|
|
849
|
-
scale(s
|
|
850
|
-
return scale(this, s,
|
|
851
|
-
}
|
|
852
|
-
/**
|
|
853
|
-
* Calculate the dot product of this and another dual quaternion.
|
|
854
|
-
* @param dq - The other dual quaternion.
|
|
855
|
-
* @returns The dot product.
|
|
856
|
-
* @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
|
|
857
|
-
*/
|
|
858
|
-
dot(dq) {
|
|
859
|
-
return dot(this, dq);
|
|
860
|
-
}
|
|
861
|
-
/**
|
|
862
|
-
* Perform a linear interpolation between this and another dual quaternion.
|
|
863
|
-
* @param dq - The other dual quaternion.
|
|
864
|
-
* @param t - The interpolation amount in `[0,1]`.
|
|
865
|
-
* @param out - The dual quaternion to store the result in.
|
|
866
|
-
* @returns The interpolated value.
|
|
867
|
-
*/
|
|
868
|
-
lerp(dq, t, out = new DualQuaternion()) {
|
|
869
|
-
return lerp(this, dq, t, out);
|
|
870
|
-
}
|
|
871
|
-
/**
|
|
872
|
-
* Calculate the inverse of this dual quaternion. If this dual quaternion is normalized, the conjugate is equivalent and faster to calculate.
|
|
873
|
-
* @param out - The dual quaternion to store the result in.
|
|
874
|
-
* @returns The inverse.
|
|
875
|
-
*/
|
|
876
|
-
invert(out = new DualQuaternion()) {
|
|
877
|
-
return invert(this, out);
|
|
879
|
+
scale(s) {
|
|
880
|
+
return scale(this, s, new DualQuaternion());
|
|
878
881
|
}
|
|
879
882
|
/**
|
|
880
|
-
*
|
|
881
|
-
* @param
|
|
882
|
-
* @returns The conjugate.
|
|
883
|
-
*/
|
|
884
|
-
conjugate(out = new DualQuaternion()) {
|
|
885
|
-
return conjugate(this, out);
|
|
886
|
-
}
|
|
887
|
-
/** Get the magnitude (length) of this dual quaternion. */
|
|
888
|
-
get magnitude() {
|
|
889
|
-
return getMagnitude(this);
|
|
890
|
-
}
|
|
891
|
-
/** Get the squared magnitude (length) of this dual quaternion. */
|
|
892
|
-
get squaredMagnitude() {
|
|
893
|
-
return getSquaredMagnitude(this);
|
|
894
|
-
}
|
|
895
|
-
/**
|
|
896
|
-
* Normalize this dual quaternion.
|
|
897
|
-
* @param out - The dual quaternion to store the result in.
|
|
898
|
-
* @returns The normalized dual quaternion.
|
|
883
|
+
* Set the real part of this dual quaternion.
|
|
884
|
+
* @param q - The quaternion.
|
|
899
885
|
*/
|
|
900
|
-
|
|
901
|
-
|
|
886
|
+
setDual(q) {
|
|
887
|
+
setDual(q, this);
|
|
902
888
|
}
|
|
903
889
|
/**
|
|
904
|
-
*
|
|
905
|
-
* @param
|
|
906
|
-
* @returns Whether or not the dual quaternions are equivalent.
|
|
890
|
+
* Set the real part of this dual quaternion.
|
|
891
|
+
* @param q - The quaternion.
|
|
907
892
|
*/
|
|
908
|
-
|
|
909
|
-
|
|
893
|
+
setReal(q) {
|
|
894
|
+
setReal(q, this);
|
|
910
895
|
}
|
|
911
896
|
/**
|
|
912
|
-
*
|
|
913
|
-
* @param
|
|
914
|
-
* @returns
|
|
897
|
+
* Translate this dual quaternion by the given vector.
|
|
898
|
+
* @param v - The vector.
|
|
899
|
+
* @returns The translated dual quaternion.
|
|
915
900
|
*/
|
|
916
|
-
|
|
917
|
-
return
|
|
901
|
+
translate(v) {
|
|
902
|
+
return translate(this, v, new DualQuaternion());
|
|
918
903
|
}
|
|
919
904
|
}
|
|
920
905
|
//# sourceMappingURL=DualQuaternion.js.map
|