@lakuna/umath 1.5.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/LICENSE +1 -1
  2. package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
  3. package/dist/algorithms/greatestCommonDivisor.js +14 -4
  4. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  5. package/dist/index.d.ts +15 -11
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +6 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/linalg/DualQuaternion.d.ts +131 -154
  10. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  11. package/dist/linalg/DualQuaternion.js +188 -203
  12. package/dist/linalg/DualQuaternion.js.map +1 -1
  13. package/dist/linalg/Matrix.d.ts +24 -24
  14. package/dist/linalg/Matrix.d.ts.map +1 -1
  15. package/dist/linalg/Matrix2.d.ts +74 -88
  16. package/dist/linalg/Matrix2.d.ts.map +1 -1
  17. package/dist/linalg/Matrix2.js +114 -124
  18. package/dist/linalg/Matrix2.js.map +1 -1
  19. package/dist/linalg/Matrix3.d.ts +118 -139
  20. package/dist/linalg/Matrix3.d.ts.map +1 -1
  21. package/dist/linalg/Matrix3.js +169 -201
  22. package/dist/linalg/Matrix3.js.map +1 -1
  23. package/dist/linalg/Matrix4.d.ts +217 -257
  24. package/dist/linalg/Matrix4.d.ts.map +1 -1
  25. package/dist/linalg/Matrix4.js +310 -374
  26. package/dist/linalg/Matrix4.js.map +1 -1
  27. package/dist/linalg/Quaternion.d.ts +120 -151
  28. package/dist/linalg/Quaternion.d.ts.map +1 -1
  29. package/dist/linalg/Quaternion.js +187 -204
  30. package/dist/linalg/Quaternion.js.map +1 -1
  31. package/dist/linalg/SlowMatrix.d.ts +5 -5
  32. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  33. package/dist/linalg/SlowMatrix.js +63 -89
  34. package/dist/linalg/SlowMatrix.js.map +1 -1
  35. package/dist/linalg/SlowSquareMatrix.d.ts +6 -6
  36. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  37. package/dist/linalg/SlowSquareMatrix.js +15 -15
  38. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  39. package/dist/linalg/SlowVector.d.ts +165 -0
  40. package/dist/linalg/SlowVector.d.ts.map +1 -0
  41. package/dist/linalg/SlowVector.js +369 -0
  42. package/dist/linalg/SlowVector.js.map +1 -0
  43. package/dist/linalg/SquareMatrix.d.ts +8 -8
  44. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  45. package/dist/linalg/Vector.d.ts +84 -84
  46. package/dist/linalg/Vector.d.ts.map +1 -1
  47. package/dist/linalg/Vector2.d.ts +115 -137
  48. package/dist/linalg/Vector2.d.ts.map +1 -1
  49. package/dist/linalg/Vector2.js +164 -188
  50. package/dist/linalg/Vector2.js.map +1 -1
  51. package/dist/linalg/Vector3.d.ts +141 -167
  52. package/dist/linalg/Vector3.d.ts.map +1 -1
  53. package/dist/linalg/Vector3.js +200 -237
  54. package/dist/linalg/Vector3.js.map +1 -1
  55. package/dist/linalg/Vector4.d.ts +111 -131
  56. package/dist/linalg/Vector4.d.ts.map +1 -1
  57. package/dist/linalg/Vector4.js +163 -187
  58. package/dist/linalg/Vector4.js.map +1 -1
  59. package/dist/types/AxisAngle.d.ts +2 -2
  60. package/dist/types/AxisAngle.d.ts.map +1 -1
  61. package/dist/types/FieldOfView.d.ts +2 -2
  62. package/dist/types/FieldOfView.d.ts.map +1 -1
  63. package/dist/utility/BigNumber.d.ts +21 -11
  64. package/dist/utility/BigNumber.d.ts.map +1 -1
  65. package/dist/utility/BigNumber.js +42 -31
  66. package/dist/utility/BigNumber.js.map +1 -1
  67. package/dist/utility/MatrixSizeError.d.ts +1 -1
  68. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  69. package/dist/utility/MatrixSizeError.js +1 -1
  70. package/dist/utility/MatrixSizeError.js.map +1 -1
  71. package/dist/utility/VectorSizeError.d.ts +12 -0
  72. package/dist/utility/VectorSizeError.d.ts.map +1 -0
  73. package/dist/utility/VectorSizeError.js +15 -0
  74. package/dist/utility/VectorSizeError.js.map +1 -0
  75. package/dist/utility/createAxisAngleLike.d.ts +10 -0
  76. package/dist/utility/createAxisAngleLike.d.ts.map +1 -0
  77. package/dist/utility/createAxisAngleLike.js +10 -0
  78. package/dist/utility/createAxisAngleLike.js.map +1 -0
  79. package/package.json +11 -11
  80. package/src/algorithms/greatestCommonDivisor.ts +19 -7
  81. package/src/index.ts +24 -13
  82. package/src/linalg/DualQuaternion.ts +224 -292
  83. package/src/linalg/Matrix.ts +28 -28
  84. package/src/linalg/Matrix2.ts +138 -180
  85. package/src/linalg/Matrix3.ts +211 -286
  86. package/src/linalg/Matrix4.ts +466 -584
  87. package/src/linalg/Quaternion.ts +221 -294
  88. package/src/linalg/SlowMatrix.ts +97 -95
  89. package/src/linalg/SlowSquareMatrix.ts +19 -18
  90. package/src/linalg/SlowVector.ts +450 -0
  91. package/src/linalg/SquareMatrix.ts +9 -9
  92. package/src/linalg/Vector.ts +90 -90
  93. package/src/linalg/Vector2.ts +181 -266
  94. package/src/linalg/Vector3.ts +230 -342
  95. package/src/linalg/Vector4.ts +183 -257
  96. package/src/types/AxisAngle.ts +3 -3
  97. package/src/types/FieldOfView.ts +3 -3
  98. package/src/utility/BigNumber.ts +63 -41
  99. package/src/utility/MatrixSizeError.ts +1 -1
  100. package/src/utility/VectorSizeError.ts +14 -0
  101. package/src/utility/createAxisAngleLike.ts +14 -0
@@ -1,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
- return new Float32Array(8);
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.sqrt(ax * ax + ay * ay + az * az); // `Math.hypot` is slower.
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 a dual quaternion with the given values.
623
- * @param x1 - The first real component.
624
- * @param y1 - The second real component.
625
- * @param z1 - The third real component.
626
- * @param w1 - The fourth real component.
627
- * @param x2 - The first dual component.
628
- * @param y2 - The second dual component.
629
- * @param z2 - The third dual component.
630
- * @param w2 - The fourth dual component.
631
- * @param out - The dual quaternion to store the result in.
632
- * @returns A new dual quaternion.
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 fromValues(x1, y1, z1, w1, x2, y2, z2, w2, out = new DualQuaternion()) {
635
- return fromValues(x1, y1, z1, w1, x2, y2, z2, w2, out);
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, out = new DualQuaternion()) {
645
- return fromRotationTranslation(q, t, out);
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, out = new DualQuaternion()) {
654
- return fromTranslation(t, out);
691
+ static fromTranslation(t) {
692
+ return fromTranslation(t, new DualQuaternion());
655
693
  }
656
694
  /**
657
- * Create a dual quaternion from the given rotation.
658
- * @param q - The rotation quaternion.
659
- * @param out - The dual quaternion to store the result in.
660
- * @returns The dual quaternion.
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 fromRotation(q, out = new DualQuaternion()) {
663
- return fromRotation(q, out);
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
- * Create a dual quaternion from the given four-by-four matrix.
667
- * @param matrix - The matrix.
668
- * @param out - The dual quaternion to store the result in.
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
- static fromMatrix4(matrix, out = new DualQuaternion()) {
672
- return fromMatrix4(matrix, out);
714
+ add(dq) {
715
+ return add(this, dq, new DualQuaternion());
673
716
  }
674
717
  /**
675
- * Create an identity dual quaternion.
676
- * @see {@link https://en.wikipedia.org/wiki/Dual_quaternion | Dual quaternion}
718
+ * Copy the values from this dual quaternion to another one.
719
+ * @returns The copy.
677
720
  */
678
- constructor() {
679
- super(8);
680
- this[3] = 1;
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
- * Copy the values from this dual quaternion to another one.
708
- * @param out - The dual quaternion to store the result in.
709
- * @returns The copy.
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
- identity() {
719
- return identity(this);
745
+ dot(dq) {
746
+ return dot(this, dq);
720
747
  }
721
748
  /**
722
- * Get the real part of this dual quaternion.
723
- * @param out - The quaternion to store the result in.
724
- * @returns The real part.
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
- getReal(out = new Quaternion()) {
727
- return getReal(this, out);
753
+ equals(dq) {
754
+ return equals(this, dq);
728
755
  }
729
756
  /**
730
- * Set the real part of this dual quaternion.
731
- * @param q - The quaternion.
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
- setReal(q) {
734
- setReal(q, this);
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(out = new Quaternion()) {
742
- return getDual(this, out);
768
+ getDual() {
769
+ return getDual(this, new Quaternion());
743
770
  }
744
771
  /**
745
- * Set the real part of this dual quaternion.
746
- * @param q - The quaternion.
772
+ * Get the real part of this dual quaternion.
773
+ * @returns The real part.
747
774
  */
748
- setDual(q) {
749
- setDual(q, this);
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(out = new Vector3()) {
757
- return getTranslation(this, out);
782
+ getTranslation() {
783
+ return getTranslation(this, new Vector3());
758
784
  }
759
785
  /**
760
- * Translate this dual quaternion by the given vector.
761
- * @param v - The vector.
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
- translate(v, out = new DualQuaternion()) {
766
- return translate(this, v, out);
789
+ identity() {
790
+ return identity(this);
767
791
  }
768
792
  /**
769
- * Rotate this dual quaternion around the X-axis.
770
- * @param r - The angle to rotate by in radians.
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
- rotateX(r, out = new DualQuaternion()) {
775
- return rotateX(this, r, out);
796
+ invert() {
797
+ return invert(this, new DualQuaternion());
776
798
  }
777
799
  /**
778
- * Rotate this dual quaternion around the Y-axis.
779
- * @param r - The angle to rotate by in radians.
780
- * @param out - The dual quaternion to store the result in.
781
- * @returns The rotated dual quaternion.
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
- rotateY(r, out = new DualQuaternion()) {
784
- return rotateY(this, r, out);
805
+ lerp(dq, t) {
806
+ return lerp(this, dq, t, new DualQuaternion());
785
807
  }
786
808
  /**
787
- * Rotate this dual quaternion around the Z-axis.
788
- * @param r - The angle to rotate by in radians.
789
- * @param out - The dual quaternion to store the result in.
790
- * @returns The rotated dual quaternion.
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
- rotateZ(r, out = new DualQuaternion()) {
793
- return rotateZ(this, r, out);
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, out = new DualQuaternion()) {
803
- return rotateByQuaternionAppend(this, q, out);
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, out = new DualQuaternion()) {
813
- return rotateByQuaternionPrepend(q, this, out);
847
+ rotateByQuaternionPrepend(q) {
848
+ return rotateByQuaternionPrepend(q, this, new DualQuaternion());
814
849
  }
815
850
  /**
816
- * Rotate this dual quaternion around an axis.
817
- * @param axis - The axis.
818
- * @param r - The angle of the rotation in radians.
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
- rotateAroundAxis(axis, r, out = new DualQuaternion()) {
823
- return rotateAroundAxis(this, axis, r, out);
855
+ rotateX(r) {
856
+ return rotateX(this, r, new DualQuaternion());
824
857
  }
825
858
  /**
826
- * Add another dual quaternion to this one.
827
- * @param dq - The other dual quaternion.
828
- * @param out - The dual quaternion to store the result in.
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
- add(dq, out = new DualQuaternion()) {
832
- return add(this, dq, out);
863
+ rotateY(r) {
864
+ return rotateY(this, r, new DualQuaternion());
833
865
  }
834
866
  /**
835
- * Multiply this dual quaternion by another one.
836
- * @param dq - The other dual quaternion.
837
- * @param out - The dual quaternion to store the result in.
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
- multiply(dq, out = new DualQuaternion()) {
841
- return multiply(this, dq, out);
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, out = new DualQuaternion()) {
850
- return scale(this, s, out);
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
- * Calculate the conjugate of this dual quaternion. If this dual quaternion is normalized, this is equivalent to its inverse and faster to calculate.
881
- * @param out - The dual quaternion to store the result in.
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
- normalize(out = new DualQuaternion()) {
901
- return normalize(this, out);
886
+ setDual(q) {
887
+ setDual(q, this);
902
888
  }
903
889
  /**
904
- * Determine whether or not this dual quaternion is exactly equivalent to another.
905
- * @param dq - The other dual quaternion.
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
- exactEquals(dq) {
909
- return exactEquals(this, dq);
893
+ setReal(q) {
894
+ setReal(q, this);
910
895
  }
911
896
  /**
912
- * Determine whether or not this dual quaternion is roughly equivalent to another.
913
- * @param dq - The other dual quaternion.
914
- * @returns Whether or not the dual quaternions are equivalent.
897
+ * Translate this dual quaternion by the given vector.
898
+ * @param v - The vector.
899
+ * @returns The translated dual quaternion.
915
900
  */
916
- equals(dq) {
917
- return equals(this, dq);
901
+ translate(v) {
902
+ return translate(this, v, new DualQuaternion());
918
903
  }
919
904
  }
920
905
  //# sourceMappingURL=DualQuaternion.js.map