@lakuna/umath 1.3.8 → 1.4.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 (163) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -0
  3. package/dist/algorithms/approx.d.ts +9 -0
  4. package/dist/algorithms/approx.d.ts.map +1 -0
  5. package/dist/algorithms/approx.js +12 -0
  6. package/dist/algorithms/approx.js.map +1 -0
  7. package/dist/algorithms/approxRelative.d.ts +9 -0
  8. package/dist/algorithms/approxRelative.d.ts.map +1 -0
  9. package/dist/algorithms/approxRelative.js +12 -0
  10. package/dist/algorithms/approxRelative.js.map +1 -0
  11. package/dist/algorithms/combinations.d.ts +2 -1
  12. package/dist/algorithms/combinations.d.ts.map +1 -1
  13. package/dist/algorithms/combinations.js +2 -1
  14. package/dist/algorithms/combinations.js.map +1 -1
  15. package/dist/algorithms/degreesToRadians.d.ts +3 -2
  16. package/dist/algorithms/degreesToRadians.d.ts.map +1 -1
  17. package/dist/algorithms/degreesToRadians.js +5 -3
  18. package/dist/algorithms/degreesToRadians.js.map +1 -1
  19. package/dist/algorithms/factorial.d.ts +2 -1
  20. package/dist/algorithms/factorial.d.ts.map +1 -1
  21. package/dist/algorithms/factorial.js +2 -1
  22. package/dist/algorithms/factorial.js.map +1 -1
  23. package/dist/algorithms/fibonacci.d.ts +2 -1
  24. package/dist/algorithms/fibonacci.d.ts.map +1 -1
  25. package/dist/algorithms/fibonacci.js +6 -2
  26. package/dist/algorithms/fibonacci.js.map +1 -1
  27. package/dist/algorithms/greatestCommonDivisor.d.ts +4 -2
  28. package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
  29. package/dist/algorithms/greatestCommonDivisor.js +5 -2
  30. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  31. package/dist/algorithms/hypergeometricPmf.d.ts +3 -2
  32. package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
  33. package/dist/algorithms/hypergeometricPmf.js +3 -2
  34. package/dist/algorithms/hypergeometricPmf.js.map +1 -1
  35. package/dist/algorithms/isPrime.d.ts +2 -1
  36. package/dist/algorithms/isPrime.d.ts.map +1 -1
  37. package/dist/algorithms/isPrime.js +2 -1
  38. package/dist/algorithms/isPrime.js.map +1 -1
  39. package/dist/algorithms/permutations.d.ts +2 -1
  40. package/dist/algorithms/permutations.d.ts.map +1 -1
  41. package/dist/algorithms/permutations.js +2 -1
  42. package/dist/algorithms/permutations.js.map +1 -1
  43. package/dist/algorithms/primeFactorization.d.ts +2 -1
  44. package/dist/algorithms/primeFactorization.d.ts.map +1 -1
  45. package/dist/algorithms/primeFactorization.js +4 -4
  46. package/dist/algorithms/primeFactorization.js.map +1 -1
  47. package/dist/algorithms/radiansToDegrees.d.ts +3 -2
  48. package/dist/algorithms/radiansToDegrees.d.ts.map +1 -1
  49. package/dist/algorithms/radiansToDegrees.js +5 -3
  50. package/dist/algorithms/radiansToDegrees.js.map +1 -1
  51. package/dist/algorithms/summation.d.ts +2 -1
  52. package/dist/algorithms/summation.d.ts.map +1 -1
  53. package/dist/algorithms/summation.js +2 -1
  54. package/dist/algorithms/summation.js.map +1 -1
  55. package/dist/linalg/DualQuaternion.d.ts +102 -32
  56. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  57. package/dist/linalg/DualQuaternion.js +249 -275
  58. package/dist/linalg/DualQuaternion.js.map +1 -1
  59. package/dist/linalg/Matrix.d.ts +14 -10
  60. package/dist/linalg/Matrix.d.ts.map +1 -1
  61. package/dist/linalg/Matrix2.d.ts +74 -51
  62. package/dist/linalg/Matrix2.d.ts.map +1 -1
  63. package/dist/linalg/Matrix2.js +96 -169
  64. package/dist/linalg/Matrix2.js.map +1 -1
  65. package/dist/linalg/Matrix3.d.ts +122 -72
  66. package/dist/linalg/Matrix3.d.ts.map +1 -1
  67. package/dist/linalg/Matrix3.js +205 -358
  68. package/dist/linalg/Matrix3.js.map +1 -1
  69. package/dist/linalg/Matrix4.d.ts +267 -150
  70. package/dist/linalg/Matrix4.d.ts.map +1 -1
  71. package/dist/linalg/Matrix4.js +553 -864
  72. package/dist/linalg/Matrix4.js.map +1 -1
  73. package/dist/linalg/Quaternion.d.ts +252 -34
  74. package/dist/linalg/Quaternion.d.ts.map +1 -1
  75. package/dist/linalg/Quaternion.js +436 -166
  76. package/dist/linalg/Quaternion.js.map +1 -1
  77. package/dist/linalg/SlowMatrix.d.ts +10 -9
  78. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  79. package/dist/linalg/SlowMatrix.js +10 -9
  80. package/dist/linalg/SlowMatrix.js.map +1 -1
  81. package/dist/linalg/SlowSquareMatrix.d.ts +10 -9
  82. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  83. package/dist/linalg/SlowSquareMatrix.js +10 -9
  84. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  85. package/dist/linalg/SquareMatrix.d.ts +6 -5
  86. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  87. package/dist/linalg/Vector.d.ts +8 -4
  88. package/dist/linalg/Vector.d.ts.map +1 -1
  89. package/dist/linalg/Vector2.d.ts +82 -31
  90. package/dist/linalg/Vector2.d.ts.map +1 -1
  91. package/dist/linalg/Vector2.js +112 -154
  92. package/dist/linalg/Vector2.js.map +1 -1
  93. package/dist/linalg/Vector3.d.ts +93 -41
  94. package/dist/linalg/Vector3.d.ts.map +1 -1
  95. package/dist/linalg/Vector3.js +171 -282
  96. package/dist/linalg/Vector3.js.map +1 -1
  97. package/dist/linalg/Vector4.d.ts +71 -21
  98. package/dist/linalg/Vector4.d.ts.map +1 -1
  99. package/dist/linalg/Vector4.js +121 -195
  100. package/dist/linalg/Vector4.js.map +1 -1
  101. package/dist/types/AxisAngle.d.ts +4 -1
  102. package/dist/types/AxisAngle.d.ts.map +1 -1
  103. package/dist/types/FieldOfView.d.ts +4 -1
  104. package/dist/types/FieldOfView.d.ts.map +1 -1
  105. package/dist/utility/BigNumber.d.ts +4 -1
  106. package/dist/utility/BigNumber.d.ts.map +1 -1
  107. package/dist/utility/BigNumber.js +4 -1
  108. package/dist/utility/BigNumber.js.map +1 -1
  109. package/dist/utility/MagnitudeError.d.ts +4 -1
  110. package/dist/utility/MagnitudeError.d.ts.map +1 -1
  111. package/dist/utility/MagnitudeError.js +4 -1
  112. package/dist/utility/MagnitudeError.js.map +1 -1
  113. package/dist/utility/MatrixSizeError.d.ts +4 -1
  114. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  115. package/dist/utility/MatrixSizeError.js +4 -1
  116. package/dist/utility/MatrixSizeError.js.map +1 -1
  117. package/dist/utility/PartialMatrixError.d.ts +4 -1
  118. package/dist/utility/PartialMatrixError.d.ts.map +1 -1
  119. package/dist/utility/PartialMatrixError.js +4 -1
  120. package/dist/utility/PartialMatrixError.js.map +1 -1
  121. package/dist/utility/SingularMatrixError.d.ts +2 -1
  122. package/dist/utility/SingularMatrixError.d.ts.map +1 -1
  123. package/dist/utility/SingularMatrixError.js +2 -1
  124. package/dist/utility/SingularMatrixError.js.map +1 -1
  125. package/dist/utility/epsilon.d.ts +4 -1
  126. package/dist/utility/epsilon.d.ts.map +1 -1
  127. package/dist/utility/epsilon.js +4 -1
  128. package/dist/utility/epsilon.js.map +1 -1
  129. package/package.json +14 -18
  130. package/src/algorithms/approx.ts +12 -0
  131. package/src/algorithms/approxRelative.ts +12 -0
  132. package/src/algorithms/combinations.ts +2 -1
  133. package/src/algorithms/degreesToRadians.ts +6 -3
  134. package/src/algorithms/factorial.ts +3 -1
  135. package/src/algorithms/fibonacci.ts +7 -2
  136. package/src/algorithms/greatestCommonDivisor.ts +9 -4
  137. package/src/algorithms/hypergeometricPmf.ts +3 -2
  138. package/src/algorithms/isPrime.ts +2 -1
  139. package/src/algorithms/permutations.ts +2 -1
  140. package/src/algorithms/primeFactorization.ts +5 -3
  141. package/src/algorithms/radiansToDegrees.ts +6 -3
  142. package/src/algorithms/summation.ts +2 -1
  143. package/src/linalg/DualQuaternion.ts +430 -292
  144. package/src/linalg/Matrix.ts +14 -10
  145. package/src/linalg/Matrix2.ts +143 -185
  146. package/src/linalg/Matrix3.ts +421 -385
  147. package/src/linalg/Matrix4.ts +1147 -952
  148. package/src/linalg/Quaternion.ts +706 -188
  149. package/src/linalg/SlowMatrix.ts +10 -9
  150. package/src/linalg/SlowSquareMatrix.ts +10 -9
  151. package/src/linalg/SquareMatrix.ts +6 -5
  152. package/src/linalg/Vector.ts +8 -4
  153. package/src/linalg/Vector2.ts +146 -173
  154. package/src/linalg/Vector3.ts +293 -326
  155. package/src/linalg/Vector4.ts +227 -215
  156. package/src/types/AxisAngle.ts +4 -1
  157. package/src/types/FieldOfView.ts +4 -1
  158. package/src/utility/BigNumber.ts +6 -3
  159. package/src/utility/MagnitudeError.ts +4 -1
  160. package/src/utility/MatrixSizeError.ts +4 -1
  161. package/src/utility/PartialMatrixError.ts +4 -1
  162. package/src/utility/SingularMatrixError.ts +2 -1
  163. package/src/utility/epsilon.ts +4 -1
@@ -1,9 +1,8 @@
1
- import Quaternion, {} from "./Quaternion.js";
2
- import epsilon from "../utility/epsilon.js";
3
- import { normalize as normalizeVector4 } from "./Vector4.js";
1
+ import approxRelative from "../algorithms/approxRelative.js";
4
2
  /**
5
3
  * Creates a 3x1 vector-like object.
6
4
  * @returns A 3x1 vector-like object.
5
+ * @public
7
6
  */
8
7
  export const createVector3Like = () => {
9
8
  return new Float32Array(3);
@@ -15,6 +14,7 @@ export const createVector3Like = () => {
15
14
  * @param z - The third component.
16
15
  * @param out - The vector to store the result in.
17
16
  * @returns A new vector.
17
+ * @public
18
18
  */
19
19
  export const fromValues = (x, y, z, out) => {
20
20
  out[0] = x;
@@ -27,166 +27,122 @@ export const fromValues = (x, y, z, out) => {
27
27
  * @param a - The first vector.
28
28
  * @param b - The second vector.
29
29
  * @returns Whether or not the vectors are equivalent.
30
+ * @public
30
31
  */
31
- export const equals = (a, b) => {
32
- const a0 = a[0];
33
- const a1 = a[1];
34
- const a2 = a[2];
35
- const b0 = b[0];
36
- const b1 = b[1];
37
- const b2 = b[2];
38
- return (Math.abs(a0 - b0) <= epsilon * Math.max(1, Math.abs(a0), Math.abs(b0)) &&
39
- Math.abs(a1 - b1) <= epsilon * Math.max(1, Math.abs(a1), Math.abs(b1)) &&
40
- Math.abs(a2 - b2) <= epsilon * Math.max(1, Math.abs(a2), Math.abs(b2)));
41
- };
32
+ export const equals = (a, b) => approxRelative(a[0], b[0]) &&
33
+ approxRelative(a[1], b[1]) &&
34
+ approxRelative(a[2], b[2]);
42
35
  /**
43
36
  * Determine whether two vectors are exactly equivalent.
44
37
  * @param a - The first vector.
45
38
  * @param b - The second vector.
46
39
  * @returns Whether the vectors are equivalent.
40
+ * @public
47
41
  */
48
- export const exactEquals = (a, b) => {
49
- return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
50
- };
42
+ export const exactEquals = (a, b) => a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
51
43
  /**
52
44
  * Add two vectors.
53
45
  * @param a - The augend.
54
46
  * @param b - The addend.
55
47
  * @param out - The vector to store the result in.
56
48
  * @returns The sum.
49
+ * @public
57
50
  */
58
- export const add = (a, b, out) => {
59
- out[0] = a[0] + b[0];
60
- out[1] = a[1] + b[1];
61
- out[2] = a[2] + b[2];
62
- return out;
63
- };
51
+ export const add = (a, b, out) => fromValues(a[0] + b[0], a[1] + b[1], a[2] + b[2], out);
64
52
  /**
65
53
  * Copy the values from one vector to another.
66
54
  * @param vector - The vector to copy.
67
55
  * @param out - The vector to store the result in.
68
56
  * @returns The copy.
57
+ * @public
69
58
  */
70
- export const copy = (vector, out) => {
71
- out[0] = vector[0];
72
- out[1] = vector[1];
73
- out[2] = vector[2];
74
- return out;
75
- };
59
+ export const copy = (vector, out) => fromValues(vector[0], vector[1], vector[2], out);
76
60
  /**
77
61
  * Multiply two vectors.
78
62
  * @param a - The multiplier.
79
63
  * @param b - The multiplicand.
80
64
  * @param out - The vector to store the result in.
81
65
  * @returns The product.
66
+ * @public
82
67
  */
83
- export const multiply = (a, b, out) => {
84
- out[0] = a[0] * b[0];
85
- out[1] = a[1] * b[1];
86
- out[2] = a[2] * b[2];
87
- return out;
88
- };
68
+ export const multiply = (a, b, out) => fromValues(a[0] * b[0], a[1] * b[1], a[2] * b[2], out);
89
69
  /**
90
70
  * Divide two vectors.
91
71
  * @param a - The dividend.
92
72
  * @param b - The divisor.
93
73
  * @param out - The vector to store the result in.
94
74
  * @returns The quotient.
75
+ * @public
95
76
  */
96
- export const divide = (a, b, out) => {
97
- out[0] = a[0] / b[0];
98
- out[1] = a[1] / b[1];
99
- out[2] = a[2] / b[2];
100
- return out;
101
- };
77
+ export const divide = (a, b, out) => fromValues(a[0] / b[0], a[1] / b[1], a[2] / b[2], out);
102
78
  /**
103
79
  * Subtract two vectors.
104
80
  * @param a - The minuend.
105
81
  * @param b - The subtrahend.
106
82
  * @param out - The vector to store the result in.
107
83
  * @returns The difference.
84
+ * @public
108
85
  */
109
- export const subtract = (a, b, out) => {
110
- out[0] = a[0] - b[0];
111
- out[1] = a[1] - b[1];
112
- out[2] = a[2] - b[2];
113
- return out;
114
- };
86
+ export const subtract = (a, b, out) => fromValues(a[0] - b[0], a[1] - b[1], a[2] - b[2], out);
87
+ /**
88
+ * Absolutize the components of a vector.
89
+ * @param vector - The vector.
90
+ * @param out - The vector to store the result in.
91
+ * @returns The absolutized vector.
92
+ * @public
93
+ */
94
+ export const abs = (vector, out) => fromValues(Math.abs(vector[0]), Math.abs(vector[1]), Math.abs(vector[2]), out);
115
95
  /**
116
96
  * Round up the components of a vector.
117
97
  * @param vector - The vector.
118
98
  * @param out - The vector to store the result in.
119
99
  * @returns The rounded vector.
100
+ * @public
120
101
  */
121
- export const ceil = (vector, out) => {
122
- out[0] = Math.ceil(vector[0]);
123
- out[1] = Math.ceil(vector[1]);
124
- out[2] = Math.ceil(vector[2]);
125
- return out;
126
- };
102
+ export const ceil = (vector, out) => fromValues(Math.ceil(vector[0]), Math.ceil(vector[1]), Math.ceil(vector[2]), out);
127
103
  /**
128
104
  * Round down the components of a vector.
129
105
  * @param vector - The vector.
130
106
  * @param out - The vector to store the result in.
131
107
  * @returns The rounded vector.
108
+ * @public
132
109
  */
133
- export const floor = (vector, out) => {
134
- out[0] = Math.floor(vector[0]);
135
- out[1] = Math.floor(vector[1]);
136
- out[2] = Math.floor(vector[2]);
137
- return out;
138
- };
110
+ export const floor = (vector, out) => fromValues(Math.floor(vector[0]), Math.floor(vector[1]), Math.floor(vector[2]), out);
139
111
  /**
140
112
  * Round the components of a vector.
141
113
  * @param vector - The vector.
142
114
  * @param out - The vector to store the result in.
143
115
  * @returns The rounded vector.
116
+ * @public
144
117
  */
145
- export const round = (vector, out) => {
146
- out[0] = Math.round(vector[0]);
147
- out[1] = Math.round(vector[1]);
148
- out[2] = Math.round(vector[2]);
149
- return out;
150
- };
118
+ export const round = (vector, out) => fromValues(Math.round(vector[0]), Math.round(vector[1]), Math.round(vector[2]), out);
151
119
  /**
152
120
  * Return the minimum of two vectors.
153
121
  * @param a - The first vector.
154
122
  * @param b - The second vector.
155
123
  * @param out - The vector to store the result in.
156
124
  * @returns The minimum.
125
+ * @public
157
126
  */
158
- export const min = (a, b, out) => {
159
- out[0] = Math.min(a[0], b[0]);
160
- out[1] = Math.min(a[1], b[1]);
161
- out[2] = Math.min(a[2], b[2]);
162
- return out;
163
- };
127
+ export const min = (a, b, out) => fromValues(Math.min(a[0], b[0]), Math.min(a[1], b[1]), Math.min(a[2], b[2]), out);
164
128
  /**
165
129
  * Return the maximum of two vectors.
166
130
  * @param a - The first vector.
167
131
  * @param b - The second vector.
168
132
  * @param out - The vector to store the result in.
169
133
  * @returns The maximum.
134
+ * @public
170
135
  */
171
- export const max = (a, b, out) => {
172
- out[0] = Math.max(a[0], b[0]);
173
- out[1] = Math.max(a[1], b[1]);
174
- out[2] = Math.max(a[2], b[2]);
175
- return out;
176
- };
136
+ export const max = (a, b, out) => fromValues(Math.max(a[0], b[0]), Math.max(a[1], b[1]), Math.max(a[2], b[2]), out);
177
137
  /**
178
138
  * Scale a vector by a scalar.
179
139
  * @param vector - The multiplier.
180
140
  * @param scalar - The multiplicand.
181
141
  * @param out - The vector to store the result in.
182
142
  * @returns The product.
143
+ * @public
183
144
  */
184
- export const scale = (vector, scalar, out) => {
185
- out[0] = vector[0] * scalar;
186
- out[1] = vector[1] * scalar;
187
- out[2] = vector[2] * scalar;
188
- return out;
189
- };
145
+ export const scale = (vector, scalar, out) => fromValues(vector[0] * scalar, vector[1] * scalar, vector[2] * scalar, out);
190
146
  /**
191
147
  * Add two vectors after scaling the second by a scalar.
192
148
  * @param a - The augend.
@@ -194,32 +150,30 @@ export const scale = (vector, scalar, out) => {
194
150
  * @param scalar - The multiplicand.
195
151
  * @param out - The vector to store the result in.
196
152
  * @returns The sum.
153
+ * @public
197
154
  */
198
- export const scaleAndAdd = (a, b, scalar, out) => {
199
- out[0] = a[0] + b[0] * scalar;
200
- out[1] = a[1] + b[1] * scalar;
201
- out[2] = a[2] + b[2] * scalar;
202
- return out;
203
- };
155
+ export const scaleAndAdd = (a, b, scalar, out) => fromValues(a[0] + b[0] * scalar, a[1] + b[1] * scalar, a[2] + b[2] * scalar, out);
204
156
  /**
205
157
  * Calculate the Euclidean distance between two vectors.
206
158
  * @param a - The first vector.
207
159
  * @param b - The second vector.
208
160
  * @returns The distance.
209
- * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
161
+ * @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
162
+ * @public
210
163
  */
211
164
  export const distance = (a, b) => {
212
165
  const x = b[0] - a[0];
213
166
  const y = b[1] - a[1];
214
167
  const z = b[2] - a[2];
215
- return Math.hypot(x, y, z);
168
+ return Math.sqrt(x * x + y * y + z * z); // `Math.hypot` is slower.
216
169
  };
217
170
  /**
218
171
  * Calculate the squared Euclidean distance between this vector and another.
219
172
  * @param a - The first vector.
220
173
  * @param b - The second vector.
221
174
  * @returns The squared distance.
222
- * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
175
+ * @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
176
+ * @public
223
177
  */
224
178
  export const squaredDistance = (a, b) => {
225
179
  const x = b[0] - a[0];
@@ -231,17 +185,19 @@ export const squaredDistance = (a, b) => {
231
185
  * Calculate the magnitude (length) of a vector.
232
186
  * @param vector - The vector.
233
187
  * @returns The magnitude.
188
+ * @public
234
189
  */
235
190
  export const getMagnitude = (vector) => {
236
191
  const x = vector[0];
237
192
  const y = vector[1];
238
193
  const z = vector[2];
239
- return Math.hypot(x, y, z);
194
+ return Math.sqrt(x * x + y * y + z * z); // `Math.hypot` is slower.
240
195
  };
241
196
  /**
242
197
  * Calculate the squared magnitude (length) of a vector.
243
198
  * @param vector - The vector.
244
199
  * @returns The squared magnitude.
200
+ * @public
245
201
  */
246
202
  export const getSquaredMagnitude = (vector) => {
247
203
  const x = vector[0];
@@ -254,31 +210,24 @@ export const getSquaredMagnitude = (vector) => {
254
210
  * @param vector - The vector.
255
211
  * @param out - The vector to store the result in.
256
212
  * @returns The negated vector.
213
+ * @public
257
214
  */
258
- export const negate = (vector, out) => {
259
- out[0] = -vector[0];
260
- out[1] = -vector[1];
261
- out[2] = -vector[2];
262
- return out;
263
- };
215
+ export const negate = (vector, out) => fromValues(-vector[0], -vector[1], -vector[2], out);
264
216
  /**
265
217
  * Calculate the multiplicative inverse of the components of a vector.
266
218
  * @param vector - The vector.
267
219
  * @param out - The vector to store the result in.
268
220
  * @returns The inverted vector.
221
+ * @public
269
222
  */
270
- export const invert = (vector, out) => {
271
- out[0] = 1 / vector[0];
272
- out[1] = 1 / vector[1];
273
- out[2] = 1 / vector[2];
274
- return out;
275
- };
223
+ export const invert = (vector, out) => fromValues(1 / vector[0], 1 / vector[1], 1 / vector[2], out);
276
224
  /**
277
225
  * Normalize a vector.
278
226
  * @param vector - The vector.
279
227
  * @param out - The vector to store the result in.
280
228
  * @returns The normalized vector.
281
- * @see [Unit vector](https://en.wikipedia.org/wiki/Unit_vector)
229
+ * @see {@link https://en.wikipedia.org/wiki/Unit_vector | Unit vector}
230
+ * @public
282
231
  */
283
232
  export const normalize = (vector, out) => {
284
233
  const x = vector[0];
@@ -288,28 +237,25 @@ export const normalize = (vector, out) => {
288
237
  if (len > 0) {
289
238
  len = 1 / Math.sqrt(len);
290
239
  }
291
- out[0] = x * len;
292
- out[1] = y * len;
293
- out[2] = z * len;
294
- return out;
240
+ return fromValues(x * len, y * len, z * len, out);
295
241
  };
296
242
  /**
297
243
  * Calculate the dot product of two vectors.
298
244
  * @param a - The multiplier.
299
245
  * @param b - The multiplicand.
300
246
  * @returns The dot product.
301
- * @see [Dot product](https://en.wikipedia.org/wiki/Dot_product)
247
+ * @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
248
+ * @public
302
249
  */
303
- export const dot = (a, b) => {
304
- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
305
- };
250
+ export const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
306
251
  /**
307
252
  * Calculate the cross product of two vectors.
308
253
  * @param a - The multiplier.
309
254
  * @param b - The mutliplicand.
310
255
  * @param out - The vector to store the result in.
311
256
  * @returns The cross product.
312
- * @see [Cross product](https://en.wikipedia.org/wiki/Cross_product)
257
+ * @see {@link https://en.wikipedia.org/wiki/Cross_product | Cross product}
258
+ * @public
313
259
  */
314
260
  export const cross = (a, b, out) => {
315
261
  const ax = a[0];
@@ -318,10 +264,7 @@ export const cross = (a, b, out) => {
318
264
  const bx = b[0];
319
265
  const by = b[1];
320
266
  const bz = b[2];
321
- out[0] = ay * bz - az * by;
322
- out[1] = az * bx - ax * bz;
323
- out[2] = ax * by - ay * bx;
324
- return out;
267
+ return fromValues(ay * bz - az * by, az * bx - ax * bz, ax * by - ay * bx, out);
325
268
  };
326
269
  /**
327
270
  * Perform a linear interpolation between two vectors.
@@ -330,31 +273,44 @@ export const cross = (a, b, out) => {
330
273
  * @param t - The interpolation amount (in `[0,1]`).
331
274
  * @param out - The vector to store the result in.
332
275
  * @returns The interpolated vector.
333
- * @see [Linear interpolation](https://en.wikipedia.org/wiki/Linear_interpolation)
276
+ * @see {@link https://en.wikipedia.org/wiki/Linear_interpolation | Linear interpolation}
277
+ * @public
334
278
  */
335
279
  export const lerp = (a, b, t, out) => {
336
280
  const ax = a[0];
337
281
  const ay = a[1];
338
282
  const az = a[2];
339
- out[0] = ax + t * (b[0] - ax);
340
- out[1] = ay + t * (b[1] - ay);
341
- out[2] = az + t * (b[2] - az);
342
- return out;
283
+ return fromValues(ax + t * (b[0] - ax), ay + t * (b[1] - ay), az + t * (b[2] - az), out);
284
+ };
285
+ /**
286
+ * Perform a spherical linear interpolation between two vectors.
287
+ * @param a - The first vector.
288
+ * @param b - The second vector.
289
+ * @param t - The interpolation amount (in `[0,1]`).
290
+ * @param out - The vector to store the result in.
291
+ * @returns The interpolated vector.
292
+ * @see {@link https://en.wikipedia.org/wiki/Slerp | Slerp}
293
+ * @public
294
+ */
295
+ export const slerp = (a, b, t, out) => {
296
+ const angle = Math.acos(Math.min(Math.max(dot(a, b), -1), 1));
297
+ const s = Math.sin(angle);
298
+ const ratioA = Math.sin((1 - t) * angle) / s;
299
+ const ratioB = Math.sin(t * angle) / s;
300
+ return fromValues(ratioA * a[0] + ratioB * b[0], ratioA * a[1] + ratioB * b[1], ratioA * a[2] + ratioB * b[2], out);
343
301
  };
344
302
  /**
345
303
  * Set a vector to a random value with the given magnitude.
346
304
  * @param magnitude - The magnitude.
347
305
  * @param out - The vector to store the result in.
348
306
  * @returns This vector.
307
+ * @public
349
308
  */
350
309
  export const random = (magnitude, out) => {
351
310
  const r = Math.random() * 2 * Math.PI;
352
311
  const z = Math.random() * 2 - 1;
353
312
  const zScale = Math.sqrt(1 - z * z) * magnitude;
354
- out[0] = Math.cos(r) * zScale;
355
- out[1] = Math.sin(r) * zScale;
356
- out[2] = z * magnitude;
357
- return out;
313
+ return fromValues(Math.cos(r) * zScale, Math.sin(r) * zScale, z * magnitude, out);
358
314
  };
359
315
  /**
360
316
  * Transform a vector by a three-by-three matrix.
@@ -362,16 +318,14 @@ export const random = (magnitude, out) => {
362
318
  * @param matrix - The matrix (multiplicand).
363
319
  * @param out - The vector to store the result in.
364
320
  * @returns The transformed vector.
365
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
321
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
322
+ * @public
366
323
  */
367
324
  export const transformMatrix3 = (vector, matrix, out) => {
368
325
  const x = vector[0];
369
326
  const y = vector[1];
370
327
  const z = vector[2];
371
- out[0] = x * matrix[0] + y * matrix[3] + z * matrix[6];
372
- out[1] = x * matrix[1] + y * matrix[4] + z * matrix[7];
373
- out[2] = x * matrix[2] + y * matrix[5] + z * matrix[8];
374
- return out;
328
+ return fromValues(x * matrix[0] + y * matrix[3] + z * matrix[6], x * matrix[1] + y * matrix[4] + z * matrix[7], x * matrix[2] + y * matrix[5] + z * matrix[8], out);
375
329
  };
376
330
  /**
377
331
  * Transform a vector by a four-by-four matrix.
@@ -379,17 +333,15 @@ export const transformMatrix3 = (vector, matrix, out) => {
379
333
  * @param matrix - The matrix (multiplicand).
380
334
  * @param out - The vector to store the result in.
381
335
  * @returns The transformed vector.
382
- * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
336
+ * @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
337
+ * @public
383
338
  */
384
339
  export const transformMatrix4 = (vector, matrix, out) => {
385
340
  const x = vector[0];
386
341
  const y = vector[1];
387
342
  const z = vector[2];
388
343
  const w = matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15] || 1;
389
- out[0] = (matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12]) / w;
390
- out[1] = (matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13]) / w;
391
- out[2] = (matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14]) / w;
392
- return out;
344
+ return fromValues((matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12]) / w, (matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13]) / w, (matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14]) / w, out);
393
345
  };
394
346
  /**
395
347
  * Rotate a vector around the X-axis.
@@ -398,17 +350,16 @@ export const transformMatrix4 = (vector, matrix, out) => {
398
350
  * @param r - The angle of rotation in radians.
399
351
  * @param out - The vector to store the result in.
400
352
  * @returns The rotated vector.
353
+ * @public
401
354
  */
402
355
  export const rotateX = (vector, origin, r, out) => {
403
- const p0 = vector[0] - origin[0];
404
- const p1 = vector[1] - origin[1];
405
- const p2 = vector[2] - origin[2];
406
- const r1 = p1 * Math.cos(r) - p2 * Math.sin(r);
407
- const r2 = p1 * Math.sin(r) + p2 * Math.cos(r);
408
- out[0] = p0 + origin[0];
409
- out[1] = r1 + origin[1];
410
- out[2] = r2 + origin[2];
411
- return out;
356
+ const o1 = origin[1];
357
+ const o2 = origin[2];
358
+ const p1 = vector[1] - o1;
359
+ const p2 = vector[2] - o2;
360
+ const c = Math.cos(r);
361
+ const s = Math.sin(r);
362
+ return fromValues(vector[0], p1 * c - p2 * s + o1, p1 * s + p2 * c + o2, out);
412
363
  };
413
364
  /**
414
365
  * Rotate a vector around the Y-axis.
@@ -417,17 +368,16 @@ export const rotateX = (vector, origin, r, out) => {
417
368
  * @param r - The angle of rotation in radians.
418
369
  * @param out - The vector to store the result in.
419
370
  * @returns The rotated vector.
371
+ * @public
420
372
  */
421
373
  export const rotateY = (vector, origin, r, out) => {
422
- const p0 = vector[0] - origin[0];
423
- const p1 = vector[1] - origin[1];
424
- const p2 = vector[2] - origin[2];
425
- const r0 = p2 * Math.sin(r) + p0 * Math.cos(r);
426
- const r2 = p2 * Math.cos(r) - p0 * Math.sin(r);
427
- out[0] = r0 + origin[0];
428
- out[1] = p1 + origin[1];
429
- out[2] = r2 + origin[2];
430
- return out;
374
+ const o0 = origin[0];
375
+ const o2 = origin[2];
376
+ const p0 = vector[0] - o0;
377
+ const p2 = vector[2] - o2;
378
+ const c = Math.cos(r);
379
+ const s = Math.sin(r);
380
+ return fromValues(p2 * s + p0 * c + o0, vector[1], p2 * c - p0 * s + o2, out);
431
381
  };
432
382
  /**
433
383
  * Rotate a vector around the Z-axis.
@@ -436,23 +386,23 @@ export const rotateY = (vector, origin, r, out) => {
436
386
  * @param r - The angle of rotation in radians.
437
387
  * @param out - The vector to store the result in.
438
388
  * @returns The rotated vector.
389
+ * @public
439
390
  */
440
391
  export const rotateZ = (vector, origin, r, out) => {
441
- const p0 = vector[0] - origin[0];
442
- const p1 = vector[1] - origin[1];
443
- const p2 = vector[2] - origin[2];
444
- const r0 = p0 * Math.cos(r) - p1 * Math.sin(r);
445
- const r1 = p0 * Math.sin(r) + p1 * Math.cos(r);
446
- out[0] = r0 + origin[0];
447
- out[1] = r1 + origin[1];
448
- out[2] = p2 + origin[2];
449
- return out;
392
+ const o0 = origin[0];
393
+ const o1 = origin[1];
394
+ const p0 = vector[0] - o0;
395
+ const p1 = vector[1] - o1;
396
+ const c = Math.cos(r);
397
+ const s = Math.sin(r);
398
+ return fromValues(p0 * c - p1 * s + o0, p0 * s + p1 * c + o1, vector[2], out);
450
399
  };
451
400
  /**
452
401
  * Get the angle between two vectors in radians.
453
402
  * @param a - The first vector.
454
403
  * @param b - The second vector.
455
404
  * @returns The angular distance from the first vector to the second.
405
+ * @public
456
406
  */
457
407
  export const angle = (a, b) => {
458
408
  const ax = a[0];
@@ -461,23 +411,18 @@ export const angle = (a, b) => {
461
411
  const bx = b[0];
462
412
  const by = b[1];
463
413
  const bz = b[2];
464
- const mag1 = Math.sqrt(ax * ax + ay * ay + az * az);
465
- const mag2 = Math.sqrt(bx * bx + by * by + bz * bz);
466
- const mag = mag1 * mag2;
467
- const cosine = mag && dot(a, b) / mag;
468
- return Math.acos(Math.min(Math.max(cosine, -1), 1));
414
+ // `Math.hypot` is slower.
415
+ const mag = Math.sqrt(ax * ax + ay * ay + az * az) *
416
+ Math.sqrt(bx * bx + by * by + bz * bz);
417
+ return Math.acos(Math.min(Math.max(mag && dot(a, b) / mag, -1), 1));
469
418
  };
470
419
  /**
471
420
  * Set a vector to the zero vector.
472
421
  * @param out - The vector to store the result in.
473
422
  * @returns This vector.
423
+ * @public
474
424
  */
475
- export const zero = (out) => {
476
- out[0] = 0;
477
- out[1] = 0;
478
- out[2] = 0;
479
- return out;
480
- };
425
+ export const zero = (out) => fromValues(0, 0, 0, out);
481
426
  /**
482
427
  * Perform a Hermite interpolation with two control points between two vectors.
483
428
  * @param a - The first vector.
@@ -487,18 +432,16 @@ export const zero = (out) => {
487
432
  * @param t - The interpolation amount in the range `[0,1]`.
488
433
  * @param out - The vector to store the result in.
489
434
  * @returns The interpolated vector.
490
- * @see [Hermite interpolation](https://en.wikipedia.org/wiki/Hermite_interpolation)
435
+ * @see {@link https://en.wikipedia.org/wiki/Hermite_interpolation | Hermite interpolation}
436
+ * @public
491
437
  */
492
438
  export const hermite = (a, b, c, d, t, out) => {
493
- const factorTimes2 = t * t;
494
- const factor1 = factorTimes2 * (2 * t - 3) + 1;
495
- const factor2 = factorTimes2 * (t - 2) + t;
496
- const factor3 = factorTimes2 * (t - 1);
497
- const factor4 = factorTimes2 * (3 - 2 * t);
498
- out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
499
- out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
500
- out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
501
- return out;
439
+ const t2 = t * t;
440
+ const f1 = t2 * (2 * t - 3) + 1;
441
+ const f2 = t2 * (t - 2) + t;
442
+ const f3 = t2 * (t - 1);
443
+ const f4 = t2 * (3 - 2 * t);
444
+ return fromValues(a[0] * f1 + b[0] * f2 + c[0] * f3 + d[0] * f4, a[1] * f1 + b[1] * f2 + c[1] * f3 + d[1] * f4, a[2] * f1 + b[2] * f2 + c[2] * f3 + d[2] * f4, out);
502
445
  };
503
446
  /**
504
447
  * Perform a Bézier interpolation with two control points between two vectors.
@@ -509,99 +452,46 @@ export const hermite = (a, b, c, d, t, out) => {
509
452
  * @param t - The interpolation amount in the range `[0,1]`.
510
453
  * @param out - The vector to store the result in.
511
454
  * @returns The interpolated vector.
512
- * @see [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
455
+ * @see {@link https://en.wikipedia.org/wiki/B%C3%A9zier_curve | Bézier curve}
456
+ * @public
513
457
  */
514
458
  export const bezier = (a, b, c, d, t, out) => {
515
- const inverseFactor = 1 - t;
516
- const inverseFactorTimesTwo = inverseFactor * inverseFactor;
517
- const factorSq = t * t;
518
- const factor1 = inverseFactorTimesTwo * inverseFactor;
519
- const factor2 = 3 * t * inverseFactorTimesTwo;
520
- const factor3 = 3 * factorSq * inverseFactor;
521
- const factor4 = factorSq * t;
522
- out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
523
- out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
524
- out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
525
- return out;
459
+ const invf = 1 - t;
460
+ const invf2 = invf * invf;
461
+ const sqf = t * t;
462
+ const f1 = invf2 * invf;
463
+ const f2 = 3 * t * invf2;
464
+ const f3 = 3 * sqf * invf;
465
+ const f4 = sqf * t;
466
+ return fromValues(a[0] * f1 + b[0] * f2 + c[0] * f3 + d[0] * f4, a[1] * f1 + b[1] * f2 + c[1] * f3 + d[1] * f4, a[2] * f1 + b[2] * f2 + c[2] * f3 + d[2] * f4, out);
526
467
  };
527
468
  /**
528
- * Transform a vector by a quaternion.
469
+ * Transform a vector by a unit quaternion.
529
470
  * @param vector - The vector.
530
- * @param quaternion - The quaternion.
471
+ * @param quaternion - The unit quaternion.
531
472
  * @param out - The vector to store the result in.
532
473
  * @returns The transformed vector.
533
- * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
474
+ * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
475
+ * @see {@link https://raw.org/proof/vector-rotation-using-quaternions/ | Fast Vector Rotation using Quaternions}
476
+ * @public
534
477
  */
535
478
  export const transformQuaternion = (vector, quaternion, out) => {
479
+ const x = vector[0];
480
+ const y = vector[1];
481
+ const z = vector[2];
536
482
  const qx = quaternion[0];
537
483
  const qy = quaternion[1];
538
484
  const qz = quaternion[2];
539
485
  const qw = quaternion[3];
540
- const x = vector[0];
541
- const y = vector[1];
542
- const z = vector[2];
543
- let uvx = qy * z - qz * y;
544
- let uvy = qz * x - qx * z;
545
- let uvz = qx * y - qy * x;
546
- let uuvx = qy * uvz - qz * uvy;
547
- let uuvy = qz * uvx - qx * uvz;
548
- let uuvz = qx * uvy - qy * uvx;
549
- const w2 = qw * 2;
550
- uvx *= w2;
551
- uvy *= w2;
552
- uvz *= w2;
553
- uuvx *= 2;
554
- uuvy *= 2;
555
- uuvz *= 2;
556
- out[0] = x + uvx + uuvx;
557
- out[1] = y + uvy + uuvy;
558
- out[2] = z + uvz + uuvz;
559
- return out;
560
- };
561
- // The unit three-dimensional vector that represents the X-axis.
562
- const xAxis = fromValues(1, 0, 0, createVector3Like());
563
- // The unit three-dimensional vector that represents the Y-axis.
564
- const yAxis = fromValues(0, 1, 0, createVector3Like());
565
- // Used to store intermediary values for some functions.
566
- const intermediary = createVector3Like();
567
- /**
568
- * Create a quaternion that represents the shortest rotation from one unit vector to another.
569
- * @param a - The first vector.
570
- * @param b - The second vector.
571
- * @param out - The quaternion to store the result in.
572
- * @returns The quaternion.
573
- */
574
- export const rotationTo = (a, b, out) => {
575
- const dp = dot(a, b);
576
- if (dp < epsilon - 1) {
577
- cross(xAxis, a, intermediary);
578
- if (getMagnitude(intermediary) < epsilon) {
579
- cross(yAxis, a, intermediary);
580
- }
581
- normalize(intermediary, intermediary);
582
- out[0] = intermediary[0];
583
- out[1] = intermediary[1];
584
- out[2] = intermediary[2];
585
- out[3] = 0;
586
- return out;
587
- }
588
- if (dp > 1 - epsilon) {
589
- out[0] = 0;
590
- out[1] = 0;
591
- out[2] = 0;
592
- out[3] = 1;
593
- return out;
594
- }
595
- cross(a, b, intermediary);
596
- out[0] = intermediary[0];
597
- out[1] = intermediary[1];
598
- out[2] = intermediary[2];
599
- out[3] = 1 + dp;
600
- return normalizeVector4(out, out);
486
+ const tx = (qy * z - qz * y) * 2;
487
+ const ty = (qz * x - qx * z) * 2;
488
+ const tz = (qx * y - qy * x) * 2;
489
+ return fromValues(x + qw * tx + qy * tz - qz * ty, y + qw * ty + qz * tx - qx * tz, z + qw * tz + qx * ty - qy * tx, out);
601
490
  };
602
491
  /**
603
492
  * A quantity with magnitude and direction in three dimensions.
604
- * @see [Euclidean vector](https://en.wikipedia.org/wiki/Euclidean_vector)
493
+ * @see {@link https://en.wikipedia.org/wiki/Euclidean_vector | Euclidean vector}
494
+ * @public
605
495
  */
606
496
  export default class Vector3 extends Float32Array {
607
497
  /**
@@ -617,7 +507,7 @@ export default class Vector3 extends Float32Array {
617
507
  }
618
508
  /**
619
509
  * Create a three-dimensional zero vector.
620
- * @see [Euclidean vector](https://en.wikipedia.org/wiki/Euclidean_vector)
510
+ * @see {@link https://en.wikipedia.org/wiki/Euclidean_vector | Euclidean vector}
621
511
  */
622
512
  constructor() {
623
513
  super(3);
@@ -696,6 +586,14 @@ export default class Vector3 extends Float32Array {
696
586
  subtract(vector, out = new Vector3()) {
697
587
  return subtract(this, vector, out);
698
588
  }
589
+ /**
590
+ * Absolutize the components of this vector.
591
+ * @param out - The vector to store the result in.
592
+ * @returns The absolutized vector.
593
+ */
594
+ abs(out = new Vector3()) {
595
+ return abs(this, out);
596
+ }
699
597
  /**
700
598
  * Round up the components of this vector.
701
599
  * @param out - The vector to store the result in.
@@ -761,7 +659,7 @@ export default class Vector3 extends Float32Array {
761
659
  * Calculate the Euclidean distance between this vector and another.
762
660
  * @param vector - The other vector.
763
661
  * @returns The distance.
764
- * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
662
+ * @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
765
663
  */
766
664
  distance(vector) {
767
665
  return distance(this, vector);
@@ -770,7 +668,7 @@ export default class Vector3 extends Float32Array {
770
668
  * Calculate the squared Euclidean distance between this vector and another.
771
669
  * @param vector - The other vector.
772
670
  * @returns The squared distance.
773
- * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
671
+ * @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
774
672
  */
775
673
  squaredDistance(vector) {
776
674
  return squaredDistance(this, vector);
@@ -803,7 +701,7 @@ export default class Vector3 extends Float32Array {
803
701
  * Normalize this vector.
804
702
  * @param out - The vector to store the result in.
805
703
  * @returns The normalized vector.
806
- * @see [Unit vector](https://en.wikipedia.org/wiki/Unit_vector)
704
+ * @see {@link https://en.wikipedia.org/wiki/Unit_vector | Unit vector}
807
705
  */
808
706
  normalize(out = new Vector3()) {
809
707
  return normalize(this, out);
@@ -812,7 +710,7 @@ export default class Vector3 extends Float32Array {
812
710
  * Calculate the dot product of this and another vector.
813
711
  * @param vector - The other vector.
814
712
  * @returns The dot product.
815
- * @see [Dot product](https://en.wikipedia.org/wiki/Dot_product)
713
+ * @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
816
714
  */
817
715
  dot(vector) {
818
716
  return dot(this, vector);
@@ -822,7 +720,7 @@ export default class Vector3 extends Float32Array {
822
720
  * @param vector - The other vector.
823
721
  * @param out - The vector to store the result in.
824
722
  * @returns The cross product.
825
- * @see [Cross product](https://en.wikipedia.org/wiki/Cross_product)
723
+ * @see {@link https://en.wikipedia.org/wiki/Cross_product | Cross product}
826
724
  */
827
725
  cross(vector, out = new Vector3()) {
828
726
  return cross(this, vector, out);
@@ -833,7 +731,7 @@ export default class Vector3 extends Float32Array {
833
731
  * @param t - The interpolation amount (in `[0,1]`).
834
732
  * @param out - The vector to store the result in.
835
733
  * @returns The interpolated vector.
836
- * @see [Linear interpolation](https://en.wikipedia.org/wiki/Linear_interpolation)
734
+ * @see {@link https://en.wikipedia.org/wiki/Linear_interpolation | Linear interpolation}
837
735
  */
838
736
  lerp(vector, t, out = new Vector3()) {
839
737
  return lerp(this, vector, t, out);
@@ -917,7 +815,7 @@ export default class Vector3 extends Float32Array {
917
815
  * @param t - The interpolation amount in the range `[0,1]`.
918
816
  * @param out - The vector to store the result in.
919
817
  * @returns The interpolated vector.
920
- * @see [Hermite interpolation](https://en.wikipedia.org/wiki/Hermite_interpolation)
818
+ * @see {@link https://en.wikipedia.org/wiki/Hermite_interpolation | Hermite interpolation}
921
819
  */
922
820
  hermite(a, b, end, t, out = new Vector3()) {
923
821
  return hermite(this, a, b, end, t, out);
@@ -930,7 +828,7 @@ export default class Vector3 extends Float32Array {
930
828
  * @param t - The interpolation amount in the range `[0,1]`.
931
829
  * @param out - The vector to store the result in.
932
830
  * @returns The interpolated vector.
933
- * @see [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
831
+ * @see {@link https://en.wikipedia.org/wiki/B%C3%A9zier_curve | Bézier curve}
934
832
  */
935
833
  bezier(a, b, end, t, out = new Vector3()) {
936
834
  return bezier(this, a, b, end, t, out);
@@ -940,19 +838,10 @@ export default class Vector3 extends Float32Array {
940
838
  * @param quaternion - The quaternion.
941
839
  * @param out - The vector to store the result in.
942
840
  * @returns The transformed vector.
943
- * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
841
+ * @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
944
842
  */
945
843
  transformQuaternion(quaternion, out = new Vector3()) {
946
844
  return transformQuaternion(this, quaternion, out);
947
845
  }
948
- /**
949
- * Create a quaternion that represents the shortest rotation from this unit vector to another.
950
- * @param vector - The other vector.
951
- * @param out - The quaternion to store the result in.
952
- * @returns The quaternion.
953
- */
954
- rotationTo(vector, out = new Quaternion()) {
955
- return rotationTo(this, vector, out);
956
- }
957
846
  }
958
847
  //# sourceMappingURL=Vector3.js.map