@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
@@ -4,9 +4,9 @@ import approxRelative from "../algorithms/approxRelative.js";
4
4
  * @returns A 3x1 vector-like object.
5
5
  * @public
6
6
  */
7
- export const createVector3Like = () => {
8
- return new Float32Array(3);
9
- };
7
+ export const createVector3Like = () =>
8
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
9
+ new Float32Array(3);
10
10
  /**
11
11
  * Create a vector with the given values.
12
12
  * @param x - The first component.
@@ -170,12 +170,7 @@ export const scaleAndAdd = (a, b, scalar, out) => fromValues(a[0] + b[0] * scala
170
170
  * @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
171
171
  * @public
172
172
  */
173
- export const distance = (a, b) => {
174
- const x = b[0] - a[0];
175
- const y = b[1] - a[1];
176
- const z = b[2] - a[2];
177
- return Math.sqrt(x * x + y * y + z * z); // `Math.hypot` is slower.
178
- };
173
+ export const distance = (a, b) => Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
179
174
  /**
180
175
  * Calculate the squared Euclidean distance between this vector and another.
181
176
  * @param a - The first vector.
@@ -196,12 +191,7 @@ export const squaredDistance = (a, b) => {
196
191
  * @returns The magnitude.
197
192
  * @public
198
193
  */
199
- export const getMagnitude = (vector) => {
200
- const x = vector[0];
201
- const y = vector[1];
202
- const z = vector[2];
203
- return Math.sqrt(x * x + y * y + z * z); // `Math.hypot` is slower.
204
- };
194
+ export const getMagnitude = (vector) => Math.hypot(vector[0], vector[1], vector[2]);
205
195
  /**
206
196
  * Calculate the squared magnitude (length) of a vector.
207
197
  * @param vector - The vector.
@@ -414,15 +404,7 @@ export const rotateZ = (vector, origin, r, out) => {
414
404
  * @public
415
405
  */
416
406
  export const angle = (a, b) => {
417
- const ax = a[0];
418
- const ay = a[1];
419
- const az = a[2];
420
- const bx = b[0];
421
- const by = b[1];
422
- const bz = b[2];
423
- // `Math.hypot` is slower.
424
- const mag = Math.sqrt(ax * ax + ay * ay + az * az) *
425
- Math.sqrt(bx * bx + by * by + bz * bz);
407
+ const mag = Math.hypot(a[0], a[1], a[2]) * Math.hypot(b[0], b[1], b[2]);
426
408
  return Math.acos(Math.min(Math.max(mag && dot(a, b) / mag, -1), 1));
427
409
  };
428
410
  /**
@@ -503,62 +485,94 @@ export const transformQuaternion = (vector, quaternion, out) => {
503
485
  * @public
504
486
  */
505
487
  export default class Vector3 extends Float32Array {
488
+ /** The first component of this vector. */
489
+ // eslint-disable-next-line @typescript-eslint/naming-convention
490
+ 0;
491
+ /** The second component of this vector. */
492
+ // eslint-disable-next-line @typescript-eslint/naming-convention
493
+ 1;
494
+ /** The third component of this vector. */
495
+ // eslint-disable-next-line @typescript-eslint/naming-convention
496
+ 2;
497
+ /** The magnitude (length) of this vector. */
498
+ get magnitude() {
499
+ return getMagnitude(this);
500
+ }
501
+ set magnitude(value) {
502
+ scale(normalize(this, this), value, this);
503
+ }
504
+ /** The squared magnitude (length) of this vector. */
505
+ get squaredMagnitude() {
506
+ return getSquaredMagnitude(this);
507
+ }
508
+ set squaredMagnitude(value) {
509
+ this.magnitude = Math.sqrt(value);
510
+ }
511
+ /**
512
+ * Create a three-dimensional zero vector.
513
+ * @see {@link https://en.wikipedia.org/wiki/Euclidean_vector | Euclidean vector}
514
+ */
515
+ constructor() {
516
+ super(3);
517
+ }
506
518
  /**
507
519
  * Create a vector with the given values.
508
520
  * @param x - The first component.
509
521
  * @param y - The second component.
510
522
  * @param z - The third component.
511
- * @param out - The vector to store the result in.
512
523
  * @returns A new vector.
513
524
  */
514
- static fromValues(x, y, z, out = new Vector3()) {
515
- return fromValues(x, y, z, out);
525
+ static fromValues(x, y, z) {
526
+ return fromValues(x, y, z, new Vector3());
516
527
  }
517
528
  /**
518
- * Create a three-dimensional zero vector.
519
- * @see {@link https://en.wikipedia.org/wiki/Euclidean_vector | Euclidean vector}
529
+ * Absolutize the components of this vector.
530
+ * @returns The absolutized vector.
520
531
  */
521
- constructor() {
522
- super(3);
532
+ abs() {
533
+ return abs(this, new Vector3());
523
534
  }
524
- /** The first component of this vector. */
525
- 0;
526
- /** The second component of this vector. */
527
- 1;
528
- /** The third component of this vector. */
529
- 2;
530
535
  /**
531
- * Determine whether or not this vector is roughly equivalent to another.
536
+ * Add two vectors of the same size.
532
537
  * @param vector - The other vector.
533
- * @returns Whether or not the vectors are equivalent.
538
+ * @returns The sum of the vectors.
534
539
  */
535
- equals(vector) {
536
- return equals(this, vector);
540
+ add(vector) {
541
+ return add(this, vector, new Vector3());
537
542
  }
538
543
  /**
539
- * Determine whether or not this vector is exactly equivalent to another.
544
+ * Get the angle from this vector to another in radians.
540
545
  * @param vector - The other vector.
541
- * @returns Whether or not the vectors are equivalent.
546
+ * @returns The angular distance from this vector to the other.
542
547
  */
543
- exactEquals(vector) {
544
- return exactEquals(this, vector);
548
+ angle(vector) {
549
+ return angle(this, vector);
545
550
  }
546
551
  /**
547
- * Add two vectors of the same size.
548
- * @param vector - The other vector.
549
- * @param out - The vector to store the result in.
550
- * @returns The sum of the vectors.
552
+ * Perform a Bézier interpolation with two control points between this vector and another.
553
+ * @param a - The first control point.
554
+ * @param b - The second control point.
555
+ * @param end - The other vector.
556
+ * @param t - The interpolation amount in the range `[0,1]`.
557
+ * @returns The interpolated vector.
558
+ * @see {@link https://en.wikipedia.org/wiki/B%C3%A9zier_curve | Bézier curve}
559
+ */
560
+ bezier(a, b, end, t) {
561
+ return bezier(this, a, b, end, t, new Vector3());
562
+ }
563
+ /**
564
+ * Round up the components of this vector.
565
+ * @returns The rounded vector.
551
566
  */
552
- add(vector, out = new Vector3()) {
553
- return add(this, vector, out);
567
+ ceil() {
568
+ return ceil(this, new Vector3());
554
569
  }
555
570
  /**
556
571
  * Copy the values from this vector to another one.
557
- * @param out - The vector to store the result in.
558
572
  * @returns The copy.
559
573
  */
560
- clone(out = new Vector3()) {
561
- return copy(this, out);
574
+ clone() {
575
+ return copy(this, new Vector3());
562
576
  }
563
577
  /**
564
578
  * Copy the values of another vector into this one.
@@ -569,190 +583,138 @@ export default class Vector3 extends Float32Array {
569
583
  return copy(vector, this);
570
584
  }
571
585
  /**
572
- * Multiply this vector by another.
586
+ * Calculate the cross product of this and another vector.
573
587
  * @param vector - The other vector.
574
- * @param out - The vector to store the result in.
575
- * @returns The product of the vectors.
588
+ * @returns The cross product.
589
+ * @see {@link https://en.wikipedia.org/wiki/Cross_product | Cross product}
590
+ */
591
+ cross(vector) {
592
+ return cross(this, vector, new Vector3());
593
+ }
594
+ /**
595
+ * Calculate the Euclidean distance between this vector and another.
596
+ * @param vector - The other vector.
597
+ * @returns The distance.
598
+ * @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
576
599
  */
577
- multiply(vector, out = new Vector3()) {
578
- return multiply(this, vector, out);
600
+ distance(vector) {
601
+ return distance(this, vector);
579
602
  }
580
603
  /**
581
604
  * Divide this vector by another.
582
605
  * @param vector - The other vector.
583
- * @param out - The vector to store the result in.
584
606
  * @returns The quotient of the vectors.
585
607
  */
586
- divide(vector, out = new Vector3()) {
587
- return divide(this, vector, out);
608
+ divide(vector) {
609
+ return divide(this, vector, new Vector3());
588
610
  }
589
611
  /**
590
- * Subtract another vector from this one.
612
+ * Calculate the dot product of this and another vector.
591
613
  * @param vector - The other vector.
592
- * @param out - The vector to store the result in.
593
- * @returns The difference between the vectors.
614
+ * @returns The dot product.
615
+ * @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
594
616
  */
595
- subtract(vector, out = new Vector3()) {
596
- return subtract(this, vector, out);
617
+ dot(vector) {
618
+ return dot(this, vector);
597
619
  }
598
620
  /**
599
- * Absolutize the components of this vector.
600
- * @param out - The vector to store the result in.
601
- * @returns The absolutized vector.
621
+ * Determine whether or not this vector is roughly equivalent to another.
622
+ * @param vector - The other vector.
623
+ * @returns Whether or not the vectors are equivalent.
602
624
  */
603
- abs(out = new Vector3()) {
604
- return abs(this, out);
625
+ equals(vector) {
626
+ return equals(this, vector);
605
627
  }
606
628
  /**
607
- * Round up the components of this vector.
608
- * @param out - The vector to store the result in.
609
- * @returns The rounded vector.
629
+ * Determine whether or not this vector is exactly equivalent to another.
630
+ * @param vector - The other vector.
631
+ * @returns Whether or not the vectors are equivalent.
610
632
  */
611
- ceil(out = new Vector3()) {
612
- return ceil(this, out);
633
+ exactEquals(vector) {
634
+ return exactEquals(this, vector);
613
635
  }
614
636
  /**
615
637
  * Round down the components of this vector.
616
- * @param out - The vector to store the result in.
617
638
  * @returns The rounded vector.
618
639
  */
619
- floor(out = new Vector3()) {
620
- return floor(this, out);
640
+ floor() {
641
+ return floor(this, new Vector3());
621
642
  }
622
643
  /**
623
- * Round the components of this vector.
624
- * @param out - The vector to store the result in.
625
- * @returns The rounded vector.
644
+ * Perform a Hermite interpolation with two control points between this vector and another.
645
+ * @param a - The first control point.
646
+ * @param b - The second control point.
647
+ * @param end - The other vector.
648
+ * @param t - The interpolation amount in the range `[0,1]`.
649
+ * @returns The interpolated vector.
650
+ * @see {@link https://en.wikipedia.org/wiki/Hermite_interpolation | Hermite interpolation}
626
651
  */
627
- round(out = new Vector3()) {
628
- return round(this, out);
652
+ hermite(a, b, end, t) {
653
+ return hermite(this, a, b, end, t, new Vector3());
629
654
  }
630
655
  /**
631
- * Return the minimum of this and another vector.
632
- * @param vector - The other vector.
633
- * @param out - The vector to store the result in.
634
- * @returns The minimum.
656
+ * Calculate the multiplicative inverse of the components of this vector.
657
+ * @returns The inverted vector.
635
658
  */
636
- min(vector, out = new Vector3()) {
637
- return min(this, vector, out);
659
+ invert() {
660
+ return invert(this, new Vector3());
638
661
  }
639
662
  /**
640
- * Return the maximum of this and another vector.
663
+ * Perform a linear interpolation between this and another vector.
641
664
  * @param vector - The other vector.
642
- * @param out - The vector to store the result in.
643
- * @returns The maximum.
644
- */
645
- max(vector, out = new Vector3()) {
646
- return max(this, vector, out);
647
- }
648
- /**
649
- * Raise each component of this vector to the given power.
650
- * @param scalar - The exponent (power) to raise each component to.
651
- * @param out - The vector to store the result in.
652
- * @returns The power (result of the exponentiation).
653
- */
654
- pow(scalar, out = new Vector3()) {
655
- return pow(this, scalar, out);
656
- }
657
- /**
658
- * Scale this vector by a scalar.
659
- * @param scalar - The scalar.
660
- * @param out - The vector to store the result in.
661
- * @returns The scaled vector.
665
+ * @param t - The interpolation amount (in `[0,1]`).
666
+ * @returns The interpolated vector.
667
+ * @see {@link https://en.wikipedia.org/wiki/Linear_interpolation | Linear interpolation}
662
668
  */
663
- scale(scalar, out = new Vector3()) {
664
- return scale(this, scalar, out);
669
+ lerp(vector, t) {
670
+ return lerp(this, vector, t, new Vector3());
665
671
  }
666
672
  /**
667
- * Add another vector to this one after scaling the other by a scalar.
673
+ * Return the maximum of this and another vector.
668
674
  * @param vector - The other vector.
669
- * @param scalar - The scalar.
670
- * @param out - The vector to store the result in.
671
- * @returns The sum.
675
+ * @returns The maximum.
672
676
  */
673
- scaleAndAdd(vector, scalar, out = new Vector3()) {
674
- return scaleAndAdd(this, vector, scalar, out);
677
+ max(vector) {
678
+ return max(this, vector, new Vector3());
675
679
  }
676
680
  /**
677
- * Calculate the Euclidean distance between this vector and another.
681
+ * Return the minimum of this and another vector.
678
682
  * @param vector - The other vector.
679
- * @returns The distance.
680
- * @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
683
+ * @returns The minimum.
681
684
  */
682
- distance(vector) {
683
- return distance(this, vector);
685
+ min(vector) {
686
+ return min(this, vector, new Vector3());
684
687
  }
685
688
  /**
686
- * Calculate the squared Euclidean distance between this vector and another.
689
+ * Multiply this vector by another.
687
690
  * @param vector - The other vector.
688
- * @returns The squared distance.
689
- * @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
691
+ * @returns The product of the vectors.
690
692
  */
691
- squaredDistance(vector) {
692
- return squaredDistance(this, vector);
693
- }
694
- /** Get the magnitude (length) of this vector. */
695
- get magnitude() {
696
- return getMagnitude(this);
697
- }
698
- /** Get the squared magnitude (length) of this vector. */
699
- get squaredMagnitude() {
700
- return getSquaredMagnitude(this);
693
+ multiply(vector) {
694
+ return multiply(this, vector, new Vector3());
701
695
  }
702
696
  /**
703
697
  * Negate this vector.
704
- * @param out - The vector to store the result in.
705
698
  * @returns The negated vector.
706
699
  */
707
- negate(out = new Vector3()) {
708
- return negate(this, out);
709
- }
710
- /**
711
- * Calculate the multiplicative inverse of the components of this vector.
712
- * @param out - The vector to store the result in.
713
- * @returns The inverted vector.
714
- */
715
- invert(out = new Vector3()) {
716
- return invert(this, out);
700
+ negate() {
701
+ return negate(this, new Vector3());
717
702
  }
718
703
  /**
719
704
  * Normalize this vector.
720
- * @param out - The vector to store the result in.
721
705
  * @returns The normalized vector.
722
706
  * @see {@link https://en.wikipedia.org/wiki/Unit_vector | Unit vector}
723
707
  */
724
- normalize(out = new Vector3()) {
725
- return normalize(this, out);
726
- }
727
- /**
728
- * Calculate the dot product of this and another vector.
729
- * @param vector - The other vector.
730
- * @returns The dot product.
731
- * @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
732
- */
733
- dot(vector) {
734
- return dot(this, vector);
735
- }
736
- /**
737
- * Calculate the cross product of this and another vector.
738
- * @param vector - The other vector.
739
- * @param out - The vector to store the result in.
740
- * @returns The cross product.
741
- * @see {@link https://en.wikipedia.org/wiki/Cross_product | Cross product}
742
- */
743
- cross(vector, out = new Vector3()) {
744
- return cross(this, vector, out);
708
+ normalize() {
709
+ return normalize(this, new Vector3());
745
710
  }
746
711
  /**
747
- * Perform a linear interpolation between this and another vector.
748
- * @param vector - The other vector.
749
- * @param t - The interpolation amount (in `[0,1]`).
750
- * @param out - The vector to store the result in.
751
- * @returns The interpolated vector.
752
- * @see {@link https://en.wikipedia.org/wiki/Linear_interpolation | Linear interpolation}
712
+ * Raise each component of this vector to the given power.
713
+ * @param scalar - The exponent (power) to raise each component to.
714
+ * @returns The power (result of the exponentiation).
753
715
  */
754
- lerp(vector, t, out = new Vector3()) {
755
- return lerp(this, vector, t, out);
716
+ pow(scalar) {
717
+ return pow(this, scalar, new Vector3());
756
718
  }
757
719
  /**
758
720
  * Set this vector to a random value with the given magnitude.
@@ -762,104 +724,105 @@ export default class Vector3 extends Float32Array {
762
724
  random(magnitude = 1) {
763
725
  return random(magnitude, this);
764
726
  }
765
- /**
766
- * Transform this vector by a three-by-three matrix.
767
- * @param matrix - The matrix.
768
- * @param out - The vector to store the result in.
769
- * @returns The transformed vector.
770
- */
771
- transformMatrix3(matrix, out = new Vector3()) {
772
- return transformMatrix3(this, matrix, out);
773
- }
774
- /**
775
- * Transform this vector by a four-by-four matrix.
776
- * @param matrix - The matrix.
777
- * @param out - The vector to store the result in.
778
- * @returns The transformed vector.
779
- */
780
- transformMatrix4(matrix, out = new Vector3()) {
781
- return transformMatrix4(this, matrix, out);
782
- }
783
727
  /**
784
728
  * Rotate this vector around the X-axis.
785
729
  * @param origin - The origin of the rotation.
786
730
  * @param r - The angle of rotation in radians.
787
- * @param out - The vector to store the result in.
788
731
  * @returns The rotated vector.
789
732
  */
790
- rotateX(origin, r, out = new Vector3()) {
791
- return rotateX(this, origin, r, out);
733
+ rotateX(origin, r) {
734
+ return rotateX(this, origin, r, new Vector3());
792
735
  }
793
736
  /**
794
737
  * Rotate this vector around the Y-axis.
795
738
  * @param origin - The origin of the rotation.
796
739
  * @param r - The angle of rotation in radians.
797
- * @param out - The vector to store the result in.
798
740
  * @returns The rotated vector.
799
741
  */
800
- rotateY(origin, r, out = new Vector3()) {
801
- return rotateY(this, origin, r, out);
742
+ rotateY(origin, r) {
743
+ return rotateY(this, origin, r, new Vector3());
802
744
  }
803
745
  /**
804
746
  * Rotate this vector around the Z-axis.
805
747
  * @param origin - The origin of the rotation.
806
748
  * @param r - The angle of rotation in radians.
807
- * @param out - The vector to store the result in.
808
749
  * @returns The rotated vector.
809
750
  */
810
- rotateZ(origin, r, out = new Vector3()) {
811
- return rotateZ(this, origin, r, out);
751
+ rotateZ(origin, r) {
752
+ return rotateZ(this, origin, r, new Vector3());
812
753
  }
813
754
  /**
814
- * Get the angle from this vector to another in radians.
755
+ * Round the components of this vector.
756
+ * @returns The rounded vector.
757
+ */
758
+ round() {
759
+ return round(this, new Vector3());
760
+ }
761
+ /**
762
+ * Scale this vector by a scalar.
763
+ * @param scalar - The scalar.
764
+ * @returns The scaled vector.
765
+ */
766
+ scale(scalar) {
767
+ return scale(this, scalar, new Vector3());
768
+ }
769
+ /**
770
+ * Add another vector to this one after scaling the other by a scalar.
815
771
  * @param vector - The other vector.
816
- * @returns The angular distance from this vector to the other.
772
+ * @param scalar - The scalar.
773
+ * @returns The sum.
817
774
  */
818
- angle(vector) {
819
- return angle(this, vector);
775
+ scaleAndAdd(vector, scalar) {
776
+ return scaleAndAdd(this, vector, scalar, new Vector3());
820
777
  }
821
778
  /**
822
- * Set this to the zero vector.
823
- * @returns This vector.
779
+ * Calculate the squared Euclidean distance between this vector and another.
780
+ * @param vector - The other vector.
781
+ * @returns The squared distance.
782
+ * @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
824
783
  */
825
- zero() {
826
- return zero(this);
784
+ squaredDistance(vector) {
785
+ return squaredDistance(this, vector);
827
786
  }
828
787
  /**
829
- * Perform a Hermite interpolation with two control points between this vector and another.
830
- * @param a - The first control point.
831
- * @param b - The second control point.
832
- * @param end - The other vector.
833
- * @param t - The interpolation amount in the range `[0,1]`.
834
- * @param out - The vector to store the result in.
835
- * @returns The interpolated vector.
836
- * @see {@link https://en.wikipedia.org/wiki/Hermite_interpolation | Hermite interpolation}
788
+ * Subtract another vector from this one.
789
+ * @param vector - The other vector.
790
+ * @returns The difference between the vectors.
837
791
  */
838
- hermite(a, b, end, t, out = new Vector3()) {
839
- return hermite(this, a, b, end, t, out);
792
+ subtract(vector) {
793
+ return subtract(this, vector, new Vector3());
840
794
  }
841
795
  /**
842
- * Perform a Bézier interpolation with two control points between this vector and another.
843
- * @param a - The first control point.
844
- * @param b - The second control point.
845
- * @param end - The other vector.
846
- * @param t - The interpolation amount in the range `[0,1]`.
847
- * @param out - The vector to store the result in.
848
- * @returns The interpolated vector.
849
- * @see {@link https://en.wikipedia.org/wiki/B%C3%A9zier_curve | Bézier curve}
796
+ * Transform this vector by a three-by-three matrix.
797
+ * @param matrix - The matrix.
798
+ * @returns The transformed vector.
799
+ */
800
+ transformMatrix3(matrix) {
801
+ return transformMatrix3(this, matrix, new Vector3());
802
+ }
803
+ /**
804
+ * Transform this vector by a four-by-four matrix.
805
+ * @param matrix - The matrix.
806
+ * @returns The transformed vector.
850
807
  */
851
- bezier(a, b, end, t, out = new Vector3()) {
852
- return bezier(this, a, b, end, t, out);
808
+ transformMatrix4(matrix) {
809
+ return transformMatrix4(this, matrix, new Vector3());
853
810
  }
854
811
  /**
855
812
  * Transform this vector by a quaternion.
856
813
  * @param quaternion - The quaternion.
857
- * @param out - The vector to store the result in.
858
814
  * @returns The transformed vector.
859
815
  * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
860
816
  */
861
- transformQuaternion(quaternion, out = new Vector3()) {
862
- return transformQuaternion(this, quaternion, out);
817
+ transformQuaternion(quaternion) {
818
+ return transformQuaternion(this, quaternion, new Vector3());
819
+ }
820
+ /**
821
+ * Set this to the zero vector.
822
+ * @returns This vector.
823
+ */
824
+ zero() {
825
+ return zero(this);
863
826
  }
864
827
  }
865
828
  //# sourceMappingURL=Vector3.js.map