@lakuna/umath 1.3.4 → 1.3.5

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 (133) hide show
  1. package/README.md +7 -9
  2. package/dist/algorithms/combinations.d.ts.map +1 -1
  3. package/dist/algorithms/combinations.js +1 -1
  4. package/dist/algorithms/combinations.js.map +1 -1
  5. package/dist/algorithms/degreesToRadians.d.ts.map +1 -1
  6. package/dist/algorithms/factorial.d.ts.map +1 -1
  7. package/dist/algorithms/factorial.js +8 -5
  8. package/dist/algorithms/factorial.js.map +1 -1
  9. package/dist/algorithms/fibonacci.d.ts +1 -1
  10. package/dist/algorithms/fibonacci.d.ts.map +1 -1
  11. package/dist/algorithms/fibonacci.js +1 -1
  12. package/dist/algorithms/fibonacci.js.map +1 -1
  13. package/dist/algorithms/greatestCommonDivisor.js +5 -9
  14. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  15. package/dist/algorithms/hypergeometricPmf.d.ts.map +1 -1
  16. package/dist/algorithms/hypergeometricPmf.js +1 -1
  17. package/dist/algorithms/hypergeometricPmf.js.map +1 -1
  18. package/dist/algorithms/isPrime.d.ts.map +1 -1
  19. package/dist/algorithms/isPrime.js +1 -1
  20. package/dist/algorithms/isPrime.js.map +1 -1
  21. package/dist/algorithms/permutations.d.ts.map +1 -1
  22. package/dist/algorithms/permutations.js +1 -1
  23. package/dist/algorithms/permutations.js.map +1 -1
  24. package/dist/algorithms/primeFactorization.d.ts +1 -1
  25. package/dist/algorithms/primeFactorization.d.ts.map +1 -1
  26. package/dist/algorithms/primeFactorization.js +4 -3
  27. package/dist/algorithms/primeFactorization.js.map +1 -1
  28. package/dist/algorithms/radiansToDegrees.d.ts.map +1 -1
  29. package/dist/algorithms/summation.d.ts.map +1 -1
  30. package/dist/algorithms/summation.js.map +1 -1
  31. package/dist/index.d.ts +32 -33
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +27 -27
  34. package/dist/index.js.map +1 -1
  35. package/dist/linalg/DualQuaternion.d.ts +50 -56
  36. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  37. package/dist/linalg/DualQuaternion.js +67 -61
  38. package/dist/linalg/DualQuaternion.js.map +1 -1
  39. package/dist/linalg/Matrix.d.ts +13 -12
  40. package/dist/linalg/Matrix.d.ts.map +1 -1
  41. package/dist/linalg/Matrix2.d.ts +30 -34
  42. package/dist/linalg/Matrix2.d.ts.map +1 -1
  43. package/dist/linalg/Matrix2.js +26 -23
  44. package/dist/linalg/Matrix2.js.map +1 -1
  45. package/dist/linalg/Matrix3.d.ts +47 -47
  46. package/dist/linalg/Matrix3.d.ts.map +1 -1
  47. package/dist/linalg/Matrix3.js +52 -43
  48. package/dist/linalg/Matrix3.js.map +1 -1
  49. package/dist/linalg/Matrix4.d.ts +83 -102
  50. package/dist/linalg/Matrix4.d.ts.map +1 -1
  51. package/dist/linalg/Matrix4.js +105 -89
  52. package/dist/linalg/Matrix4.js.map +1 -1
  53. package/dist/linalg/Quaternion.d.ts +36 -49
  54. package/dist/linalg/Quaternion.d.ts.map +1 -1
  55. package/dist/linalg/Quaternion.js +33 -25
  56. package/dist/linalg/Quaternion.js.map +1 -1
  57. package/dist/linalg/SlowMatrix.d.ts +9 -9
  58. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  59. package/dist/linalg/SlowMatrix.js +76 -27
  60. package/dist/linalg/SlowMatrix.js.map +1 -1
  61. package/dist/linalg/SlowSquareMatrix.d.ts +3 -3
  62. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  63. package/dist/linalg/SlowSquareMatrix.js +53 -21
  64. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  65. package/dist/linalg/SquareMatrix.d.ts +3 -3
  66. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  67. package/dist/linalg/Vector.d.ts +25 -24
  68. package/dist/linalg/Vector.d.ts.map +1 -1
  69. package/dist/linalg/Vector2.d.ts +35 -52
  70. package/dist/linalg/Vector2.d.ts.map +1 -1
  71. package/dist/linalg/Vector2.js +8 -6
  72. package/dist/linalg/Vector2.js.map +1 -1
  73. package/dist/linalg/Vector3.d.ts +43 -63
  74. package/dist/linalg/Vector3.d.ts.map +1 -1
  75. package/dist/linalg/Vector3.js +46 -58
  76. package/dist/linalg/Vector3.js.map +1 -1
  77. package/dist/linalg/Vector4.d.ts +34 -45
  78. package/dist/linalg/Vector4.d.ts.map +1 -1
  79. package/dist/linalg/Vector4.js +6 -2
  80. package/dist/linalg/Vector4.js.map +1 -1
  81. package/dist/types/AxisAngle.d.ts +1 -1
  82. package/dist/types/AxisAngle.d.ts.map +1 -1
  83. package/dist/utility/BigNumber.d.ts +5 -8
  84. package/dist/utility/BigNumber.d.ts.map +1 -1
  85. package/dist/utility/BigNumber.js +5 -5
  86. package/dist/utility/BigNumber.js.map +1 -1
  87. package/dist/utility/MagnitudeError.d.ts.map +1 -1
  88. package/dist/utility/MagnitudeError.js +1 -1
  89. package/dist/utility/MagnitudeError.js.map +1 -1
  90. package/dist/utility/MatrixSizeError.d.ts.map +1 -1
  91. package/dist/utility/MatrixSizeError.js.map +1 -1
  92. package/dist/utility/PartialMatrixError.d.ts.map +1 -1
  93. package/dist/utility/PartialMatrixError.js.map +1 -1
  94. package/dist/utility/epsilon.d.ts.map +1 -1
  95. package/dist/utility/epsilon.js.map +1 -1
  96. package/package.json +20 -51
  97. package/src/algorithms/combinations.ts +5 -5
  98. package/src/algorithms/degreesToRadians.ts +4 -4
  99. package/src/algorithms/factorial.ts +14 -9
  100. package/src/algorithms/fibonacci.ts +3 -3
  101. package/src/algorithms/greatestCommonDivisor.ts +15 -19
  102. package/src/algorithms/hypergeometricPmf.ts +6 -7
  103. package/src/algorithms/isPrime.ts +5 -5
  104. package/src/algorithms/permutations.ts +5 -5
  105. package/src/algorithms/primeFactorization.ts +9 -9
  106. package/src/algorithms/radiansToDegrees.ts +4 -4
  107. package/src/algorithms/summation.ts +6 -6
  108. package/src/index.ts +35 -33
  109. package/src/linalg/DualQuaternion.ts +528 -780
  110. package/src/linalg/Matrix.ts +35 -36
  111. package/src/linalg/Matrix2.ts +253 -402
  112. package/src/linalg/Matrix3.ts +502 -720
  113. package/src/linalg/Matrix4.ts +1032 -1574
  114. package/src/linalg/Quaternion.ts +400 -679
  115. package/src/linalg/SlowMatrix.ts +124 -75
  116. package/src/linalg/SlowSquareMatrix.ts +92 -63
  117. package/src/linalg/SquareMatrix.ts +7 -7
  118. package/src/linalg/Vector.ts +71 -70
  119. package/src/linalg/Vector2.ts +342 -552
  120. package/src/linalg/Vector3.ts +502 -815
  121. package/src/linalg/Vector4.ts +347 -530
  122. package/src/types/AxisAngle.ts +1 -1
  123. package/src/utility/BigNumber.ts +36 -45
  124. package/src/utility/MagnitudeError.ts +4 -4
  125. package/src/utility/MatrixSizeError.ts +2 -3
  126. package/src/utility/PartialMatrixError.ts +2 -3
  127. package/src/utility/SingularMatrixError.ts +2 -2
  128. package/src/utility/epsilon.ts +1 -4
  129. package/dist/types/IntegerRepresentation.d.ts +0 -2
  130. package/dist/types/IntegerRepresentation.d.ts.map +0 -1
  131. package/dist/types/IntegerRepresentation.js +0 -2
  132. package/dist/types/IntegerRepresentation.js.map +0 -1
  133. package/src/types/IntegerRepresentation.ts +0 -2
@@ -1,27 +1,36 @@
1
- import type { Matrix3Like } from "#Matrix3";
2
- import type { Matrix4Like } from "#Matrix4";
3
- import Quaternion, { type QuaternionLike } from "#Quaternion";
4
- import type Vector from "#Vector";
5
- import { normalize as normalizeVector4, type Vector4Like } from "#Vector4";
6
- import epsilon from "#epsilon";
1
+ import Quaternion, { type QuaternionLike } from "./Quaternion.js";
2
+ import type { default as Vector, VectorLike } from "./Vector.js";
3
+ import type { Matrix3Like } from "./Matrix3.js";
4
+ import type { Matrix4Like } from "./Matrix4.js";
5
+ import epsilon from "../utility/epsilon.js";
6
+ import { normalize as normalizeVector4 } from "./Vector4.js";
7
7
 
8
8
  /** A quantity with magnitude and direction in three dimensions. */
9
- export type Vector3Like = Vector3 | [number, number, number];
9
+ export interface Vector3Like extends VectorLike {
10
+ /** The first component of this vector. */
11
+ 0: number;
12
+
13
+ /** The second component of this vector. */
14
+ 1: number;
15
+
16
+ /** The third component of this vector. */
17
+ 2: number;
18
+ }
10
19
 
11
20
  /**
12
21
  * Creates a 3x1 vector-like object.
13
22
  * @returns A 3x1 vector-like object.
14
23
  */
15
- export function createVector3Like(): Vector3Like {
16
- return new Float32Array(3) as Vector3Like;
24
+ export function createVector3Like() {
25
+ return new Float32Array(3) as unknown as Vector3Like;
17
26
  }
18
27
 
19
28
  /**
20
- * Creates a vector with the given values.
21
- * @param x The first component.
22
- * @param y The second component.
23
- * @param z The third component.
24
- * @param out The vector to store the result in.
29
+ * Create a vector with the given values.
30
+ * @param x - The first component.
31
+ * @param y - The second component.
32
+ * @param z - The third component.
33
+ * @param out - The vector to store the result in.
25
34
  * @returns A new vector.
26
35
  */
27
36
  export function fromValues<T extends Vector3Like>(
@@ -29,7 +38,7 @@ export function fromValues<T extends Vector3Like>(
29
38
  y: number,
30
39
  z: number,
31
40
  out: T
32
- ): T {
41
+ ) {
33
42
  out[0] = x;
34
43
  out[1] = y;
35
44
  out[2] = z;
@@ -37,19 +46,19 @@ export function fromValues<T extends Vector3Like>(
37
46
  }
38
47
 
39
48
  /**
40
- * Determines whether two vectors are roughly equivalent.
41
- * @param a The first vector.
42
- * @param b The second vector.
43
- * @returns Whether the vectors are equivalent.
49
+ * Determine whether or not two vectors are roughly equivalent.
50
+ * @param a - The first vector.
51
+ * @param b - The second vector.
52
+ * @returns Whether or not the vectors are equivalent.
44
53
  */
45
- export function equals(a: Vector3Like, b: Vector3Like): boolean {
46
- const a0: number = a[0];
47
- const a1: number = a[1];
48
- const a2: number = a[2];
54
+ export function equals(a: Vector3Like, b: Vector3Like) {
55
+ const a0 = a[0];
56
+ const a1 = a[1];
57
+ const a2 = a[2];
49
58
 
50
- const b0: number = b[0];
51
- const b1: number = b[1];
52
- const b2: number = b[2];
59
+ const b0 = b[0];
60
+ const b1 = b[1];
61
+ const b2 = b[2];
53
62
 
54
63
  return (
55
64
  Math.abs(a0 - b0) <= epsilon * Math.max(1, Math.abs(a0), Math.abs(b0)) &&
@@ -59,27 +68,27 @@ export function equals(a: Vector3Like, b: Vector3Like): boolean {
59
68
  }
60
69
 
61
70
  /**
62
- * Determines whether two vectors are exactly equivalent.
63
- * @param a The first vector.
64
- * @param b The second vector.
71
+ * Determine whether two vectors are exactly equivalent.
72
+ * @param a - The first vector.
73
+ * @param b - The second vector.
65
74
  * @returns Whether the vectors are equivalent.
66
75
  */
67
- export function exactEquals(a: Vector3Like, b: Vector3Like): boolean {
68
- return a[0] == b[0] && a[1] == b[1] && a[2] == b[2];
76
+ export function exactEquals(a: Vector3Like, b: Vector3Like) {
77
+ return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
69
78
  }
70
79
 
71
80
  /**
72
- * Adds two vectors.
73
- * @param a The augend.
74
- * @param b The addend.
75
- * @param out The vector to store the result in.
81
+ * Add two vectors.
82
+ * @param a - The augend.
83
+ * @param b - The addend.
84
+ * @param out - The vector to store the result in.
76
85
  * @returns The sum.
77
86
  */
78
87
  export function add<T extends Vector3Like>(
79
88
  a: Vector3Like,
80
89
  b: Vector3Like,
81
90
  out: T
82
- ): T {
91
+ ) {
83
92
  out[0] = a[0] + b[0];
84
93
  out[1] = a[1] + b[1];
85
94
  out[2] = a[2] + b[2];
@@ -87,12 +96,12 @@ export function add<T extends Vector3Like>(
87
96
  }
88
97
 
89
98
  /**
90
- * Copies the values from one vector to another.
91
- * @param vector The vector to copy.
92
- * @param out The vector to store the result in.
99
+ * Copy the values from one vector to another.
100
+ * @param vector - The vector to copy.
101
+ * @param out - The vector to store the result in.
93
102
  * @returns The copy.
94
103
  */
95
- export function copy<T extends Vector3Like>(vector: Vector3Like, out: T): T {
104
+ export function copy<T extends Vector3Like>(vector: Vector3Like, out: T) {
96
105
  out[0] = vector[0];
97
106
  out[1] = vector[1];
98
107
  out[2] = vector[2];
@@ -100,17 +109,17 @@ export function copy<T extends Vector3Like>(vector: Vector3Like, out: T): T {
100
109
  }
101
110
 
102
111
  /**
103
- * Multiplies two vectors.
104
- * @param a The multiplier.
105
- * @param b The multiplicand.
106
- * @param out The vector to store the result in.
112
+ * Multiply two vectors.
113
+ * @param a - The multiplier.
114
+ * @param b - The multiplicand.
115
+ * @param out - The vector to store the result in.
107
116
  * @returns The product.
108
117
  */
109
118
  export function multiply<T extends Vector3Like>(
110
119
  a: Vector3Like,
111
120
  b: Vector3Like,
112
121
  out: T
113
- ): T {
122
+ ) {
114
123
  out[0] = a[0] * b[0];
115
124
  out[1] = a[1] * b[1];
116
125
  out[2] = a[2] * b[2];
@@ -118,17 +127,17 @@ export function multiply<T extends Vector3Like>(
118
127
  }
119
128
 
120
129
  /**
121
- * Divides two vectors.
122
- * @param a The dividend.
123
- * @param b The divisor.
124
- * @param out The vector to store the result in.
130
+ * Divide two vectors.
131
+ * @param a - The dividend.
132
+ * @param b - The divisor.
133
+ * @param out - The vector to store the result in.
125
134
  * @returns The quotient.
126
135
  */
127
136
  export function divide<T extends Vector3Like>(
128
137
  a: Vector3Like,
129
138
  b: Vector3Like,
130
139
  out: T
131
- ): T {
140
+ ) {
132
141
  out[0] = a[0] / b[0];
133
142
  out[1] = a[1] / b[1];
134
143
  out[2] = a[2] / b[2];
@@ -136,17 +145,17 @@ export function divide<T extends Vector3Like>(
136
145
  }
137
146
 
138
147
  /**
139
- * Subtracts two vectors.
140
- * @param a The minuend.
141
- * @param b The subtrahend.
142
- * @param out The vector to store the result in.
148
+ * Subtract two vectors.
149
+ * @param a - The minuend.
150
+ * @param b - The subtrahend.
151
+ * @param out - The vector to store the result in.
143
152
  * @returns The difference.
144
153
  */
145
154
  export function subtract<T extends Vector3Like>(
146
155
  a: Vector3Like,
147
156
  b: Vector3Like,
148
157
  out: T
149
- ): T {
158
+ ) {
150
159
  out[0] = a[0] - b[0];
151
160
  out[1] = a[1] - b[1];
152
161
  out[2] = a[2] - b[2];
@@ -154,12 +163,12 @@ export function subtract<T extends Vector3Like>(
154
163
  }
155
164
 
156
165
  /**
157
- * Rounds up the components of a vector.
158
- * @param vector The vector.
159
- * @param out The vector to store the result in.
166
+ * Round up the components of a vector.
167
+ * @param vector - The vector.
168
+ * @param out - The vector to store the result in.
160
169
  * @returns The rounded vector.
161
170
  */
162
- export function ceil<T extends Vector3Like>(vector: Vector3Like, out: T): T {
171
+ export function ceil<T extends Vector3Like>(vector: Vector3Like, out: T) {
163
172
  out[0] = Math.ceil(vector[0]);
164
173
  out[1] = Math.ceil(vector[1]);
165
174
  out[2] = Math.ceil(vector[2]);
@@ -167,12 +176,12 @@ export function ceil<T extends Vector3Like>(vector: Vector3Like, out: T): T {
167
176
  }
168
177
 
169
178
  /**
170
- * Rounds down the components of a vector.
171
- * @param vector The vector.
172
- * @param out The vector to store the result in.
179
+ * Round down the components of a vector.
180
+ * @param vector - The vector.
181
+ * @param out - The vector to store the result in.
173
182
  * @returns The rounded vector.
174
183
  */
175
- export function floor<T extends Vector3Like>(vector: Vector3Like, out: T): T {
184
+ export function floor<T extends Vector3Like>(vector: Vector3Like, out: T) {
176
185
  out[0] = Math.floor(vector[0]);
177
186
  out[1] = Math.floor(vector[1]);
178
187
  out[2] = Math.floor(vector[2]);
@@ -180,12 +189,12 @@ export function floor<T extends Vector3Like>(vector: Vector3Like, out: T): T {
180
189
  }
181
190
 
182
191
  /**
183
- * Rounds the components of a vector.
184
- * @param vector The vector.
185
- * @param out The vector to store the result in.
192
+ * Round the components of a vector.
193
+ * @param vector - The vector.
194
+ * @param out - The vector to store the result in.
186
195
  * @returns The rounded vector.
187
196
  */
188
- export function round<T extends Vector3Like>(vector: Vector3Like, out: T): T {
197
+ export function round<T extends Vector3Like>(vector: Vector3Like, out: T) {
189
198
  out[0] = Math.round(vector[0]);
190
199
  out[1] = Math.round(vector[1]);
191
200
  out[2] = Math.round(vector[2]);
@@ -193,17 +202,17 @@ export function round<T extends Vector3Like>(vector: Vector3Like, out: T): T {
193
202
  }
194
203
 
195
204
  /**
196
- * Returns the minimum of two vectors.
197
- * @param a The first vector.
198
- * @param b The second vector.
199
- * @param out The vector to store the result in.
205
+ * Return the minimum of two vectors.
206
+ * @param a - The first vector.
207
+ * @param b - The second vector.
208
+ * @param out - The vector to store the result in.
200
209
  * @returns The minimum.
201
210
  */
202
211
  export function min<T extends Vector3Like>(
203
212
  a: Vector3Like,
204
213
  b: Vector3Like,
205
214
  out: T
206
- ): T {
215
+ ) {
207
216
  out[0] = Math.min(a[0], b[0]);
208
217
  out[1] = Math.min(a[1], b[1]);
209
218
  out[2] = Math.min(a[2], b[2]);
@@ -211,17 +220,17 @@ export function min<T extends Vector3Like>(
211
220
  }
212
221
 
213
222
  /**
214
- * Returns the maximum of two vectors.
215
- * @param a The first vector.
216
- * @param b The second vector.
217
- * @param out The vector to store the result in.
223
+ * Return the maximum of two vectors.
224
+ * @param a - The first vector.
225
+ * @param b - The second vector.
226
+ * @param out - The vector to store the result in.
218
227
  * @returns The maximum.
219
228
  */
220
229
  export function max<T extends Vector3Like>(
221
230
  a: Vector3Like,
222
231
  b: Vector3Like,
223
232
  out: T
224
- ): T {
233
+ ) {
225
234
  out[0] = Math.max(a[0], b[0]);
226
235
  out[1] = Math.max(a[1], b[1]);
227
236
  out[2] = Math.max(a[2], b[2]);
@@ -229,17 +238,17 @@ export function max<T extends Vector3Like>(
229
238
  }
230
239
 
231
240
  /**
232
- * Scales a vector by a scalar.
233
- * @param vector The multiplier.
234
- * @param scalar The multiplicand.
235
- * @param out The vector to store the result in.
241
+ * Scale a vector by a scalar.
242
+ * @param vector - The multiplier.
243
+ * @param scalar - The multiplicand.
244
+ * @param out - The vector to store the result in.
236
245
  * @returns The product.
237
246
  */
238
247
  export function scale<T extends Vector3Like>(
239
248
  vector: Vector3Like,
240
249
  scalar: number,
241
250
  out: T
242
- ): T {
251
+ ) {
243
252
  out[0] = vector[0] * scalar;
244
253
  out[1] = vector[1] * scalar;
245
254
  out[2] = vector[2] * scalar;
@@ -247,11 +256,11 @@ export function scale<T extends Vector3Like>(
247
256
  }
248
257
 
249
258
  /**
250
- * Adds two vectors after scaling the second by a scalar.
251
- * @param a The augend.
252
- * @param b The addend.
253
- * @param scalar The multiplicand.
254
- * @param out The vector to store the result in.
259
+ * Add two vectors after scaling the second by a scalar.
260
+ * @param a - The augend.
261
+ * @param b - The addend.
262
+ * @param scalar - The multiplicand.
263
+ * @param out - The vector to store the result in.
255
264
  * @returns The sum.
256
265
  */
257
266
  export function scaleAndAdd<T extends Vector3Like>(
@@ -259,7 +268,7 @@ export function scaleAndAdd<T extends Vector3Like>(
259
268
  b: Vector3Like,
260
269
  scalar: number,
261
270
  out: T
262
- ): T {
271
+ ) {
263
272
  out[0] = a[0] + b[0] * scalar;
264
273
  out[1] = a[1] + b[1] * scalar;
265
274
  out[2] = a[2] + b[2] * scalar;
@@ -267,64 +276,64 @@ export function scaleAndAdd<T extends Vector3Like>(
267
276
  }
268
277
 
269
278
  /**
270
- * Calculates the Euclidean distance between two vectors.
271
- * @param a The first vector.
272
- * @param b The second vector.
279
+ * Calculate the Euclidean distance between two vectors.
280
+ * @param a - The first vector.
281
+ * @param b - The second vector.
273
282
  * @returns The distance.
274
283
  * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
275
284
  */
276
- export function distance(a: Vector3Like, b: Vector3Like): number {
277
- const x: number = b[0] - a[0];
278
- const y: number = b[1] - a[1];
279
- const z: number = b[2] - a[2];
285
+ export function distance(a: Vector3Like, b: Vector3Like) {
286
+ const x = b[0] - a[0];
287
+ const y = b[1] - a[1];
288
+ const z = b[2] - a[2];
280
289
  return Math.hypot(x, y, z);
281
290
  }
282
291
 
283
292
  /**
284
- * Calculates the squared Euclidean distance between this vector and another.
285
- * @param a The first vector.
286
- * @param b The second vector.
293
+ * Calculate the squared Euclidean distance between this vector and another.
294
+ * @param a - The first vector.
295
+ * @param b - The second vector.
287
296
  * @returns The squared distance.
288
297
  * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
289
298
  */
290
- export function squaredDistance(a: Vector3Like, b: Vector3Like): number {
291
- const x: number = b[0] - a[0];
292
- const y: number = b[1] - a[1];
293
- const z: number = b[2] - a[2];
299
+ export function squaredDistance(a: Vector3Like, b: Vector3Like) {
300
+ const x = b[0] - a[0];
301
+ const y = b[1] - a[1];
302
+ const z = b[2] - a[2];
294
303
  return x * x + y * y + z * z;
295
304
  }
296
305
 
297
306
  /**
298
- * Calculates the magnitude (length) of a vector.
299
- * @param vector The vector.
307
+ * Calculate the magnitude (length) of a vector.
308
+ * @param vector - The vector.
300
309
  * @returns The magnitude.
301
310
  */
302
- export function getMagnitude(vector: Vector3Like): number {
303
- const x: number = vector[0];
304
- const y: number = vector[1];
305
- const z: number = vector[2];
311
+ export function getMagnitude(vector: Vector3Like) {
312
+ const x = vector[0];
313
+ const y = vector[1];
314
+ const z = vector[2];
306
315
  return Math.hypot(x, y, z);
307
316
  }
308
317
 
309
318
  /**
310
- * Calculates the squared magnitude (length) of a vector.
311
- * @param vector The vector.
319
+ * Calculate the squared magnitude (length) of a vector.
320
+ * @param vector - The vector.
312
321
  * @returns The squared magnitude.
313
322
  */
314
- export function getSquaredMagnitude(vector: Vector3Like): number {
315
- const x: number = vector[0];
316
- const y: number = vector[1];
317
- const z: number = vector[2];
323
+ export function getSquaredMagnitude(vector: Vector3Like) {
324
+ const x = vector[0];
325
+ const y = vector[1];
326
+ const z = vector[2];
318
327
  return x * x + y * y + z * z;
319
328
  }
320
329
 
321
330
  /**
322
- * Negates a vector.
323
- * @param vector The vector.
324
- * @param out The vector to store the result in.
331
+ * Negate a vector.
332
+ * @param vector - The vector.
333
+ * @param out - The vector to store the result in.
325
334
  * @returns The negated vector.
326
335
  */
327
- export function negate<T extends Vector3Like>(vector: Vector3Like, out: T): T {
336
+ export function negate<T extends Vector3Like>(vector: Vector3Like, out: T) {
328
337
  out[0] = -vector[0];
329
338
  out[1] = -vector[1];
330
339
  out[2] = -vector[2];
@@ -332,12 +341,12 @@ export function negate<T extends Vector3Like>(vector: Vector3Like, out: T): T {
332
341
  }
333
342
 
334
343
  /**
335
- * Calculates the multiplicative inverse of the components of a vector.
336
- * @param vector The vector.
337
- * @param out The vector to store the result in.
344
+ * Calculate the multiplicative inverse of the components of a vector.
345
+ * @param vector - The vector.
346
+ * @param out - The vector to store the result in.
338
347
  * @returns The inverted vector.
339
348
  */
340
- export function invert<T extends Vector3Like>(vector: Vector3Like, out: T): T {
349
+ export function invert<T extends Vector3Like>(vector: Vector3Like, out: T) {
341
350
  out[0] = 1 / vector[0];
342
351
  out[1] = 1 / vector[1];
343
352
  out[2] = 1 / vector[2];
@@ -345,21 +354,18 @@ export function invert<T extends Vector3Like>(vector: Vector3Like, out: T): T {
345
354
  }
346
355
 
347
356
  /**
348
- * Normalizes a vector.
349
- * @param vector The vector.
350
- * @param out The vector to store the result in.
357
+ * Normalize a vector.
358
+ * @param vector - The vector.
359
+ * @param out - The vector to store the result in.
351
360
  * @returns The normalized vector.
352
361
  * @see [Unit vector](https://en.wikipedia.org/wiki/Unit_vector)
353
362
  */
354
- export function normalize<T extends Vector3Like>(
355
- vector: Vector3Like,
356
- out: T
357
- ): T {
358
- const x: number = vector[0];
359
- const y: number = vector[1];
360
- const z: number = vector[2];
363
+ export function normalize<T extends Vector3Like>(vector: Vector3Like, out: T) {
364
+ const x = vector[0];
365
+ const y = vector[1];
366
+ const z = vector[2];
361
367
 
362
- let len: number = x * x + y * y + z * z;
368
+ let len = x * x + y * y + z * z;
363
369
  if (len > 0) {
364
370
  len = 1 / Math.sqrt(len);
365
371
  }
@@ -371,21 +377,21 @@ export function normalize<T extends Vector3Like>(
371
377
  }
372
378
 
373
379
  /**
374
- * Calculates the dot product of two vectors.
375
- * @param a The multiplier.
376
- * @param b The multiplicand.
380
+ * Calculate the dot product of two vectors.
381
+ * @param a - The multiplier.
382
+ * @param b - The multiplicand.
377
383
  * @returns The dot product.
378
384
  * @see [Dot product](https://en.wikipedia.org/wiki/Dot_product)
379
385
  */
380
- export function dot(a: Vector3Like, b: Vector3Like): number {
386
+ export function dot(a: Vector3Like, b: Vector3Like) {
381
387
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
382
388
  }
383
389
 
384
390
  /**
385
- * Calculates the cross product of two vectors.
386
- * @param a The multiplier.
387
- * @param b The mutliplicand.
388
- * @param out The vector to store the result in.
391
+ * Calculate the cross product of two vectors.
392
+ * @param a - The multiplier.
393
+ * @param b - The mutliplicand.
394
+ * @param out - The vector to store the result in.
389
395
  * @returns The cross product.
390
396
  * @see [Cross product](https://en.wikipedia.org/wiki/Cross_product)
391
397
  */
@@ -393,14 +399,14 @@ export function cross<T extends Vector3Like>(
393
399
  a: Vector3Like,
394
400
  b: Vector3Like,
395
401
  out: T
396
- ): T {
397
- const ax: number = a[0];
398
- const ay: number = a[1];
399
- const az: number = a[2];
402
+ ) {
403
+ const ax = a[0];
404
+ const ay = a[1];
405
+ const az = a[2];
400
406
 
401
- const bx: number = b[0];
402
- const by: number = b[1];
403
- const bz: number = b[2];
407
+ const bx = b[0];
408
+ const by = b[1];
409
+ const bz = b[2];
404
410
 
405
411
  out[0] = ay * bz - az * by;
406
412
  out[1] = az * bx - ax * bz;
@@ -409,11 +415,11 @@ export function cross<T extends Vector3Like>(
409
415
  }
410
416
 
411
417
  /**
412
- * Performs a linear interpolation between two vectors.
413
- * @param a The first vector.
414
- * @param b The second vector.
415
- * @param t The interpolation amount (in `[0,1]`).
416
- * @param out The vector to store the result in.
418
+ * Perform a linear interpolation between two vectors.
419
+ * @param a - The first vector.
420
+ * @param b - The second vector.
421
+ * @param t - The interpolation amount (in `[0,1]`).
422
+ * @param out - The vector to store the result in.
417
423
  * @returns The interpolated vector.
418
424
  * @see [Linear interpolation](https://en.wikipedia.org/wiki/Linear_interpolation)
419
425
  */
@@ -422,10 +428,10 @@ export function lerp<T extends Vector3Like>(
422
428
  b: Vector3Like,
423
429
  t: number,
424
430
  out: T
425
- ): T {
426
- const ax: number = a[0];
427
- const ay: number = a[1];
428
- const az: number = a[2];
431
+ ) {
432
+ const ax = a[0];
433
+ const ay = a[1];
434
+ const az = a[2];
429
435
 
430
436
  out[0] = ax + t * (b[0] - ax);
431
437
  out[1] = ay + t * (b[1] - ay);
@@ -434,15 +440,15 @@ export function lerp<T extends Vector3Like>(
434
440
  }
435
441
 
436
442
  /**
437
- * Sets a vector to a random value with the given magnitude.
438
- * @param magnitude The magnitude.
439
- * @param out The vector to store the result in.
443
+ * Set a vector to a random value with the given magnitude.
444
+ * @param magnitude - The magnitude.
445
+ * @param out - The vector to store the result in.
440
446
  * @returns This vector.
441
447
  */
442
- export function random<T extends Vector3Like>(magnitude: number, out: T): T {
443
- const r: number = Math.random() * 2 * Math.PI;
444
- const z: number = Math.random() * 2 - 1;
445
- const zScale: number = Math.sqrt(1 - z * z) * magnitude;
448
+ export function random<T extends Vector3Like>(magnitude: number, out: T) {
449
+ const r = Math.random() * 2 * Math.PI;
450
+ const z = Math.random() * 2 - 1;
451
+ const zScale = Math.sqrt(1 - z * z) * magnitude;
446
452
 
447
453
  out[0] = Math.cos(r) * zScale;
448
454
  out[1] = Math.sin(r) * zScale;
@@ -451,10 +457,10 @@ export function random<T extends Vector3Like>(magnitude: number, out: T): T {
451
457
  }
452
458
 
453
459
  /**
454
- * Transforms a vector by a three-by-three matrix.
455
- * @param vector The vector (multiplier).
456
- * @param matrix The matrix (multiplicand).
457
- * @param out The vector to store the result in.
460
+ * Transform a vector by a three-by-three matrix.
461
+ * @param vector - The vector (multiplier).
462
+ * @param matrix - The matrix (multiplicand).
463
+ * @param out - The vector to store the result in.
458
464
  * @returns The transformed vector.
459
465
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
460
466
  */
@@ -462,10 +468,10 @@ export function transformMatrix3<T extends Vector3Like>(
462
468
  vector: Vector3Like,
463
469
  matrix: Matrix3Like,
464
470
  out: T
465
- ): T {
466
- const x: number = vector[0];
467
- const y: number = vector[1];
468
- const z: number = vector[2];
471
+ ) {
472
+ const x = vector[0];
473
+ const y = vector[1];
474
+ const z = vector[2];
469
475
 
470
476
  out[0] = x * matrix[0] + y * matrix[3] + z * matrix[6];
471
477
  out[1] = x * matrix[1] + y * matrix[4] + z * matrix[7];
@@ -474,10 +480,10 @@ export function transformMatrix3<T extends Vector3Like>(
474
480
  }
475
481
 
476
482
  /**
477
- * Transforms a vector by a four-by-four matrix.
478
- * @param vector The vector (multiplier).
479
- * @param matrix The matrix (multiplicand).
480
- * @param out The vector to store the result in.
483
+ * Transform a vector by a four-by-four matrix.
484
+ * @param vector - The vector (multiplier).
485
+ * @param matrix - The matrix (multiplicand).
486
+ * @param out - The vector to store the result in.
481
487
  * @returns The transformed vector.
482
488
  * @see [Transformation matrix](https://en.wikipedia.org/wiki/Transformation_matrix)
483
489
  */
@@ -485,13 +491,12 @@ export function transformMatrix4<T extends Vector3Like>(
485
491
  vector: Vector3Like,
486
492
  matrix: Matrix4Like,
487
493
  out: T
488
- ): T {
489
- const x: number = vector[0];
490
- const y: number = vector[1];
491
- const z: number = vector[2];
494
+ ) {
495
+ const x = vector[0];
496
+ const y = vector[1];
497
+ const z = vector[2];
492
498
 
493
- const w: number =
494
- matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15] || 1;
499
+ const w = matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15] || 1;
495
500
 
496
501
  out[0] = (matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12]) / w;
497
502
  out[1] = (matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13]) / w;
@@ -500,132 +505,117 @@ export function transformMatrix4<T extends Vector3Like>(
500
505
  }
501
506
 
502
507
  /**
503
- * Rotates a vector around the X-axis.
504
- * @param vector The vector.
505
- * @param origin The origin of the rotation.
506
- * @param radians The angle of rotation in radians.
507
- * @param out The vector to store the result in.
508
+ * Rotate a vector around the X-axis.
509
+ * @param vector - The vector.
510
+ * @param origin - The origin of the rotation.
511
+ * @param r - The angle of rotation in radians.
512
+ * @param out - The vector to store the result in.
508
513
  * @returns The rotated vector.
509
514
  */
510
515
  export function rotateX<T extends Vector3Like>(
511
516
  vector: Vector3Like,
512
517
  origin: Vector3Like,
513
- radians: number,
518
+ r: number,
514
519
  out: T
515
- ): T {
516
- const p: Vector3Like = [
517
- vector[0] - origin[0],
518
- vector[1] - origin[1],
519
- vector[2] - origin[2]
520
- ];
521
-
522
- const r: Vector3Like = [
523
- p[0],
524
- p[1] * Math.cos(radians) - p[2] * Math.sin(radians),
525
- p[1] * Math.sin(radians) + p[2] * Math.cos(radians)
526
- ];
527
-
528
- out[0] = r[0] + origin[0];
529
- out[1] = r[1] + origin[1];
530
- out[2] = r[2] + origin[2];
520
+ ) {
521
+ const p0 = vector[0] - origin[0];
522
+ const p1 = vector[1] - origin[1];
523
+ const p2 = vector[2] - origin[2];
524
+
525
+ const r1 = p1 * Math.cos(r) - p2 * Math.sin(r);
526
+ const r2 = p1 * Math.sin(r) + p2 * Math.cos(r);
527
+
528
+ out[0] = p0 + origin[0];
529
+ out[1] = r1 + origin[1];
530
+ out[2] = r2 + origin[2];
531
531
  return out;
532
532
  }
533
533
 
534
534
  /**
535
- * Rotates a vector around the Y-axis.
536
- * @param vector The vector.
537
- * @param origin The origin of the rotation.
538
- * @param radians The angle of rotation in radians.
539
- * @param out The vector to store the result in.
535
+ * Rotate a vector around the Y-axis.
536
+ * @param vector - The vector.
537
+ * @param origin - The origin of the rotation.
538
+ * @param r - The angle of rotation in radians.
539
+ * @param out - The vector to store the result in.
540
540
  * @returns The rotated vector.
541
541
  */
542
542
  export function rotateY<T extends Vector3Like>(
543
543
  vector: Vector3Like,
544
544
  origin: Vector3Like,
545
- radians: number,
545
+ r: number,
546
546
  out: T
547
- ): T {
548
- const p: Vector3Like = [
549
- vector[0] - origin[0],
550
- vector[1] - origin[1],
551
- vector[2] - origin[2]
552
- ];
553
-
554
- const r: Vector3Like = [
555
- p[2] * Math.sin(radians) + p[0] * Math.cos(radians),
556
- p[1],
557
- p[2] * Math.cos(radians) - p[0] * Math.sin(radians)
558
- ];
559
-
560
- out[0] = r[0] + origin[0];
561
- out[1] = r[1] + origin[1];
562
- out[2] = r[2] + origin[2];
547
+ ) {
548
+ const p0 = vector[0] - origin[0];
549
+ const p1 = vector[1] - origin[1];
550
+ const p2 = vector[2] - origin[2];
551
+
552
+ const r0 = p2 * Math.sin(r) + p0 * Math.cos(r);
553
+ const r2 = p2 * Math.cos(r) - p0 * Math.sin(r);
554
+
555
+ out[0] = r0 + origin[0];
556
+ out[1] = p1 + origin[1];
557
+ out[2] = r2 + origin[2];
563
558
  return out;
564
559
  }
565
560
 
566
561
  /**
567
- * Rotates a vector around the Z-axis.
568
- * @param vector The vector.
569
- * @param origin The origin of the rotation.
570
- * @param radians The angle of rotation in radians.
571
- * @param out The vector to store the result in.
562
+ * Rotate a vector around the Z-axis.
563
+ * @param vector - The vector.
564
+ * @param origin - The origin of the rotation.
565
+ * @param r - The angle of rotation in radians.
566
+ * @param out - The vector to store the result in.
572
567
  * @returns The rotated vector.
573
568
  */
574
569
  export function rotateZ<T extends Vector3Like>(
575
570
  vector: Vector3Like,
576
571
  origin: Vector3Like,
577
- radians: number,
572
+ r: number,
578
573
  out: T
579
- ): T {
580
- const p: Vector3Like = [
581
- vector[0] - origin[0],
582
- vector[1] - origin[1],
583
- vector[2] - origin[2]
584
- ];
585
-
586
- const r: Vector3Like = [
587
- p[0] * Math.cos(radians) - p[1] * Math.sin(radians),
588
- p[0] * Math.sin(radians) + p[1] * Math.cos(radians),
589
- p[2]
590
- ];
591
-
592
- out[0] = r[0] + origin[0];
593
- out[1] = r[1] + origin[1];
594
- out[2] = r[2] + origin[2];
574
+ ) {
575
+ const p0 = vector[0] - origin[0];
576
+ const p1 = vector[1] - origin[1];
577
+ const p2 = vector[2] - origin[2];
578
+
579
+ const r0 = p0 * Math.cos(r) - p1 * Math.sin(r);
580
+ const r1 = p0 * Math.sin(r) + p1 * Math.cos(r);
581
+
582
+ out[0] = r0 + origin[0];
583
+ out[1] = r1 + origin[1];
584
+ out[2] = p2 + origin[2];
595
585
  return out;
596
586
  }
597
587
 
598
588
  /**
599
- * Gets the angle between two vectors in radians.
600
- * @param a The first vector.
601
- * @param b The second vector.
589
+ * Get the angle between two vectors in radians.
590
+ * @param a - The first vector.
591
+ * @param b - The second vector.
602
592
  * @returns The angular distance from the first vector to the second.
603
593
  */
604
- export function angle(a: Vector3Like, b: Vector3Like): number {
605
- const ax: number = a[0];
606
- const ay: number = a[1];
607
- const az: number = a[2];
594
+ export function angle(a: Vector3Like, b: Vector3Like) {
595
+ const ax = a[0];
596
+ const ay = a[1];
597
+ const az = a[2];
608
598
 
609
- const bx: number = b[0];
610
- const by: number = b[1];
611
- const bz: number = b[2];
599
+ const bx = b[0];
600
+ const by = b[1];
601
+ const bz = b[2];
612
602
 
613
- const mag1: number = Math.sqrt(ax * ax + ay * ay + az * az);
614
- const mag2: number = Math.sqrt(bx * bx + by * by + bz * bz);
603
+ const mag1 = Math.sqrt(ax * ax + ay * ay + az * az);
604
+ const mag2 = Math.sqrt(bx * bx + by * by + bz * bz);
615
605
 
616
- const mag: number = mag1 * mag2;
606
+ const mag = mag1 * mag2;
617
607
 
618
- const cosine: number = mag && dot(a, b) / mag;
608
+ const cosine = mag && dot(a, b) / mag;
619
609
 
620
610
  return Math.acos(Math.min(Math.max(cosine, -1), 1));
621
611
  }
622
612
 
623
613
  /**
624
- * Sets a vector to the zero vector.
625
- * @param out The vector to store the result in.
614
+ * Set a vector to the zero vector.
615
+ * @param out - The vector to store the result in.
626
616
  * @returns This vector.
627
617
  */
628
- export function zero<T extends Vector3Like>(out: T): T {
618
+ export function zero<T extends Vector3Like>(out: T) {
629
619
  out[0] = 0;
630
620
  out[1] = 0;
631
621
  out[2] = 0;
@@ -633,13 +623,13 @@ export function zero<T extends Vector3Like>(out: T): T {
633
623
  }
634
624
 
635
625
  /**
636
- * Performs a Hermite interpolation with two control points between two vectors.
637
- * @param a The first vector.
638
- * @param b The first control point.
639
- * @param c The second control point.
640
- * @param d The second vector.
641
- * @param t The interpolation amount in the range `[0,1]`.
642
- * @param out The vector to store the result in.
626
+ * Perform a Hermite interpolation with two control points between two vectors.
627
+ * @param a - The first vector.
628
+ * @param b - The first control point.
629
+ * @param c - The second control point.
630
+ * @param d - The second vector.
631
+ * @param t - The interpolation amount in the range `[0,1]`.
632
+ * @param out - The vector to store the result in.
643
633
  * @returns The interpolated vector.
644
634
  * @see [Hermite interpolation](https://en.wikipedia.org/wiki/Hermite_interpolation)
645
635
  */
@@ -650,13 +640,13 @@ export function hermite<T extends Vector3Like>(
650
640
  d: Vector3Like,
651
641
  t: number,
652
642
  out: T
653
- ): T {
654
- const factorTimes2: number = t * t;
643
+ ) {
644
+ const factorTimes2 = t * t;
655
645
 
656
- const factor1: number = factorTimes2 * (2 * t - 3) + 1;
657
- const factor2: number = factorTimes2 * (t - 2) + t;
658
- const factor3: number = factorTimes2 * (t - 1);
659
- const factor4: number = factorTimes2 * (3 - 2 * t);
646
+ const factor1 = factorTimes2 * (2 * t - 3) + 1;
647
+ const factor2 = factorTimes2 * (t - 2) + t;
648
+ const factor3 = factorTimes2 * (t - 1);
649
+ const factor4 = factorTimes2 * (3 - 2 * t);
660
650
 
661
651
  out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
662
652
  out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
@@ -665,13 +655,13 @@ export function hermite<T extends Vector3Like>(
665
655
  }
666
656
 
667
657
  /**
668
- * Performs a Bézier interpolation with two control points between two vectors.
669
- * @param a The first vector.
670
- * @param b The first control point.
671
- * @param c The second control point.
672
- * @param d The second vector.
673
- * @param t The interpolation amount in the range `[0,1]`.
674
- * @param out The vector to store the result in.
658
+ * Perform a Bézier interpolation with two control points between two vectors.
659
+ * @param a - The first vector.
660
+ * @param b - The first control point.
661
+ * @param c - The second control point.
662
+ * @param d - The second vector.
663
+ * @param t - The interpolation amount in the range `[0,1]`.
664
+ * @param out - The vector to store the result in.
675
665
  * @returns The interpolated vector.
676
666
  * @see [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
677
667
  */
@@ -682,15 +672,15 @@ export function bezier<T extends Vector3Like>(
682
672
  d: Vector3Like,
683
673
  t: number,
684
674
  out: T
685
- ): T {
686
- const inverseFactor: number = 1 - t;
687
- const inverseFactorTimesTwo: number = inverseFactor * inverseFactor;
688
- const factorTimes2: number = t * t;
675
+ ) {
676
+ const inverseFactor = 1 - t;
677
+ const inverseFactorTimesTwo = inverseFactor * inverseFactor;
678
+ const factorSq = t * t;
689
679
 
690
- const factor1: number = inverseFactorTimesTwo * inverseFactor;
691
- const factor2: number = 3 * t * inverseFactorTimesTwo;
692
- const factor3: number = 3 * factorTimes2 * inverseFactor;
693
- const factor4: number = factorTimes2 * t;
680
+ const factor1 = inverseFactorTimesTwo * inverseFactor;
681
+ const factor2 = 3 * t * inverseFactorTimesTwo;
682
+ const factor3 = 3 * factorSq * inverseFactor;
683
+ const factor4 = factorSq * t;
694
684
 
695
685
  out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
696
686
  out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
@@ -699,10 +689,10 @@ export function bezier<T extends Vector3Like>(
699
689
  }
700
690
 
701
691
  /**
702
- * Transforms a vector by a quaternion.
703
- * @param vector The vector.
704
- * @param quaternion The quaternion.
705
- * @param out The vector to store the result in.
692
+ * Transform a vector by a quaternion.
693
+ * @param vector - The vector.
694
+ * @param quaternion - The quaternion.
695
+ * @param out - The vector to store the result in.
706
696
  * @returns The transformed vector.
707
697
  * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
708
698
  */
@@ -710,25 +700,25 @@ export function transformQuaternion<T extends Vector3Like>(
710
700
  vector: Vector3Like,
711
701
  quaternion: QuaternionLike,
712
702
  out: T
713
- ): T {
714
- const qx: number = quaternion[0];
715
- const qy: number = quaternion[1];
716
- const qz: number = quaternion[2];
717
- const qw: number = quaternion[3];
703
+ ) {
704
+ const qx = quaternion[0];
705
+ const qy = quaternion[1];
706
+ const qz = quaternion[2];
707
+ const qw = quaternion[3];
718
708
 
719
- const x: number = vector[0];
720
- const y: number = vector[1];
721
- const z: number = vector[2];
709
+ const x = vector[0];
710
+ const y = vector[1];
711
+ const z = vector[2];
722
712
 
723
- let uvx: number = qy * z - qz * y;
724
- let uvy: number = qz * x - qx * z;
725
- let uvz: number = qx * y - qy * x;
713
+ let uvx = qy * z - qz * y;
714
+ let uvy = qz * x - qx * z;
715
+ let uvz = qx * y - qy * x;
726
716
 
727
- let uuvx: number = qy * uvz - qz * uvy;
728
- let uuvy: number = qz * uvx - qx * uvz;
729
- let uuvz: number = qx * uvy - qy * uvx;
717
+ let uuvx = qy * uvz - qz * uvy;
718
+ let uuvy = qz * uvx - qx * uvz;
719
+ let uuvz = qx * uvy - qy * uvx;
730
720
 
731
- const w2: number = qw * 2;
721
+ const w2 = qw * 2;
732
722
  uvx *= w2;
733
723
  uvy *= w2;
734
724
  uvz *= w2;
@@ -743,29 +733,28 @@ export function transformQuaternion<T extends Vector3Like>(
743
733
  return out;
744
734
  }
745
735
 
746
- /** The unit three-dimensional vector that represents the X-axis. */
747
- const xAxis: Vector3Like = new Float32Array([1, 0, 0]) as Vector3Like;
736
+ // The unit three-dimensional vector that represents the X-axis.
737
+ const xAxis = fromValues(1, 0, 0, createVector3Like());
748
738
 
749
- /** The unit three-dimensional vector that represents the Y-axis. */
750
- const yAxis: Vector3Like = new Float32Array([0, 1, 0]) as Vector3Like;
739
+ // The unit three-dimensional vector that represents the Y-axis.
740
+ const yAxis = fromValues(0, 1, 0, createVector3Like());
751
741
 
752
- /** A three-dimensional vector that is used to store intermediary values. */
753
- const intermediary: Vector3Like = new Float32Array(3) as Vector3Like;
742
+ // Used to store intermediary values for some functions.
743
+ const intermediary = createVector3Like();
754
744
 
755
745
  /**
756
- * Creates a quaternion that represents the shortest rotation from one unit
757
- * vector to another.
758
- * @param a The first vector.
759
- * @param b The second vector.
760
- * @param out The quaternion to store the result in.
746
+ * Create a quaternion that represents the shortest rotation from one unit vector to another.
747
+ * @param a - The first vector.
748
+ * @param b - The second vector.
749
+ * @param out - The quaternion to store the result in.
761
750
  * @returns The quaternion.
762
751
  */
763
752
  export function rotationTo<T extends QuaternionLike>(
764
753
  a: Vector3Like,
765
754
  b: Vector3Like,
766
755
  out: T
767
- ): T {
768
- const dp: number = dot(a, b);
756
+ ) {
757
+ const dp = dot(a, b);
769
758
 
770
759
  if (dp < epsilon - 1) {
771
760
  cross(xAxis, a, intermediary);
@@ -793,666 +782,422 @@ export function rotationTo<T extends QuaternionLike>(
793
782
  out[1] = intermediary[1];
794
783
  out[2] = intermediary[2];
795
784
  out[3] = 1 + dp;
796
- return normalizeVector4(out as Vector4Like, out as Vector4Like) as T;
785
+ return normalizeVector4(out, out);
797
786
  }
798
787
 
799
788
  /**
800
789
  * A quantity with magnitude and direction in three dimensions.
801
790
  * @see [Euclidean vector](https://en.wikipedia.org/wiki/Euclidean_vector)
802
791
  */
803
- export default class Vector3 extends Float32Array implements Vector {
804
- /**
805
- * Creates a vector with the given values.
806
- * @param x The first component.
807
- * @param y The second component.
808
- * @param z The third component.
809
- * @returns A new vector.
810
- */
811
- public static fromValues(x: number, y: number, z: number): Vector3;
812
-
813
- /**
814
- * Creates a vector with the given values.
815
- * @param x The first component.
816
- * @param y The second component.
817
- * @param z The third component.
818
- * @param out The vector to store the result in.
792
+ export default class Vector3
793
+ extends Float32Array
794
+ implements Vector, Vector3Like
795
+ {
796
+ /**
797
+ * Create a vector with the given values.
798
+ * @param x - The first component.
799
+ * @param y - The second component.
800
+ * @param z - The third component.
801
+ * @param out - The vector to store the result in.
819
802
  * @returns A new vector.
820
803
  */
821
804
  public static fromValues<T extends Vector3Like>(
822
805
  x: number,
823
806
  y: number,
824
807
  z: number,
825
- out: T
826
- ): T;
827
-
828
- public static fromValues<T extends Vector3Like>(
829
- x: number,
830
- y: number,
831
- z: number,
832
- out: T = new Vector3() as T
833
- ): T {
808
+ out = new Vector3() as unknown as T
809
+ ) {
834
810
  return fromValues(x, y, z, out);
835
811
  }
836
812
 
837
813
  /**
838
- * Creates a three-dimensional zero vector.
814
+ * Create a three-dimensional zero vector.
839
815
  * @see [Euclidean vector](https://en.wikipedia.org/wiki/Euclidean_vector)
840
816
  */
841
817
  public constructor() {
842
818
  super(3);
843
819
  }
844
820
 
821
+ /** The first component of this vector. */
822
+ public 0: number;
823
+
824
+ /** The second component of this vector. */
825
+ public 1: number;
826
+
827
+ /** The third component of this vector. */
828
+ public 2: number;
829
+
845
830
  /**
846
- * Determines whether this vector is roughly equivalent to another.
847
- * @param vector The other vector.
848
- * @returns Whether the vectors are equivalent.
831
+ * Determine whether or not this vector is roughly equivalent to another.
832
+ * @param vector - The other vector.
833
+ * @returns Whether or not the vectors are equivalent.
849
834
  */
850
- public equals(vector: Vector3Like): boolean {
835
+ public equals(vector: Vector3Like) {
851
836
  return equals(this, vector);
852
837
  }
853
838
 
854
839
  /**
855
- * Determines whether this vector is exactly equivalent to another.
856
- * @param vector The other vector.
857
- * @returns Whether the vectors are equivalent.
840
+ * Determine whether or not this vector is exactly equivalent to another.
841
+ * @param vector - The other vector.
842
+ * @returns Whether or not the vectors are equivalent.
858
843
  */
859
- public exactEquals(vector: Vector3Like): boolean {
844
+ public exactEquals(vector: Vector3Like) {
860
845
  return exactEquals(this, vector);
861
846
  }
862
847
 
863
848
  /**
864
- * Adds two vectors of the same size.
865
- * @param vector The other vector.
866
- * @returns The sum of the vectors.
867
- */
868
- public add(vector: Vector3Like): Vector3;
869
-
870
- /**
871
- * Adds two vectors of the same size.
872
- * @param vector The other vector.
873
- * @param out The vector to store the result in.
849
+ * Add two vectors of the same size.
850
+ * @param vector - The other vector.
851
+ * @param out - The vector to store the result in.
874
852
  * @returns The sum of the vectors.
875
853
  */
876
- public add<T extends Vector3Like>(vector: Vector3Like, out: T): T;
877
-
878
854
  public add<T extends Vector3Like>(
879
855
  vector: Vector3Like,
880
- out: T = new Vector3() as T
881
- ): T {
856
+ out: T = new Vector3() as unknown as T
857
+ ) {
882
858
  return add(this, vector, out);
883
859
  }
884
860
 
885
861
  /**
886
- * Creates a copy of this vector.
862
+ * Copy the values from this vector to another one.
863
+ * @param out - The vector to store the result in.
887
864
  * @returns The copy.
888
865
  */
889
- public clone(): Vector3;
890
-
891
- /**
892
- * Copies the values from this vector to another one.
893
- * @param out The vector to store the result in.
894
- * @returns The copy.
895
- */
896
- public clone<T extends Vector3Like>(out: T): T;
897
-
898
- public clone<T extends Vector3Like>(out: T = new Vector3() as T): T {
866
+ public clone<T extends Vector3Like>(out = new Vector3() as unknown as T) {
899
867
  return copy(this, out);
900
868
  }
901
869
 
902
870
  /**
903
- * Copies the values of another vector into this one.
904
- * @param vector The vector to copy.
871
+ * Copy the values of another vector into this one.
872
+ * @param vector - The vector to copy.
905
873
  * @returns This vector.
906
874
  */
907
- public copy(vector: Vector3Like): this {
875
+ public copy(vector: Vector3Like) {
908
876
  return copy(vector, this);
909
877
  }
910
878
 
911
879
  /**
912
- * Multiplies this vector by another.
913
- * @param vvector The other vector.
914
- * @returns The product of the vectors.
915
- */
916
- public multiply(vector: Vector3Like): Vector3;
917
-
918
- /**
919
- * Multiplies this vector by another.
920
- * @param vector The other vector.
921
- * @param out The vector to store the result in.
880
+ * Multiply this vector by another.
881
+ * @param vector - The other vector.
882
+ * @param out - The vector to store the result in.
922
883
  * @returns The product of the vectors.
923
884
  */
924
- public multiply<T extends Vector3Like>(vector: Vector3Like, out: T): T;
925
-
926
885
  public multiply<T extends Vector3Like>(
927
886
  vector: Vector3Like,
928
- out: T = new Vector3() as T
929
- ): T {
887
+ out = new Vector3() as unknown as T
888
+ ) {
930
889
  return multiply(this, vector, out);
931
890
  }
932
891
 
933
892
  /**
934
- * Divides this vector by another.
935
- * @param vector The other vector.
936
- * @returns The quotient of the vectors.
937
- */
938
- public divide(vector: Vector3Like): Vector3;
939
-
940
- /**
941
- * Divides this vector by another.
942
- * @param vector The other vector.
943
- * @param out The vector to store the result in.
893
+ * Divide this vector by another.
894
+ * @param vector - The other vector.
895
+ * @param out - The vector to store the result in.
944
896
  * @returns The quotient of the vectors.
945
897
  */
946
- public divide<T extends Vector3Like>(vector: Vector3Like, out: T): T;
947
-
948
898
  public divide<T extends Vector3Like>(
949
899
  vector: Vector3Like,
950
- out: T = new Vector3() as T
951
- ): T {
900
+ out = new Vector3() as unknown as T
901
+ ) {
952
902
  return divide(this, vector, out);
953
903
  }
954
904
 
955
905
  /**
956
- * Subtracts another vector from this one.
957
- * @param vector The other vector.
958
- * @returns The difference between the vectors.
959
- */
960
- public subtract(vector: Vector3Like): Vector3;
961
-
962
- /**
963
- * Subtracts another vector from this one.
964
- * @param vector The other vector.
965
- * @param out The vector to store the result in.
906
+ * Subtract another vector from this one.
907
+ * @param vector - The other vector.
908
+ * @param out - The vector to store the result in.
966
909
  * @returns The difference between the vectors.
967
910
  */
968
- public subtract<T extends Vector3Like>(vector: Vector3Like, out: T): T;
969
-
970
911
  public subtract<T extends Vector3Like>(
971
912
  vector: Vector3Like,
972
- out: T = new Vector3() as T
973
- ): T {
913
+ out = new Vector3() as unknown as T
914
+ ) {
974
915
  return subtract(this, vector, out);
975
916
  }
976
917
 
977
918
  /**
978
- * Rounds up the components of this vector.
979
- * @returns The rounded vector.
980
- */
981
- public ceil(): Vector3;
982
-
983
- /**
984
- * Rounds up the components of this vector.
985
- * @param out The vector to store the result in.
919
+ * Round up the components of this vector.
920
+ * @param out - The vector to store the result in.
986
921
  * @returns The rounded vector.
987
922
  */
988
- public ceil<T extends Vector3Like>(out: T): T;
989
-
990
- public ceil<T extends Vector3Like>(out: T = new Vector3() as T): T {
923
+ public ceil<T extends Vector3Like>(out = new Vector3() as unknown as T) {
991
924
  return ceil(this, out);
992
925
  }
993
926
 
994
927
  /**
995
- * Rounds down the components of this vector.
996
- * @returns The rounded vector.
997
- */
998
- public floor(): Vector3;
999
-
1000
- /**
1001
- * Rounds down the components of this vector.
1002
- * @param out The vector to store the result in.
928
+ * Round down the components of this vector.
929
+ * @param out - The vector to store the result in.
1003
930
  * @returns The rounded vector.
1004
931
  */
1005
- public floor<T extends Vector3Like>(out: T): T;
1006
-
1007
- public floor<T extends Vector3Like>(out: T = new Vector3() as T): T {
932
+ public floor<T extends Vector3Like>(out = new Vector3() as unknown as T) {
1008
933
  return floor(this, out);
1009
934
  }
1010
935
 
1011
936
  /**
1012
- * Rounds the components of this vector.
937
+ * Round the components of this vector.
938
+ * @param out - The vector to store the result in.
1013
939
  * @returns The rounded vector.
1014
940
  */
1015
- public round(): Vector3;
1016
-
1017
- /**
1018
- * Rounds the components of this vector.
1019
- * @param out The vector to store the result in.
1020
- * @returns The rounded vector.
1021
- */
1022
- public round<T extends Vector3Like>(out: T): T;
1023
-
1024
- public round<T extends Vector3Like>(out: T = new Vector3() as T): T {
941
+ public round<T extends Vector3Like>(out = new Vector3() as unknown as T) {
1025
942
  return round(this, out);
1026
943
  }
1027
944
 
1028
945
  /**
1029
- * Returns the minimum of this and another vector.
1030
- * @param vector The other vector.
1031
- * @returns The minimum.
1032
- */
1033
- public min(vector: Vector3Like): Vector3;
1034
-
1035
- /**
1036
- * Returns the minimum of this and another vector.
1037
- * @param vector The other vector.
1038
- * @param out The vector to store the result in.
946
+ * Return the minimum of this and another vector.
947
+ * @param vector - The other vector.
948
+ * @param out - The vector to store the result in.
1039
949
  * @returns The minimum.
1040
950
  */
1041
- public min<T extends Vector3Like>(vector: Vector3Like, out: T): T;
1042
-
1043
951
  public min<T extends Vector3Like>(
1044
952
  vector: Vector3Like,
1045
- out: T = new Vector3() as T
1046
- ): T {
953
+ out: T = new Vector3() as unknown as T
954
+ ) {
1047
955
  return min(this, vector, out);
1048
956
  }
1049
957
 
1050
958
  /**
1051
- * Returns the maximum of this and another vector.
1052
- * @param vector The other vector.
1053
- * @returns The maximum.
1054
- */
1055
- public max(vector: Vector3Like): Vector3;
1056
-
1057
- /**
1058
- * Returns the maximum of this and another vector.
1059
- * @param vector The other vector.
1060
- * @param out The vector to store the result in.
959
+ * Return the maximum of this and another vector.
960
+ * @param vector - The other vector.
961
+ * @param out - The vector to store the result in.
1061
962
  * @returns The maximum.
1062
963
  */
1063
- public max<T extends Vector3Like>(vector: Vector3Like, out: T): T;
1064
-
1065
964
  public max<T extends Vector3Like>(
1066
965
  vector: Vector3Like,
1067
- out: T = new Vector3() as T
1068
- ): T {
966
+ out = new Vector3() as unknown as T
967
+ ) {
1069
968
  return max(this, vector, out);
1070
969
  }
1071
970
 
1072
971
  /**
1073
- * Scales this vector by a scalar.
1074
- * @param scalar The scalar.
1075
- * @returns The scaled vector.
1076
- */
1077
- public scale(scalar: number): Vector3;
1078
-
1079
- /**
1080
- * Scales this vector by a scalar.
1081
- * @param scalar The scalar.
1082
- * @param out The vector to store the result in.
972
+ * Scale this vector by a scalar.
973
+ * @param scalar - The scalar.
974
+ * @param out - The vector to store the result in.
1083
975
  * @returns The scaled vector.
1084
976
  */
1085
- public scale<T extends Vector3Like>(scalar: number, out: T): T;
1086
-
1087
977
  public scale<T extends Vector3Like>(
1088
978
  scalar: number,
1089
- out: T = new Vector3() as T
1090
- ): T {
979
+ out = new Vector3() as unknown as T
980
+ ) {
1091
981
  return scale(this, scalar, out);
1092
982
  }
1093
983
 
1094
984
  /**
1095
- * Adds another vector to this one after scaling the other by a scalar.
1096
- * @param vector The other vector.
1097
- * @param scalar The scalar.
1098
- * @returns The sum.
1099
- */
1100
- public scaleAndAdd(vector: Vector3Like, scalar: number): Vector3;
1101
-
1102
- /**
1103
- * Adds another vector to this one after scaling the other by a scalar.
1104
- * @param vector The other vector.
1105
- * @param scalar The scalar.
1106
- * @param out The vector to store the result in.
985
+ * Add another vector to this one after scaling the other by a scalar.
986
+ * @param vector - The other vector.
987
+ * @param scalar - The scalar.
988
+ * @param out - The vector to store the result in.
1107
989
  * @returns The sum.
1108
990
  */
1109
991
  public scaleAndAdd<T extends Vector3Like>(
1110
992
  vector: Vector3Like,
1111
993
  scalar: number,
1112
- out: T
1113
- ): T;
1114
-
1115
- public scaleAndAdd<T extends Vector3Like>(
1116
- vector: Vector3Like,
1117
- scalar: number,
1118
- out: T = new Vector3() as T
1119
- ): T {
994
+ out = new Vector3() as unknown as T
995
+ ) {
1120
996
  return scaleAndAdd(this, vector, scalar, out);
1121
997
  }
1122
998
 
1123
999
  /**
1124
- * Calculates the Euclidean distance between this vector and another.
1125
- * @param vector The other vector.
1000
+ * Calculate the Euclidean distance between this vector and another.
1001
+ * @param vector - The other vector.
1126
1002
  * @returns The distance.
1127
1003
  * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
1128
1004
  */
1129
- public distance(vector: Vector3Like): number {
1005
+ public distance(vector: Vector3Like) {
1130
1006
  return distance(this, vector);
1131
1007
  }
1132
1008
 
1133
1009
  /**
1134
- * Calculates the squared Euclidean distance between this vector and
1135
- * another.
1136
- * @param vector The other vector.
1010
+ * Calculate the squared Euclidean distance between this vector and another.
1011
+ * @param vector - The other vector.
1137
1012
  * @returns The squared distance.
1138
1013
  * @see [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance)
1139
1014
  */
1140
- public squaredDistance(vector: Vector3Like): number {
1015
+ public squaredDistance(vector: Vector3Like) {
1141
1016
  return squaredDistance(this, vector);
1142
1017
  }
1143
1018
 
1144
- /** The magnitude (length) of this vector. */
1145
- public get magnitude(): number {
1019
+ /** Get the magnitude (length) of this vector. */
1020
+ public get magnitude() {
1146
1021
  return getMagnitude(this);
1147
1022
  }
1148
1023
 
1149
- /** The squared magnitude (length) of this vector. */
1150
- public get squaredMagnitude(): number {
1024
+ /** Get the squared magnitude (length) of this vector. */
1025
+ public get squaredMagnitude() {
1151
1026
  return getSquaredMagnitude(this);
1152
1027
  }
1153
1028
 
1154
1029
  /**
1155
- * Negates this vector.
1156
- * @returns The negated vector.
1157
- */
1158
- public negate(): Vector3;
1159
-
1160
- /**
1161
- * Negates this vector.
1162
- * @param out The vector to store the result in.
1030
+ * Negate this vector.
1031
+ * @param out - The vector to store the result in.
1163
1032
  * @returns The negated vector.
1164
1033
  */
1165
- public negate<T extends Vector3Like>(out: T): T;
1166
-
1167
- public negate<T extends Vector3Like>(out: T = new Vector3() as T): T {
1034
+ public negate<T extends Vector3Like>(out = new Vector3() as unknown as T) {
1168
1035
  return negate(this, out);
1169
1036
  }
1170
1037
 
1171
1038
  /**
1172
- * Calculates the multiplicative inverse of the components of this vector.
1039
+ * Calculate the multiplicative inverse of the components of this vector.
1040
+ * @param out - The vector to store the result in.
1173
1041
  * @returns The inverted vector.
1174
1042
  */
1175
- public invert(): Vector3;
1176
-
1177
- /**
1178
- * Calculates the multiplicative inverse of the components of this vector.
1179
- * @param out The vector to store the result in.
1180
- * @returns The inverted vector.
1181
- */
1182
- public invert<T extends Vector3Like>(out: T): T;
1183
-
1184
- public invert<T extends Vector3Like>(out: T = new Vector3() as T): T {
1043
+ public invert<T extends Vector3Like>(out = new Vector3() as unknown as T) {
1185
1044
  return invert(this, out);
1186
1045
  }
1187
1046
 
1188
1047
  /**
1189
- * Normalizes this vector.
1190
- * @returns The normalized vector.
1191
- * @see [Unit vector](https://en.wikipedia.org/wiki/Unit_vector)
1192
- */
1193
- public normalize(): Vector3;
1194
-
1195
- /**
1196
- * Normalizes this vector.
1197
- * @param out The vector to store the result in.
1048
+ * Normalize this vector.
1049
+ * @param out - The vector to store the result in.
1198
1050
  * @returns The normalized vector.
1199
1051
  * @see [Unit vector](https://en.wikipedia.org/wiki/Unit_vector)
1200
1052
  */
1201
- public normalize<T extends Vector3Like>(out: T): T;
1202
-
1203
- public normalize<T extends Vector3Like>(out: T = new Vector3() as T): T {
1053
+ public normalize<T extends Vector3Like>(out = new Vector3() as unknown as T) {
1204
1054
  return normalize(this, out);
1205
1055
  }
1206
1056
 
1207
1057
  /**
1208
- * Calculates the dot product of this and another vector.
1209
- * @param vector The other vector.
1058
+ * Calculate the dot product of this and another vector.
1059
+ * @param vector - The other vector.
1210
1060
  * @returns The dot product.
1211
1061
  * @see [Dot product](https://en.wikipedia.org/wiki/Dot_product)
1212
1062
  */
1213
- public dot(vector: Vector3Like): number {
1063
+ public dot(vector: Vector3Like) {
1214
1064
  return dot(this, vector);
1215
1065
  }
1216
1066
 
1217
1067
  /**
1218
- * Calculates the cross product of this and another vector.
1219
- * @param vector The other vector.
1220
- * @returns The cross product.
1221
- * @see [Cross product](https://en.wikipedia.org/wiki/Cross_product)
1222
- */
1223
- public cross(vector: Vector3Like): Vector3;
1224
-
1225
- /**
1226
- * Calculates the cross product of this and another vector.
1227
- * @param vector The other vector.
1228
- * @param out The vector to store the result in.
1068
+ * Calculate the cross product of this and another vector.
1069
+ * @param vector - The other vector.
1070
+ * @param out - The vector to store the result in.
1229
1071
  * @returns The cross product.
1230
1072
  * @see [Cross product](https://en.wikipedia.org/wiki/Cross_product)
1231
1073
  */
1232
- public cross<T extends Vector3Like>(vector: Vector3Like, out: T): T;
1233
-
1234
1074
  public cross<T extends Vector3Like>(
1235
1075
  vector: Vector3Like,
1236
- out: T = new Vector3() as T
1237
- ): T {
1076
+ out = new Vector3() as unknown as T
1077
+ ) {
1238
1078
  return cross(this, vector, out);
1239
1079
  }
1240
1080
 
1241
1081
  /**
1242
- * Performs a linear interpolation between this and another vector.
1243
- * @param vector The other vector.
1244
- * @param t The interpolation amount (in `[0,1]`).
1245
- * @returns The interpolated vector.
1246
- * @see [Linear interpolation](https://en.wikipedia.org/wiki/Linear_interpolation)
1247
- */
1248
- public lerp(vector: Vector3Like, t: number): Vector3;
1249
-
1250
- /**
1251
- * Performs a linear interpolation between this and another vector.
1252
- * @param vector The other vector.
1253
- * @param t The interpolation amount (in `[0,1]`).
1254
- * @param out The vector to store the result in.
1082
+ * Perform a linear interpolation between this and another vector.
1083
+ * @param vector - The other vector.
1084
+ * @param t - The interpolation amount (in `[0,1]`).
1085
+ * @param out - The vector to store the result in.
1255
1086
  * @returns The interpolated vector.
1256
1087
  * @see [Linear interpolation](https://en.wikipedia.org/wiki/Linear_interpolation)
1257
1088
  */
1258
- public lerp<T extends Vector3Like>(vector: Vector3Like, t: number, out: T): T;
1259
-
1260
1089
  public lerp<T extends Vector3Like>(
1261
1090
  vector: Vector3Like,
1262
1091
  t: number,
1263
- out: T = new Vector3() as T
1264
- ): T {
1092
+ out = new Vector3() as unknown as T
1093
+ ) {
1265
1094
  return lerp(this, vector, t, out);
1266
1095
  }
1267
1096
 
1268
1097
  /**
1269
- * Sets this vector to a random value with the given magnitude.
1270
- * @param magnitude The magnitude.
1098
+ * Set this vector to a random value with the given magnitude.
1099
+ * @param magnitude - The magnitude.
1271
1100
  * @returns This vector.
1272
1101
  */
1273
- public random(magnitude = 1): this {
1102
+ public random(magnitude = 1) {
1274
1103
  return random(magnitude, this);
1275
1104
  }
1276
1105
 
1277
1106
  /**
1278
- * Transforms this vector by a three-by-three matrix.
1279
- * @param matrix The matrix.
1280
- * @returns The transformed vector.
1281
- */
1282
- public transformMatrix3(matrix: Matrix3Like): Vector3;
1283
-
1284
- /**
1285
- * Transforms this vector by a three-by-three matrix.
1286
- * @param matrix The matrix.
1287
- * @param out The vector to store the result in.
1107
+ * Transform this vector by a three-by-three matrix.
1108
+ * @param matrix - The matrix.
1109
+ * @param out - The vector to store the result in.
1288
1110
  * @returns The transformed vector.
1289
1111
  */
1290
1112
  public transformMatrix3<T extends Vector3Like>(
1291
1113
  matrix: Matrix3Like,
1292
- out: T
1293
- ): T;
1294
-
1295
- public transformMatrix3<T extends Vector3Like>(
1296
- matrix: Matrix3Like,
1297
- out: T = new Vector3() as T
1298
- ): T {
1114
+ out = new Vector3() as unknown as T
1115
+ ) {
1299
1116
  return transformMatrix3(this, matrix, out);
1300
1117
  }
1301
1118
 
1302
1119
  /**
1303
- * Transforms this vector by a four-by-four matrix.
1304
- * @param matrix The matrix.
1305
- * @returns The transformed vector.
1306
- */
1307
- public transformMatrix4(matrix: Matrix4Like): Vector3;
1308
-
1309
- /**
1310
- * Transforms this vector by a four-by-four matrix.
1311
- * @param matrix The matrix.
1312
- * @param out The vector to store the result in.
1120
+ * Transform this vector by a four-by-four matrix.
1121
+ * @param matrix - The matrix.
1122
+ * @param out - The vector to store the result in.
1313
1123
  * @returns The transformed vector.
1314
1124
  */
1315
1125
  public transformMatrix4<T extends Vector3Like>(
1316
1126
  matrix: Matrix4Like,
1317
- out: T
1318
- ): T;
1319
-
1320
- public transformMatrix4<T extends Vector3Like>(
1321
- matrix: Matrix4Like,
1322
- out: T = new Vector3() as T
1323
- ): T {
1127
+ out = new Vector3() as unknown as T
1128
+ ) {
1324
1129
  return transformMatrix4(this, matrix, out);
1325
1130
  }
1326
1131
 
1327
1132
  /**
1328
- * Rotates this vector around the X-axis.
1329
- * @param origin The origin of the rotation.
1330
- * @param radians The angle of rotation in radians.
1331
- * @returns The rotated vector.
1332
- */
1333
- public rotateX(origin: Vector3Like, radians: number): Vector3;
1334
-
1335
- /**
1336
- * Rotates this vector around the X-axis.
1337
- * @param origin The origin of the rotation.
1338
- * @param radians The angle of rotation in radians.
1339
- * @param out The vector to store the result in.
1133
+ * Rotate this vector around the X-axis.
1134
+ * @param origin - The origin of the rotation.
1135
+ * @param r - The angle of rotation in radians.
1136
+ * @param out - The vector to store the result in.
1340
1137
  * @returns The rotated vector.
1341
1138
  */
1342
1139
  public rotateX<T extends Vector3Like>(
1343
1140
  origin: Vector3Like,
1344
- radians: number,
1345
- out: T
1346
- ): T;
1347
-
1348
- public rotateX<T extends Vector3Like>(
1349
- origin: Vector3Like,
1350
- radians: number,
1351
- out: T = new Vector3() as T
1352
- ): T {
1353
- return rotateX(this, origin, radians, out);
1141
+ r: number,
1142
+ out = new Vector3() as unknown as T
1143
+ ) {
1144
+ return rotateX(this, origin, r, out);
1354
1145
  }
1355
1146
 
1356
1147
  /**
1357
- * Rotates this vector around the Y-axis.
1358
- * @param origin The origin of the rotation.
1359
- * @param radians The angle of rotation in radians.
1360
- * @returns The rotated vector.
1361
- */
1362
- public rotateY(origin: Vector3Like, radians: number): Vector3;
1363
-
1364
- /**
1365
- * Rotates this vector around the Y-axis.
1366
- * @param origin The origin of the rotation.
1367
- * @param radians The angle of rotation in radians.
1368
- * @param out The vector to store the result in.
1148
+ * Rotate this vector around the Y-axis.
1149
+ * @param origin - The origin of the rotation.
1150
+ * @param r - The angle of rotation in radians.
1151
+ * @param out - The vector to store the result in.
1369
1152
  * @returns The rotated vector.
1370
1153
  */
1371
1154
  public rotateY<T extends Vector3Like>(
1372
1155
  origin: Vector3Like,
1373
- radians: number,
1374
- out: T
1375
- ): T;
1376
-
1377
- public rotateY<T extends Vector3Like>(
1378
- origin: Vector3Like,
1379
- radians: number,
1380
- out: T = new Vector3() as T
1381
- ): T {
1382
- return rotateY(this, origin, radians, out);
1156
+ r: number,
1157
+ out = new Vector3() as unknown as T
1158
+ ) {
1159
+ return rotateY(this, origin, r, out);
1383
1160
  }
1384
1161
 
1385
1162
  /**
1386
- * Rotates this vector around the Z-axis.
1387
- * @param origin The origin of the rotation.
1388
- * @param radians The angle of rotation in radians.
1163
+ * Rotate this vector around the Z-axis.
1164
+ * @param origin - The origin of the rotation.
1165
+ * @param r - The angle of rotation in radians.
1166
+ * @param out - The vector to store the result in.
1389
1167
  * @returns The rotated vector.
1390
1168
  */
1391
- public rotateZ(origin: Vector3Like, radians: number): Vector3;
1392
-
1393
- /**
1394
- * Rotates this vector around the Z-axis.
1395
- * @param origin The origin of the rotation.
1396
- * @param radians The angle of rotation in radians.
1397
- * @param out The vector to store the result in.
1398
- * @returns The rotated vector.
1399
- */
1400
- public rotateZ<T extends Vector3Like>(
1401
- origin: Vector3Like,
1402
- radians: number,
1403
- out: T
1404
- ): T;
1405
-
1406
1169
  public rotateZ<T extends Vector3Like>(
1407
1170
  origin: Vector3Like,
1408
- radians: number,
1409
- out: T = new Vector3() as T
1410
- ): T {
1411
- return rotateZ(this, origin, radians, out);
1171
+ r: number,
1172
+ out = new Vector3() as unknown as T
1173
+ ) {
1174
+ return rotateZ(this, origin, r, out);
1412
1175
  }
1413
1176
 
1414
1177
  /**
1415
- * Gets the angle from this vector to another in radians.
1416
- * @param vector The other vector.
1178
+ * Get the angle from this vector to another in radians.
1179
+ * @param vector - The other vector.
1417
1180
  * @returns The angular distance from this vector to the other.
1418
1181
  */
1419
- public angle(vector: Vector3Like): number {
1182
+ public angle(vector: Vector3Like) {
1420
1183
  return angle(this, vector);
1421
1184
  }
1422
1185
 
1423
1186
  /**
1424
- * Sets this to the zero vector.
1187
+ * Set this to the zero vector.
1425
1188
  * @returns This vector.
1426
1189
  */
1427
- public zero(): this {
1190
+ public zero() {
1428
1191
  return zero(this);
1429
1192
  }
1430
1193
 
1431
1194
  /**
1432
- * Performs a Hermite interpolation with two control points between this
1433
- * vector and another.
1434
- * @param a The first control point.
1435
- * @param b The second control point.
1436
- * @param end The other vector.
1437
- * @param t The interpolation amount in the range `[0,1]`.
1438
- * @returns The interpolated vector.
1439
- * @see [Hermite interpolation](https://en.wikipedia.org/wiki/Hermite_interpolation)
1440
- */
1441
- public hermite(
1442
- a: Vector3Like,
1443
- b: Vector3Like,
1444
- end: Vector3Like,
1445
- t: number
1446
- ): Vector3;
1447
-
1448
- /**
1449
- * Performs a Hermite interpolation with two control points between this
1450
- * vector and another.
1451
- * @param a The first control point.
1452
- * @param b The second control point.
1453
- * @param end The other vector.
1454
- * @param t The interpolation amount in the range `[0,1]`.
1455
- * @param out The vector to store the result in.
1195
+ * Perform a Hermite interpolation with two control points between this vector and another.
1196
+ * @param a - The first control point.
1197
+ * @param b - The second control point.
1198
+ * @param end - The other vector.
1199
+ * @param t - The interpolation amount in the range `[0,1]`.
1200
+ * @param out - The vector to store the result in.
1456
1201
  * @returns The interpolated vector.
1457
1202
  * @see [Hermite interpolation](https://en.wikipedia.org/wiki/Hermite_interpolation)
1458
1203
  */
@@ -1461,113 +1206,55 @@ export default class Vector3 extends Float32Array implements Vector {
1461
1206
  b: Vector3Like,
1462
1207
  end: Vector3Like,
1463
1208
  t: number,
1464
- out: T
1465
- ): T;
1466
-
1467
- public hermite<T extends Vector3Like>(
1468
- a: Vector3Like,
1469
- b: Vector3Like,
1470
- end: Vector3Like,
1471
- t: number,
1472
- out: T = new Vector3() as T
1473
- ): T {
1209
+ out = new Vector3() as unknown as T
1210
+ ) {
1474
1211
  return hermite(this, a, b, end, t, out);
1475
1212
  }
1476
1213
 
1477
1214
  /**
1478
- * Performs a Bézier interpolation with two control points between this
1479
- * vector and another.
1480
- * @param a The first control point.
1481
- * @param b The second control point.
1482
- * @param end The other vector.
1483
- * @param t The interpolation amount in the range `[0,1]`.
1215
+ * Perform a Bézier interpolation with two control points between this vector and another.
1216
+ * @param a - The first control point.
1217
+ * @param b - The second control point.
1218
+ * @param end - The other vector.
1219
+ * @param t - The interpolation amount in the range `[0,1]`.
1220
+ * @param out - The vector to store the result in.
1484
1221
  * @returns The interpolated vector.
1485
1222
  * @see [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
1486
1223
  */
1487
- public bezier(
1488
- a: Vector3Like,
1489
- b: Vector3Like,
1490
- end: Vector3Like,
1491
- t: number
1492
- ): Vector3;
1493
-
1494
- /**
1495
- * Performs a Bézier interpolation with two control points between this
1496
- * vector and another.
1497
- * @param a The first control point.
1498
- * @param b The second control point.
1499
- * @param end The other vector.
1500
- * @param t The interpolation amount in the range `[0,1]`.
1501
- * @param out The vector to store the result in.
1502
- * @returns The interpolated vector.
1503
- * @see [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve)
1504
- */
1505
- public bezier<T extends Vector3Like>(
1506
- a: Vector3Like,
1507
- b: Vector3Like,
1508
- end: Vector3Like,
1509
- t: number,
1510
- out: T
1511
- ): T;
1512
-
1513
1224
  public bezier<T extends Vector3Like>(
1514
1225
  a: Vector3Like,
1515
1226
  b: Vector3Like,
1516
1227
  end: Vector3Like,
1517
1228
  t: number,
1518
- out: T = new Vector3() as T
1519
- ): T {
1229
+ out = new Vector3() as unknown as T
1230
+ ) {
1520
1231
  return bezier(this, a, b, end, t, out);
1521
1232
  }
1522
1233
 
1523
1234
  /**
1524
- * Transforms this vector by a quaternion.
1525
- * @param quaternion The quaternion.
1526
- * @returns The transformed vector.
1527
- * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
1528
- */
1529
- public transformQuaternion(quaternion: QuaternionLike): Vector3;
1530
-
1531
- /**
1532
- * Transforms this vector by a quaternion.
1533
- * @param quaternion The quaternion.
1534
- * @param out The vector to store the result in.
1235
+ * Transform this vector by a quaternion.
1236
+ * @param quaternion - The quaternion.
1237
+ * @param out - The vector to store the result in.
1535
1238
  * @returns The transformed vector.
1536
1239
  * @see [Quaternion](https://en.wikipedia.org/wiki/Quaternion)
1537
1240
  */
1538
1241
  public transformQuaternion<T extends Vector3Like>(
1539
1242
  quaternion: QuaternionLike,
1540
- out: T
1541
- ): T;
1542
-
1543
- public transformQuaternion<T extends Vector3Like>(
1544
- quaternion: QuaternionLike,
1545
- out: T = new Vector3() as T
1546
- ): T {
1243
+ out = new Vector3() as unknown as T
1244
+ ) {
1547
1245
  return transformQuaternion(this, quaternion, out);
1548
1246
  }
1549
1247
 
1550
1248
  /**
1551
- * Creates a quaternion that represents the shortest rotation from this
1552
- * vector to another.
1553
- * @param vector The other vector.
1554
- * @returns The rotation.
1555
- */
1556
- public rotationTo(vector: Vector3Like): Quaternion;
1557
-
1558
- /**
1559
- * Creates a quaternion that represents the shortest rotation from this
1560
- * unit vector to another.
1561
- * @param vector The other vector.
1562
- * @param out The quaternion to store the result in.
1249
+ * Create a quaternion that represents the shortest rotation from this unit vector to another.
1250
+ * @param vector - The other vector.
1251
+ * @param out - The quaternion to store the result in.
1563
1252
  * @returns The quaternion.
1564
1253
  */
1565
- public rotationTo<T extends QuaternionLike>(vector: Vector3Like, out: T): T;
1566
-
1567
1254
  public rotationTo<T extends QuaternionLike>(
1568
1255
  vector: Vector3Like,
1569
- out: T = new Quaternion() as T
1570
- ): T {
1256
+ out = new Quaternion() as unknown as T
1257
+ ) {
1571
1258
  return rotationTo(this, vector, out);
1572
1259
  }
1573
1260
  }