@lakuna/umath 1.3.4 → 1.3.6

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 (162) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +7 -9
  3. package/dist/algorithms/combinations.d.ts +7 -0
  4. package/dist/algorithms/combinations.d.ts.map +1 -1
  5. package/dist/algorithms/combinations.js +8 -1
  6. package/dist/algorithms/combinations.js.map +1 -1
  7. package/dist/algorithms/degreesToRadians.d.ts +7 -0
  8. package/dist/algorithms/degreesToRadians.d.ts.map +1 -1
  9. package/dist/algorithms/degreesToRadians.js +7 -0
  10. package/dist/algorithms/degreesToRadians.js.map +1 -1
  11. package/dist/algorithms/factorial.d.ts +6 -0
  12. package/dist/algorithms/factorial.d.ts.map +1 -1
  13. package/dist/algorithms/factorial.js +15 -5
  14. package/dist/algorithms/factorial.js.map +1 -1
  15. package/dist/algorithms/fibonacci.d.ts +6 -1
  16. package/dist/algorithms/fibonacci.d.ts.map +1 -1
  17. package/dist/algorithms/fibonacci.js +6 -1
  18. package/dist/algorithms/fibonacci.js.map +1 -1
  19. package/dist/algorithms/greatestCommonDivisor.d.ts +14 -0
  20. package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
  21. package/dist/algorithms/greatestCommonDivisor.js +7 -9
  22. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  23. package/dist/algorithms/hypergeometricPmf.d.ts +9 -0
  24. package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
  25. package/dist/algorithms/hypergeometricPmf.js +10 -1
  26. package/dist/algorithms/hypergeometricPmf.js.map +1 -1
  27. package/dist/algorithms/isPrime.d.ts +6 -0
  28. package/dist/algorithms/isPrime.d.ts.map +1 -1
  29. package/dist/algorithms/isPrime.js +8 -1
  30. package/dist/algorithms/isPrime.js.map +1 -1
  31. package/dist/algorithms/permutations.d.ts +7 -0
  32. package/dist/algorithms/permutations.d.ts.map +1 -1
  33. package/dist/algorithms/permutations.js +8 -1
  34. package/dist/algorithms/permutations.js.map +1 -1
  35. package/dist/algorithms/primeFactorization.d.ts +7 -1
  36. package/dist/algorithms/primeFactorization.d.ts.map +1 -1
  37. package/dist/algorithms/primeFactorization.js +10 -3
  38. package/dist/algorithms/primeFactorization.js.map +1 -1
  39. package/dist/algorithms/radiansToDegrees.d.ts +7 -0
  40. package/dist/algorithms/radiansToDegrees.d.ts.map +1 -1
  41. package/dist/algorithms/radiansToDegrees.js +7 -0
  42. package/dist/algorithms/radiansToDegrees.js.map +1 -1
  43. package/dist/algorithms/summation.d.ts +8 -0
  44. package/dist/algorithms/summation.d.ts.map +1 -1
  45. package/dist/algorithms/summation.js +9 -0
  46. package/dist/algorithms/summation.js.map +1 -1
  47. package/dist/index.d.ts +32 -33
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +27 -27
  50. package/dist/index.js.map +1 -1
  51. package/dist/linalg/DualQuaternion.d.ts +460 -83
  52. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  53. package/dist/linalg/DualQuaternion.js +514 -133
  54. package/dist/linalg/DualQuaternion.js.map +1 -1
  55. package/dist/linalg/Matrix.d.ts +80 -12
  56. package/dist/linalg/Matrix.d.ts.map +1 -1
  57. package/dist/linalg/Matrix2.d.ts +337 -52
  58. package/dist/linalg/Matrix2.d.ts.map +1 -1
  59. package/dist/linalg/Matrix2.js +345 -61
  60. package/dist/linalg/Matrix2.js.map +1 -1
  61. package/dist/linalg/Matrix3.d.ts +470 -72
  62. package/dist/linalg/Matrix3.d.ts.map +1 -1
  63. package/dist/linalg/Matrix3.js +488 -94
  64. package/dist/linalg/Matrix3.js.map +1 -1
  65. package/dist/linalg/Matrix4.d.ts +842 -137
  66. package/dist/linalg/Matrix4.d.ts.map +1 -1
  67. package/dist/linalg/Matrix4.js +896 -175
  68. package/dist/linalg/Matrix4.js.map +1 -1
  69. package/dist/linalg/Quaternion.d.ts +395 -70
  70. package/dist/linalg/Quaternion.d.ts.map +1 -1
  71. package/dist/linalg/Quaternion.js +416 -70
  72. package/dist/linalg/Quaternion.js.map +1 -1
  73. package/dist/linalg/SlowMatrix.d.ts +79 -9
  74. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  75. package/dist/linalg/SlowMatrix.js +147 -27
  76. package/dist/linalg/SlowMatrix.js.map +1 -1
  77. package/dist/linalg/SlowSquareMatrix.d.ts +58 -3
  78. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  79. package/dist/linalg/SlowSquareMatrix.js +111 -21
  80. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  81. package/dist/linalg/SquareMatrix.d.ts +26 -3
  82. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  83. package/dist/linalg/Vector.d.ts +148 -24
  84. package/dist/linalg/Vector.d.ts.map +1 -1
  85. package/dist/linalg/Vector2.d.ts +484 -84
  86. package/dist/linalg/Vector2.d.ts.map +1 -1
  87. package/dist/linalg/Vector2.js +487 -71
  88. package/dist/linalg/Vector2.js.map +1 -1
  89. package/dist/linalg/Vector3.d.ts +582 -98
  90. package/dist/linalg/Vector3.d.ts.map +1 -1
  91. package/dist/linalg/Vector3.js +625 -134
  92. package/dist/linalg/Vector3.js.map +1 -1
  93. package/dist/linalg/Vector4.d.ts +450 -75
  94. package/dist/linalg/Vector4.d.ts.map +1 -1
  95. package/dist/linalg/Vector4.js +447 -62
  96. package/dist/linalg/Vector4.js.map +1 -1
  97. package/dist/types/AxisAngle.d.ts +4 -1
  98. package/dist/types/AxisAngle.d.ts.map +1 -1
  99. package/dist/types/FieldOfView.d.ts +5 -0
  100. package/dist/types/FieldOfView.d.ts.map +1 -1
  101. package/dist/utility/BigNumber.d.ts +41 -8
  102. package/dist/utility/BigNumber.d.ts.map +1 -1
  103. package/dist/utility/BigNumber.js +47 -5
  104. package/dist/utility/BigNumber.js.map +1 -1
  105. package/dist/utility/MagnitudeError.d.ts +5 -0
  106. package/dist/utility/MagnitudeError.d.ts.map +1 -1
  107. package/dist/utility/MagnitudeError.js +6 -1
  108. package/dist/utility/MagnitudeError.js.map +1 -1
  109. package/dist/utility/MatrixSizeError.d.ts +5 -0
  110. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  111. package/dist/utility/MatrixSizeError.js +5 -0
  112. package/dist/utility/MatrixSizeError.js.map +1 -1
  113. package/dist/utility/PartialMatrixError.d.ts +5 -0
  114. package/dist/utility/PartialMatrixError.d.ts.map +1 -1
  115. package/dist/utility/PartialMatrixError.js +5 -0
  116. package/dist/utility/PartialMatrixError.js.map +1 -1
  117. package/dist/utility/SingularMatrixError.d.ts +8 -0
  118. package/dist/utility/SingularMatrixError.d.ts.map +1 -1
  119. package/dist/utility/SingularMatrixError.js +8 -0
  120. package/dist/utility/SingularMatrixError.js.map +1 -1
  121. package/dist/utility/epsilon.d.ts +1 -0
  122. package/dist/utility/epsilon.d.ts.map +1 -1
  123. package/dist/utility/epsilon.js +1 -0
  124. package/dist/utility/epsilon.js.map +1 -1
  125. package/package.json +20 -51
  126. package/src/algorithms/combinations.ts +4 -4
  127. package/src/algorithms/degreesToRadians.ts +3 -3
  128. package/src/algorithms/factorial.ts +13 -8
  129. package/src/algorithms/fibonacci.ts +3 -3
  130. package/src/algorithms/greatestCommonDivisor.ts +15 -19
  131. package/src/algorithms/hypergeometricPmf.ts +5 -6
  132. package/src/algorithms/isPrime.ts +4 -4
  133. package/src/algorithms/permutations.ts +4 -4
  134. package/src/algorithms/primeFactorization.ts +9 -9
  135. package/src/algorithms/radiansToDegrees.ts +3 -3
  136. package/src/algorithms/summation.ts +5 -5
  137. package/src/index.ts +35 -33
  138. package/src/linalg/DualQuaternion.ts +558 -804
  139. package/src/linalg/Matrix.ts +35 -36
  140. package/src/linalg/Matrix2.ts +277 -413
  141. package/src/linalg/Matrix3.ts +532 -737
  142. package/src/linalg/Matrix4.ts +1078 -1604
  143. package/src/linalg/Quaternion.ts +415 -690
  144. package/src/linalg/SlowMatrix.ts +118 -69
  145. package/src/linalg/SlowSquareMatrix.ts +85 -56
  146. package/src/linalg/SquareMatrix.ts +7 -7
  147. package/src/linalg/Vector.ts +71 -70
  148. package/src/linalg/Vector2.ts +380 -576
  149. package/src/linalg/Vector3.ts +544 -840
  150. package/src/linalg/Vector4.ts +383 -549
  151. package/src/types/AxisAngle.ts +1 -1
  152. package/src/utility/BigNumber.ts +33 -42
  153. package/src/utility/MagnitudeError.ts +4 -4
  154. package/src/utility/MatrixSizeError.ts +2 -3
  155. package/src/utility/PartialMatrixError.ts +2 -3
  156. package/src/utility/SingularMatrixError.ts +2 -2
  157. package/src/utility/epsilon.ts +1 -4
  158. package/dist/types/IntegerRepresentation.d.ts +0 -2
  159. package/dist/types/IntegerRepresentation.d.ts.map +0 -1
  160. package/dist/types/IntegerRepresentation.js +0 -2
  161. package/dist/types/IntegerRepresentation.js.map +0 -1
  162. package/src/types/IntegerRepresentation.ts +0 -2
@@ -1,16 +1,34 @@
1
- import Quaternion, {} from "#Quaternion";
2
- import { normalize as normalizeVector4 } from "#Vector4";
3
- import epsilon from "#epsilon";
4
- export function createVector3Like() {
1
+ import Quaternion, {} from "./Quaternion.js";
2
+ import epsilon from "../utility/epsilon.js";
3
+ import { normalize as normalizeVector4 } from "./Vector4.js";
4
+ /**
5
+ * Creates a 3x1 vector-like object.
6
+ * @returns A 3x1 vector-like object.
7
+ */
8
+ export const createVector3Like = () => {
5
9
  return new Float32Array(3);
6
- }
7
- export function fromValues(x, y, z, out) {
10
+ };
11
+ /**
12
+ * Create a vector with the given values.
13
+ * @param x - The first component.
14
+ * @param y - The second component.
15
+ * @param z - The third component.
16
+ * @param out - The vector to store the result in.
17
+ * @returns A new vector.
18
+ */
19
+ export const fromValues = (x, y, z, out) => {
8
20
  out[0] = x;
9
21
  out[1] = y;
10
22
  out[2] = z;
11
23
  return out;
12
- }
13
- export function equals(a, b) {
24
+ };
25
+ /**
26
+ * Determine whether or not two vectors are roughly equivalent.
27
+ * @param a - The first vector.
28
+ * @param b - The second vector.
29
+ * @returns Whether or not the vectors are equivalent.
30
+ */
31
+ export const equals = (a, b) => {
14
32
  const a0 = a[0];
15
33
  const a1 = a[1];
16
34
  const a2 = a[2];
@@ -20,119 +38,249 @@ export function equals(a, b) {
20
38
  return (Math.abs(a0 - b0) <= epsilon * Math.max(1, Math.abs(a0), Math.abs(b0)) &&
21
39
  Math.abs(a1 - b1) <= epsilon * Math.max(1, Math.abs(a1), Math.abs(b1)) &&
22
40
  Math.abs(a2 - b2) <= epsilon * Math.max(1, Math.abs(a2), Math.abs(b2)));
23
- }
24
- export function exactEquals(a, b) {
25
- return a[0] == b[0] && a[1] == b[1] && a[2] == b[2];
26
- }
27
- export function add(a, b, out) {
41
+ };
42
+ /**
43
+ * Determine whether two vectors are exactly equivalent.
44
+ * @param a - The first vector.
45
+ * @param b - The second vector.
46
+ * @returns Whether the vectors are equivalent.
47
+ */
48
+ export const exactEquals = (a, b) => {
49
+ return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
50
+ };
51
+ /**
52
+ * Add two vectors.
53
+ * @param a - The augend.
54
+ * @param b - The addend.
55
+ * @param out - The vector to store the result in.
56
+ * @returns The sum.
57
+ */
58
+ export const add = (a, b, out) => {
28
59
  out[0] = a[0] + b[0];
29
60
  out[1] = a[1] + b[1];
30
61
  out[2] = a[2] + b[2];
31
62
  return out;
32
- }
33
- export function copy(vector, out) {
63
+ };
64
+ /**
65
+ * Copy the values from one vector to another.
66
+ * @param vector - The vector to copy.
67
+ * @param out - The vector to store the result in.
68
+ * @returns The copy.
69
+ */
70
+ export const copy = (vector, out) => {
34
71
  out[0] = vector[0];
35
72
  out[1] = vector[1];
36
73
  out[2] = vector[2];
37
74
  return out;
38
- }
39
- export function multiply(a, b, out) {
75
+ };
76
+ /**
77
+ * Multiply two vectors.
78
+ * @param a - The multiplier.
79
+ * @param b - The multiplicand.
80
+ * @param out - The vector to store the result in.
81
+ * @returns The product.
82
+ */
83
+ export const multiply = (a, b, out) => {
40
84
  out[0] = a[0] * b[0];
41
85
  out[1] = a[1] * b[1];
42
86
  out[2] = a[2] * b[2];
43
87
  return out;
44
- }
45
- export function divide(a, b, out) {
88
+ };
89
+ /**
90
+ * Divide two vectors.
91
+ * @param a - The dividend.
92
+ * @param b - The divisor.
93
+ * @param out - The vector to store the result in.
94
+ * @returns The quotient.
95
+ */
96
+ export const divide = (a, b, out) => {
46
97
  out[0] = a[0] / b[0];
47
98
  out[1] = a[1] / b[1];
48
99
  out[2] = a[2] / b[2];
49
100
  return out;
50
- }
51
- export function subtract(a, b, out) {
101
+ };
102
+ /**
103
+ * Subtract two vectors.
104
+ * @param a - The minuend.
105
+ * @param b - The subtrahend.
106
+ * @param out - The vector to store the result in.
107
+ * @returns The difference.
108
+ */
109
+ export const subtract = (a, b, out) => {
52
110
  out[0] = a[0] - b[0];
53
111
  out[1] = a[1] - b[1];
54
112
  out[2] = a[2] - b[2];
55
113
  return out;
56
- }
57
- export function ceil(vector, out) {
114
+ };
115
+ /**
116
+ * Round up the components of a vector.
117
+ * @param vector - The vector.
118
+ * @param out - The vector to store the result in.
119
+ * @returns The rounded vector.
120
+ */
121
+ export const ceil = (vector, out) => {
58
122
  out[0] = Math.ceil(vector[0]);
59
123
  out[1] = Math.ceil(vector[1]);
60
124
  out[2] = Math.ceil(vector[2]);
61
125
  return out;
62
- }
63
- export function floor(vector, out) {
126
+ };
127
+ /**
128
+ * Round down the components of a vector.
129
+ * @param vector - The vector.
130
+ * @param out - The vector to store the result in.
131
+ * @returns The rounded vector.
132
+ */
133
+ export const floor = (vector, out) => {
64
134
  out[0] = Math.floor(vector[0]);
65
135
  out[1] = Math.floor(vector[1]);
66
136
  out[2] = Math.floor(vector[2]);
67
137
  return out;
68
- }
69
- export function round(vector, out) {
138
+ };
139
+ /**
140
+ * Round the components of a vector.
141
+ * @param vector - The vector.
142
+ * @param out - The vector to store the result in.
143
+ * @returns The rounded vector.
144
+ */
145
+ export const round = (vector, out) => {
70
146
  out[0] = Math.round(vector[0]);
71
147
  out[1] = Math.round(vector[1]);
72
148
  out[2] = Math.round(vector[2]);
73
149
  return out;
74
- }
75
- export function min(a, b, out) {
150
+ };
151
+ /**
152
+ * Return the minimum of two vectors.
153
+ * @param a - The first vector.
154
+ * @param b - The second vector.
155
+ * @param out - The vector to store the result in.
156
+ * @returns The minimum.
157
+ */
158
+ export const min = (a, b, out) => {
76
159
  out[0] = Math.min(a[0], b[0]);
77
160
  out[1] = Math.min(a[1], b[1]);
78
161
  out[2] = Math.min(a[2], b[2]);
79
162
  return out;
80
- }
81
- export function max(a, b, out) {
163
+ };
164
+ /**
165
+ * Return the maximum of two vectors.
166
+ * @param a - The first vector.
167
+ * @param b - The second vector.
168
+ * @param out - The vector to store the result in.
169
+ * @returns The maximum.
170
+ */
171
+ export const max = (a, b, out) => {
82
172
  out[0] = Math.max(a[0], b[0]);
83
173
  out[1] = Math.max(a[1], b[1]);
84
174
  out[2] = Math.max(a[2], b[2]);
85
175
  return out;
86
- }
87
- export function scale(vector, scalar, out) {
176
+ };
177
+ /**
178
+ * Scale a vector by a scalar.
179
+ * @param vector - The multiplier.
180
+ * @param scalar - The multiplicand.
181
+ * @param out - The vector to store the result in.
182
+ * @returns The product.
183
+ */
184
+ export const scale = (vector, scalar, out) => {
88
185
  out[0] = vector[0] * scalar;
89
186
  out[1] = vector[1] * scalar;
90
187
  out[2] = vector[2] * scalar;
91
188
  return out;
92
- }
93
- export function scaleAndAdd(a, b, scalar, out) {
189
+ };
190
+ /**
191
+ * Add two vectors after scaling the second by a scalar.
192
+ * @param a - The augend.
193
+ * @param b - The addend.
194
+ * @param scalar - The multiplicand.
195
+ * @param out - The vector to store the result in.
196
+ * @returns The sum.
197
+ */
198
+ export const scaleAndAdd = (a, b, scalar, out) => {
94
199
  out[0] = a[0] + b[0] * scalar;
95
200
  out[1] = a[1] + b[1] * scalar;
96
201
  out[2] = a[2] + b[2] * scalar;
97
202
  return out;
98
- }
99
- export function distance(a, b) {
203
+ };
204
+ /**
205
+ * Calculate the Euclidean distance between two vectors.
206
+ * @param a - The first vector.
207
+ * @param b - The second vector.
208
+ * @returns The distance.
209
+ * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
210
+ */
211
+ export const distance = (a, b) => {
100
212
  const x = b[0] - a[0];
101
213
  const y = b[1] - a[1];
102
214
  const z = b[2] - a[2];
103
215
  return Math.hypot(x, y, z);
104
- }
105
- export function squaredDistance(a, b) {
216
+ };
217
+ /**
218
+ * Calculate the squared Euclidean distance between this vector and another.
219
+ * @param a - The first vector.
220
+ * @param b - The second vector.
221
+ * @returns The squared distance.
222
+ * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
223
+ */
224
+ export const squaredDistance = (a, b) => {
106
225
  const x = b[0] - a[0];
107
226
  const y = b[1] - a[1];
108
227
  const z = b[2] - a[2];
109
228
  return x * x + y * y + z * z;
110
- }
111
- export function getMagnitude(vector) {
229
+ };
230
+ /**
231
+ * Calculate the magnitude (length) of a vector.
232
+ * @param vector - The vector.
233
+ * @returns The magnitude.
234
+ */
235
+ export const getMagnitude = (vector) => {
112
236
  const x = vector[0];
113
237
  const y = vector[1];
114
238
  const z = vector[2];
115
239
  return Math.hypot(x, y, z);
116
- }
117
- export function getSquaredMagnitude(vector) {
240
+ };
241
+ /**
242
+ * Calculate the squared magnitude (length) of a vector.
243
+ * @param vector - The vector.
244
+ * @returns The squared magnitude.
245
+ */
246
+ export const getSquaredMagnitude = (vector) => {
118
247
  const x = vector[0];
119
248
  const y = vector[1];
120
249
  const z = vector[2];
121
250
  return x * x + y * y + z * z;
122
- }
123
- export function negate(vector, out) {
251
+ };
252
+ /**
253
+ * Negate a vector.
254
+ * @param vector - The vector.
255
+ * @param out - The vector to store the result in.
256
+ * @returns The negated vector.
257
+ */
258
+ export const negate = (vector, out) => {
124
259
  out[0] = -vector[0];
125
260
  out[1] = -vector[1];
126
261
  out[2] = -vector[2];
127
262
  return out;
128
- }
129
- export function invert(vector, out) {
263
+ };
264
+ /**
265
+ * Calculate the multiplicative inverse of the components of a vector.
266
+ * @param vector - The vector.
267
+ * @param out - The vector to store the result in.
268
+ * @returns The inverted vector.
269
+ */
270
+ export const invert = (vector, out) => {
130
271
  out[0] = 1 / vector[0];
131
272
  out[1] = 1 / vector[1];
132
273
  out[2] = 1 / vector[2];
133
274
  return out;
134
- }
135
- export function normalize(vector, out) {
275
+ };
276
+ /**
277
+ * Normalize a vector.
278
+ * @param vector - The vector.
279
+ * @param out - The vector to store the result in.
280
+ * @returns The normalized vector.
281
+ * @see [Unit vector](https://en.wikipedia.org/wiki/Unit_vector)
282
+ */
283
+ export const normalize = (vector, out) => {
136
284
  const x = vector[0];
137
285
  const y = vector[1];
138
286
  const z = vector[2];
@@ -144,11 +292,26 @@ export function normalize(vector, out) {
144
292
  out[1] = y * len;
145
293
  out[2] = z * len;
146
294
  return out;
147
- }
148
- export function dot(a, b) {
295
+ };
296
+ /**
297
+ * Calculate the dot product of two vectors.
298
+ * @param a - The multiplier.
299
+ * @param b - The multiplicand.
300
+ * @returns The dot product.
301
+ * @see [Dot product](https://en.wikipedia.org/wiki/Dot_product)
302
+ */
303
+ export const dot = (a, b) => {
149
304
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
150
- }
151
- export function cross(a, b, out) {
305
+ };
306
+ /**
307
+ * Calculate the cross product of two vectors.
308
+ * @param a - The multiplier.
309
+ * @param b - The mutliplicand.
310
+ * @param out - The vector to store the result in.
311
+ * @returns The cross product.
312
+ * @see [Cross product](https://en.wikipedia.org/wiki/Cross_product)
313
+ */
314
+ export const cross = (a, b, out) => {
152
315
  const ax = a[0];
153
316
  const ay = a[1];
154
317
  const az = a[2];
@@ -159,8 +322,17 @@ export function cross(a, b, out) {
159
322
  out[1] = az * bx - ax * bz;
160
323
  out[2] = ax * by - ay * bx;
161
324
  return out;
162
- }
163
- export function lerp(a, b, t, out) {
325
+ };
326
+ /**
327
+ * Perform a linear interpolation between two vectors.
328
+ * @param a - The first vector.
329
+ * @param b - The second vector.
330
+ * @param t - The interpolation amount (in `[0,1]`).
331
+ * @param out - The vector to store the result in.
332
+ * @returns The interpolated vector.
333
+ * @see [Linear interpolation](https://en.wikipedia.org/wiki/Linear_interpolation)
334
+ */
335
+ export const lerp = (a, b, t, out) => {
164
336
  const ax = a[0];
165
337
  const ay = a[1];
166
338
  const az = a[2];
@@ -168,8 +340,14 @@ export function lerp(a, b, t, out) {
168
340
  out[1] = ay + t * (b[1] - ay);
169
341
  out[2] = az + t * (b[2] - az);
170
342
  return out;
171
- }
172
- export function random(magnitude, out) {
343
+ };
344
+ /**
345
+ * Set a vector to a random value with the given magnitude.
346
+ * @param magnitude - The magnitude.
347
+ * @param out - The vector to store the result in.
348
+ * @returns This vector.
349
+ */
350
+ export const random = (magnitude, out) => {
173
351
  const r = Math.random() * 2 * Math.PI;
174
352
  const z = Math.random() * 2 - 1;
175
353
  const zScale = Math.sqrt(1 - z * z) * magnitude;
@@ -177,8 +355,16 @@ export function random(magnitude, out) {
177
355
  out[1] = Math.sin(r) * zScale;
178
356
  out[2] = z * magnitude;
179
357
  return out;
180
- }
181
- export function transformMatrix3(vector, matrix, out) {
358
+ };
359
+ /**
360
+ * Transform a vector by a three-by-three matrix.
361
+ * @param vector - The vector (multiplier).
362
+ * @param matrix - The matrix (multiplicand).
363
+ * @param out - The vector to store the result in.
364
+ * @returns The transformed vector.
365
+ * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
366
+ */
367
+ export const transformMatrix3 = (vector, matrix, out) => {
182
368
  const x = vector[0];
183
369
  const y = vector[1];
184
370
  const z = vector[2];
@@ -186,8 +372,16 @@ export function transformMatrix3(vector, matrix, out) {
186
372
  out[1] = x * matrix[1] + y * matrix[4] + z * matrix[7];
187
373
  out[2] = x * matrix[2] + y * matrix[5] + z * matrix[8];
188
374
  return out;
189
- }
190
- export function transformMatrix4(vector, matrix, out) {
375
+ };
376
+ /**
377
+ * Transform a vector by a four-by-four matrix.
378
+ * @param vector - The vector (multiplier).
379
+ * @param matrix - The matrix (multiplicand).
380
+ * @param out - The vector to store the result in.
381
+ * @returns The transformed vector.
382
+ * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
383
+ */
384
+ export const transformMatrix4 = (vector, matrix, out) => {
191
385
  const x = vector[0];
192
386
  const y = vector[1];
193
387
  const z = vector[2];
@@ -196,56 +390,71 @@ export function transformMatrix4(vector, matrix, out) {
196
390
  out[1] = (matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13]) / w;
197
391
  out[2] = (matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14]) / w;
198
392
  return out;
199
- }
200
- export function rotateX(vector, origin, radians, out) {
201
- const p = [
202
- vector[0] - origin[0],
203
- vector[1] - origin[1],
204
- vector[2] - origin[2]
205
- ];
206
- const r = [
207
- p[0],
208
- p[1] * Math.cos(radians) - p[2] * Math.sin(radians),
209
- p[1] * Math.sin(radians) + p[2] * Math.cos(radians)
210
- ];
211
- out[0] = r[0] + origin[0];
212
- out[1] = r[1] + origin[1];
213
- out[2] = r[2] + origin[2];
393
+ };
394
+ /**
395
+ * Rotate a vector around the X-axis.
396
+ * @param vector - The vector.
397
+ * @param origin - The origin of the rotation.
398
+ * @param r - The angle of rotation in radians.
399
+ * @param out - The vector to store the result in.
400
+ * @returns The rotated vector.
401
+ */
402
+ 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];
214
411
  return out;
215
- }
216
- export function rotateY(vector, origin, radians, out) {
217
- const p = [
218
- vector[0] - origin[0],
219
- vector[1] - origin[1],
220
- vector[2] - origin[2]
221
- ];
222
- const r = [
223
- p[2] * Math.sin(radians) + p[0] * Math.cos(radians),
224
- p[1],
225
- p[2] * Math.cos(radians) - p[0] * Math.sin(radians)
226
- ];
227
- out[0] = r[0] + origin[0];
228
- out[1] = r[1] + origin[1];
229
- out[2] = r[2] + origin[2];
412
+ };
413
+ /**
414
+ * Rotate a vector around the Y-axis.
415
+ * @param vector - The vector.
416
+ * @param origin - The origin of the rotation.
417
+ * @param r - The angle of rotation in radians.
418
+ * @param out - The vector to store the result in.
419
+ * @returns The rotated vector.
420
+ */
421
+ 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];
230
430
  return out;
231
- }
232
- export function rotateZ(vector, origin, radians, out) {
233
- const p = [
234
- vector[0] - origin[0],
235
- vector[1] - origin[1],
236
- vector[2] - origin[2]
237
- ];
238
- const r = [
239
- p[0] * Math.cos(radians) - p[1] * Math.sin(radians),
240
- p[0] * Math.sin(radians) + p[1] * Math.cos(radians),
241
- p[2]
242
- ];
243
- out[0] = r[0] + origin[0];
244
- out[1] = r[1] + origin[1];
245
- out[2] = r[2] + origin[2];
431
+ };
432
+ /**
433
+ * Rotate a vector around the Z-axis.
434
+ * @param vector - The vector.
435
+ * @param origin - The origin of the rotation.
436
+ * @param r - The angle of rotation in radians.
437
+ * @param out - The vector to store the result in.
438
+ * @returns The rotated vector.
439
+ */
440
+ 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];
246
449
  return out;
247
- }
248
- export function angle(a, b) {
450
+ };
451
+ /**
452
+ * Get the angle between two vectors in radians.
453
+ * @param a - The first vector.
454
+ * @param b - The second vector.
455
+ * @returns The angular distance from the first vector to the second.
456
+ */
457
+ export const angle = (a, b) => {
249
458
  const ax = a[0];
250
459
  const ay = a[1];
251
460
  const az = a[2];
@@ -257,14 +466,30 @@ export function angle(a, b) {
257
466
  const mag = mag1 * mag2;
258
467
  const cosine = mag && dot(a, b) / mag;
259
468
  return Math.acos(Math.min(Math.max(cosine, -1), 1));
260
- }
261
- export function zero(out) {
469
+ };
470
+ /**
471
+ * Set a vector to the zero vector.
472
+ * @param out - The vector to store the result in.
473
+ * @returns This vector.
474
+ */
475
+ export const zero = (out) => {
262
476
  out[0] = 0;
263
477
  out[1] = 0;
264
478
  out[2] = 0;
265
479
  return out;
266
- }
267
- export function hermite(a, b, c, d, t, out) {
480
+ };
481
+ /**
482
+ * Perform a Hermite interpolation with two control points between two vectors.
483
+ * @param a - The first vector.
484
+ * @param b - The first control point.
485
+ * @param c - The second control point.
486
+ * @param d - The second vector.
487
+ * @param t - The interpolation amount in the range `[0,1]`.
488
+ * @param out - The vector to store the result in.
489
+ * @returns The interpolated vector.
490
+ * @see [Hermite interpolation](https://en.wikipedia.org/wiki/Hermite_interpolation)
491
+ */
492
+ export const hermite = (a, b, c, d, t, out) => {
268
493
  const factorTimes2 = t * t;
269
494
  const factor1 = factorTimes2 * (2 * t - 3) + 1;
270
495
  const factor2 = factorTimes2 * (t - 2) + t;
@@ -274,21 +499,40 @@ export function hermite(a, b, c, d, t, out) {
274
499
  out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
275
500
  out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
276
501
  return out;
277
- }
278
- export function bezier(a, b, c, d, t, out) {
502
+ };
503
+ /**
504
+ * Perform a Bézier interpolation with two control points between two vectors.
505
+ * @param a - The first vector.
506
+ * @param b - The first control point.
507
+ * @param c - The second control point.
508
+ * @param d - The second vector.
509
+ * @param t - The interpolation amount in the range `[0,1]`.
510
+ * @param out - The vector to store the result in.
511
+ * @returns The interpolated vector.
512
+ * @see [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
513
+ */
514
+ export const bezier = (a, b, c, d, t, out) => {
279
515
  const inverseFactor = 1 - t;
280
516
  const inverseFactorTimesTwo = inverseFactor * inverseFactor;
281
- const factorTimes2 = t * t;
517
+ const factorSq = t * t;
282
518
  const factor1 = inverseFactorTimesTwo * inverseFactor;
283
519
  const factor2 = 3 * t * inverseFactorTimesTwo;
284
- const factor3 = 3 * factorTimes2 * inverseFactor;
285
- const factor4 = factorTimes2 * t;
520
+ const factor3 = 3 * factorSq * inverseFactor;
521
+ const factor4 = factorSq * t;
286
522
  out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
287
523
  out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
288
524
  out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
289
525
  return out;
290
- }
291
- export function transformQuaternion(vector, quaternion, out) {
526
+ };
527
+ /**
528
+ * Transform a vector by a quaternion.
529
+ * @param vector - The vector.
530
+ * @param quaternion - The quaternion.
531
+ * @param out - The vector to store the result in.
532
+ * @returns The transformed vector.
533
+ * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
534
+ */
535
+ export const transformQuaternion = (vector, quaternion, out) => {
292
536
  const qx = quaternion[0];
293
537
  const qy = quaternion[1];
294
538
  const qz = quaternion[2];
@@ -313,11 +557,21 @@ export function transformQuaternion(vector, quaternion, out) {
313
557
  out[1] = y + uvy + uuvy;
314
558
  out[2] = z + uvz + uuvz;
315
559
  return out;
316
- }
317
- const xAxis = new Float32Array([1, 0, 0]);
318
- const yAxis = new Float32Array([0, 1, 0]);
319
- const intermediary = new Float32Array(3);
320
- export function rotationTo(a, b, 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) => {
321
575
  const dp = dot(a, b);
322
576
  if (dp < epsilon - 1) {
323
577
  cross(xAxis, a, intermediary);
@@ -344,122 +598,359 @@ export function rotationTo(a, b, out) {
344
598
  out[2] = intermediary[2];
345
599
  out[3] = 1 + dp;
346
600
  return normalizeVector4(out, out);
347
- }
601
+ };
602
+ /**
603
+ * A quantity with magnitude and direction in three dimensions.
604
+ * @see [Euclidean vector](https://en.wikipedia.org/wiki/Euclidean_vector)
605
+ */
348
606
  export default class Vector3 extends Float32Array {
607
+ /**
608
+ * Create a vector with the given values.
609
+ * @param x - The first component.
610
+ * @param y - The second component.
611
+ * @param z - The third component.
612
+ * @param out - The vector to store the result in.
613
+ * @returns A new vector.
614
+ */
349
615
  static fromValues(x, y, z, out = new Vector3()) {
350
616
  return fromValues(x, y, z, out);
351
617
  }
618
+ /**
619
+ * Create a three-dimensional zero vector.
620
+ * @see [Euclidean vector](https://en.wikipedia.org/wiki/Euclidean_vector)
621
+ */
352
622
  constructor() {
353
623
  super(3);
354
624
  }
625
+ /** The first component of this vector. */
626
+ 0;
627
+ /** The second component of this vector. */
628
+ 1;
629
+ /** The third component of this vector. */
630
+ 2;
631
+ /**
632
+ * Determine whether or not this vector is roughly equivalent to another.
633
+ * @param vector - The other vector.
634
+ * @returns Whether or not the vectors are equivalent.
635
+ */
355
636
  equals(vector) {
356
637
  return equals(this, vector);
357
638
  }
639
+ /**
640
+ * Determine whether or not this vector is exactly equivalent to another.
641
+ * @param vector - The other vector.
642
+ * @returns Whether or not the vectors are equivalent.
643
+ */
358
644
  exactEquals(vector) {
359
645
  return exactEquals(this, vector);
360
646
  }
647
+ /**
648
+ * Add two vectors of the same size.
649
+ * @param vector - The other vector.
650
+ * @param out - The vector to store the result in.
651
+ * @returns The sum of the vectors.
652
+ */
361
653
  add(vector, out = new Vector3()) {
362
654
  return add(this, vector, out);
363
655
  }
656
+ /**
657
+ * Copy the values from this vector to another one.
658
+ * @param out - The vector to store the result in.
659
+ * @returns The copy.
660
+ */
364
661
  clone(out = new Vector3()) {
365
662
  return copy(this, out);
366
663
  }
664
+ /**
665
+ * Copy the values of another vector into this one.
666
+ * @param vector - The vector to copy.
667
+ * @returns This vector.
668
+ */
367
669
  copy(vector) {
368
670
  return copy(vector, this);
369
671
  }
672
+ /**
673
+ * Multiply this vector by another.
674
+ * @param vector - The other vector.
675
+ * @param out - The vector to store the result in.
676
+ * @returns The product of the vectors.
677
+ */
370
678
  multiply(vector, out = new Vector3()) {
371
679
  return multiply(this, vector, out);
372
680
  }
681
+ /**
682
+ * Divide this vector by another.
683
+ * @param vector - The other vector.
684
+ * @param out - The vector to store the result in.
685
+ * @returns The quotient of the vectors.
686
+ */
373
687
  divide(vector, out = new Vector3()) {
374
688
  return divide(this, vector, out);
375
689
  }
690
+ /**
691
+ * Subtract another vector from this one.
692
+ * @param vector - The other vector.
693
+ * @param out - The vector to store the result in.
694
+ * @returns The difference between the vectors.
695
+ */
376
696
  subtract(vector, out = new Vector3()) {
377
697
  return subtract(this, vector, out);
378
698
  }
699
+ /**
700
+ * Round up the components of this vector.
701
+ * @param out - The vector to store the result in.
702
+ * @returns The rounded vector.
703
+ */
379
704
  ceil(out = new Vector3()) {
380
705
  return ceil(this, out);
381
706
  }
707
+ /**
708
+ * Round down the components of this vector.
709
+ * @param out - The vector to store the result in.
710
+ * @returns The rounded vector.
711
+ */
382
712
  floor(out = new Vector3()) {
383
713
  return floor(this, out);
384
714
  }
715
+ /**
716
+ * Round the components of this vector.
717
+ * @param out - The vector to store the result in.
718
+ * @returns The rounded vector.
719
+ */
385
720
  round(out = new Vector3()) {
386
721
  return round(this, out);
387
722
  }
723
+ /**
724
+ * Return the minimum of this and another vector.
725
+ * @param vector - The other vector.
726
+ * @param out - The vector to store the result in.
727
+ * @returns The minimum.
728
+ */
388
729
  min(vector, out = new Vector3()) {
389
730
  return min(this, vector, out);
390
731
  }
732
+ /**
733
+ * Return the maximum of this and another vector.
734
+ * @param vector - The other vector.
735
+ * @param out - The vector to store the result in.
736
+ * @returns The maximum.
737
+ */
391
738
  max(vector, out = new Vector3()) {
392
739
  return max(this, vector, out);
393
740
  }
741
+ /**
742
+ * Scale this vector by a scalar.
743
+ * @param scalar - The scalar.
744
+ * @param out - The vector to store the result in.
745
+ * @returns The scaled vector.
746
+ */
394
747
  scale(scalar, out = new Vector3()) {
395
748
  return scale(this, scalar, out);
396
749
  }
750
+ /**
751
+ * Add another vector to this one after scaling the other by a scalar.
752
+ * @param vector - The other vector.
753
+ * @param scalar - The scalar.
754
+ * @param out - The vector to store the result in.
755
+ * @returns The sum.
756
+ */
397
757
  scaleAndAdd(vector, scalar, out = new Vector3()) {
398
758
  return scaleAndAdd(this, vector, scalar, out);
399
759
  }
760
+ /**
761
+ * Calculate the Euclidean distance between this vector and another.
762
+ * @param vector - The other vector.
763
+ * @returns The distance.
764
+ * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
765
+ */
400
766
  distance(vector) {
401
767
  return distance(this, vector);
402
768
  }
769
+ /**
770
+ * Calculate the squared Euclidean distance between this vector and another.
771
+ * @param vector - The other vector.
772
+ * @returns The squared distance.
773
+ * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
774
+ */
403
775
  squaredDistance(vector) {
404
776
  return squaredDistance(this, vector);
405
777
  }
778
+ /** Get the magnitude (length) of this vector. */
406
779
  get magnitude() {
407
780
  return getMagnitude(this);
408
781
  }
782
+ /** Get the squared magnitude (length) of this vector. */
409
783
  get squaredMagnitude() {
410
784
  return getSquaredMagnitude(this);
411
785
  }
786
+ /**
787
+ * Negate this vector.
788
+ * @param out - The vector to store the result in.
789
+ * @returns The negated vector.
790
+ */
412
791
  negate(out = new Vector3()) {
413
792
  return negate(this, out);
414
793
  }
794
+ /**
795
+ * Calculate the multiplicative inverse of the components of this vector.
796
+ * @param out - The vector to store the result in.
797
+ * @returns The inverted vector.
798
+ */
415
799
  invert(out = new Vector3()) {
416
800
  return invert(this, out);
417
801
  }
802
+ /**
803
+ * Normalize this vector.
804
+ * @param out - The vector to store the result in.
805
+ * @returns The normalized vector.
806
+ * @see [Unit vector](https://en.wikipedia.org/wiki/Unit_vector)
807
+ */
418
808
  normalize(out = new Vector3()) {
419
809
  return normalize(this, out);
420
810
  }
811
+ /**
812
+ * Calculate the dot product of this and another vector.
813
+ * @param vector - The other vector.
814
+ * @returns The dot product.
815
+ * @see [Dot product](https://en.wikipedia.org/wiki/Dot_product)
816
+ */
421
817
  dot(vector) {
422
818
  return dot(this, vector);
423
819
  }
820
+ /**
821
+ * Calculate the cross product of this and another vector.
822
+ * @param vector - The other vector.
823
+ * @param out - The vector to store the result in.
824
+ * @returns The cross product.
825
+ * @see [Cross product](https://en.wikipedia.org/wiki/Cross_product)
826
+ */
424
827
  cross(vector, out = new Vector3()) {
425
828
  return cross(this, vector, out);
426
829
  }
830
+ /**
831
+ * Perform a linear interpolation between this and another vector.
832
+ * @param vector - The other vector.
833
+ * @param t - The interpolation amount (in `[0,1]`).
834
+ * @param out - The vector to store the result in.
835
+ * @returns The interpolated vector.
836
+ * @see [Linear interpolation](https://en.wikipedia.org/wiki/Linear_interpolation)
837
+ */
427
838
  lerp(vector, t, out = new Vector3()) {
428
839
  return lerp(this, vector, t, out);
429
840
  }
841
+ /**
842
+ * Set this vector to a random value with the given magnitude.
843
+ * @param magnitude - The magnitude.
844
+ * @returns This vector.
845
+ */
430
846
  random(magnitude = 1) {
431
847
  return random(magnitude, this);
432
848
  }
849
+ /**
850
+ * Transform this vector by a three-by-three matrix.
851
+ * @param matrix - The matrix.
852
+ * @param out - The vector to store the result in.
853
+ * @returns The transformed vector.
854
+ */
433
855
  transformMatrix3(matrix, out = new Vector3()) {
434
856
  return transformMatrix3(this, matrix, out);
435
857
  }
858
+ /**
859
+ * Transform this vector by a four-by-four matrix.
860
+ * @param matrix - The matrix.
861
+ * @param out - The vector to store the result in.
862
+ * @returns The transformed vector.
863
+ */
436
864
  transformMatrix4(matrix, out = new Vector3()) {
437
865
  return transformMatrix4(this, matrix, out);
438
866
  }
439
- rotateX(origin, radians, out = new Vector3()) {
440
- return rotateX(this, origin, radians, out);
441
- }
442
- rotateY(origin, radians, out = new Vector3()) {
443
- return rotateY(this, origin, radians, out);
444
- }
445
- rotateZ(origin, radians, out = new Vector3()) {
446
- return rotateZ(this, origin, radians, out);
447
- }
867
+ /**
868
+ * Rotate this vector around the X-axis.
869
+ * @param origin - The origin of the rotation.
870
+ * @param r - The angle of rotation in radians.
871
+ * @param out - The vector to store the result in.
872
+ * @returns The rotated vector.
873
+ */
874
+ rotateX(origin, r, out = new Vector3()) {
875
+ return rotateX(this, origin, r, out);
876
+ }
877
+ /**
878
+ * Rotate this vector around the Y-axis.
879
+ * @param origin - The origin of the rotation.
880
+ * @param r - The angle of rotation in radians.
881
+ * @param out - The vector to store the result in.
882
+ * @returns The rotated vector.
883
+ */
884
+ rotateY(origin, r, out = new Vector3()) {
885
+ return rotateY(this, origin, r, out);
886
+ }
887
+ /**
888
+ * Rotate this vector around the Z-axis.
889
+ * @param origin - The origin of the rotation.
890
+ * @param r - The angle of rotation in radians.
891
+ * @param out - The vector to store the result in.
892
+ * @returns The rotated vector.
893
+ */
894
+ rotateZ(origin, r, out = new Vector3()) {
895
+ return rotateZ(this, origin, r, out);
896
+ }
897
+ /**
898
+ * Get the angle from this vector to another in radians.
899
+ * @param vector - The other vector.
900
+ * @returns The angular distance from this vector to the other.
901
+ */
448
902
  angle(vector) {
449
903
  return angle(this, vector);
450
904
  }
905
+ /**
906
+ * Set this to the zero vector.
907
+ * @returns This vector.
908
+ */
451
909
  zero() {
452
910
  return zero(this);
453
911
  }
912
+ /**
913
+ * Perform a Hermite interpolation with two control points between this vector and another.
914
+ * @param a - The first control point.
915
+ * @param b - The second control point.
916
+ * @param end - The other vector.
917
+ * @param t - The interpolation amount in the range `[0,1]`.
918
+ * @param out - The vector to store the result in.
919
+ * @returns The interpolated vector.
920
+ * @see [Hermite interpolation](https://en.wikipedia.org/wiki/Hermite_interpolation)
921
+ */
454
922
  hermite(a, b, end, t, out = new Vector3()) {
455
923
  return hermite(this, a, b, end, t, out);
456
924
  }
925
+ /**
926
+ * Perform a Bézier interpolation with two control points between this vector and another.
927
+ * @param a - The first control point.
928
+ * @param b - The second control point.
929
+ * @param end - The other vector.
930
+ * @param t - The interpolation amount in the range `[0,1]`.
931
+ * @param out - The vector to store the result in.
932
+ * @returns The interpolated vector.
933
+ * @see [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
934
+ */
457
935
  bezier(a, b, end, t, out = new Vector3()) {
458
936
  return bezier(this, a, b, end, t, out);
459
937
  }
938
+ /**
939
+ * Transform this vector by a quaternion.
940
+ * @param quaternion - The quaternion.
941
+ * @param out - The vector to store the result in.
942
+ * @returns The transformed vector.
943
+ * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
944
+ */
460
945
  transformQuaternion(quaternion, out = new Vector3()) {
461
946
  return transformQuaternion(this, quaternion, out);
462
947
  }
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
+ */
463
954
  rotationTo(vector, out = new Quaternion()) {
464
955
  return rotationTo(this, vector, out);
465
956
  }