@lakuna/umath 2.0.0 → 3.0.1
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.
- package/LICENSE +1 -1
- package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
- package/dist/algorithms/greatestCommonDivisor.js +14 -4
- package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/linalg/DualQuaternion.d.ts +158 -158
- package/dist/linalg/DualQuaternion.d.ts.map +1 -1
- package/dist/linalg/DualQuaternion.js +173 -165
- package/dist/linalg/DualQuaternion.js.map +1 -1
- package/dist/linalg/Matrix.d.ts +24 -24
- package/dist/linalg/Matrix.d.ts.map +1 -1
- package/dist/linalg/Matrix2.d.ts +85 -85
- package/dist/linalg/Matrix2.d.ts.map +1 -1
- package/dist/linalg/Matrix2.js +92 -88
- package/dist/linalg/Matrix2.js.map +1 -1
- package/dist/linalg/Matrix3.d.ts +134 -134
- package/dist/linalg/Matrix3.d.ts.map +1 -1
- package/dist/linalg/Matrix3.js +147 -138
- package/dist/linalg/Matrix3.js.map +1 -1
- package/dist/linalg/Matrix4.d.ts +245 -246
- package/dist/linalg/Matrix4.d.ts.map +1 -1
- package/dist/linalg/Matrix4.js +272 -251
- package/dist/linalg/Matrix4.js.map +1 -1
- package/dist/linalg/Quaternion.d.ts +147 -146
- package/dist/linalg/Quaternion.d.ts.map +1 -1
- package/dist/linalg/Quaternion.js +175 -161
- package/dist/linalg/Quaternion.js.map +1 -1
- package/dist/linalg/SlowMatrix.d.ts +12 -12
- package/dist/linalg/SlowMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowMatrix.js +12 -12
- package/dist/linalg/SlowMatrix.js.map +1 -1
- package/dist/linalg/SlowSquareMatrix.d.ts +7 -7
- package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowSquareMatrix.js +15 -15
- package/dist/linalg/SlowSquareMatrix.js.map +1 -1
- package/dist/linalg/SlowVector.d.ts +77 -77
- package/dist/linalg/SlowVector.d.ts.map +1 -1
- package/dist/linalg/SlowVector.js +153 -153
- package/dist/linalg/SlowVector.js.map +1 -1
- package/dist/linalg/SquareMatrix.d.ts +8 -8
- package/dist/linalg/SquareMatrix.d.ts.map +1 -1
- package/dist/linalg/Vector.d.ts +85 -84
- package/dist/linalg/Vector.d.ts.map +1 -1
- package/dist/linalg/Vector2.d.ts +143 -143
- package/dist/linalg/Vector2.d.ts.map +1 -1
- package/dist/linalg/Vector2.js +145 -143
- package/dist/linalg/Vector2.js.map +1 -1
- package/dist/linalg/Vector3.d.ts +173 -173
- package/dist/linalg/Vector3.d.ts.map +1 -1
- package/dist/linalg/Vector3.js +176 -173
- package/dist/linalg/Vector3.js.map +1 -1
- package/dist/linalg/Vector4.d.ts +137 -137
- package/dist/linalg/Vector4.d.ts.map +1 -1
- package/dist/linalg/Vector4.js +144 -140
- package/dist/linalg/Vector4.js.map +1 -1
- package/dist/types/AxisAngle.d.ts +11 -1
- package/dist/types/AxisAngle.d.ts.map +1 -1
- package/dist/types/FieldOfView.d.ts +2 -2
- package/dist/types/FieldOfView.d.ts.map +1 -1
- package/dist/utility/BigNumber.d.ts +21 -11
- package/dist/utility/BigNumber.d.ts.map +1 -1
- package/dist/utility/BigNumber.js +49 -31
- package/dist/utility/BigNumber.js.map +1 -1
- package/dist/utility/createAxisAngleLike.d.ts.map +1 -1
- package/dist/utility/createAxisAngleLike.js.map +1 -1
- package/package.json +13 -12
- package/src/algorithms/greatestCommonDivisor.ts +19 -7
- package/src/index.ts +21 -14
- package/src/linalg/DualQuaternion.ts +264 -238
- package/src/linalg/Matrix.ts +31 -28
- package/src/linalg/Matrix2.ts +157 -137
- package/src/linalg/Matrix3.ts +222 -191
- package/src/linalg/Matrix4.ts +464 -412
- package/src/linalg/Quaternion.ts +267 -234
- package/src/linalg/SlowMatrix.ts +31 -27
- package/src/linalg/SlowSquareMatrix.ts +19 -18
- package/src/linalg/SlowVector.ts +175 -174
- package/src/linalg/SquareMatrix.ts +9 -9
- package/src/linalg/Vector.ts +91 -89
- package/src/linalg/Vector2.ts +250 -217
- package/src/linalg/Vector3.ts +309 -269
- package/src/linalg/Vector4.ts +246 -206
- package/src/types/AxisAngle.ts +13 -1
- package/src/types/FieldOfView.ts +3 -3
- package/src/utility/BigNumber.ts +71 -38
- package/src/utility/createAxisAngleLike.ts +1 -0
package/src/linalg/Vector2.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { default as Vector, VectorLike } from "./Vector.js";
|
|
2
|
-
import Vector3, {
|
|
3
|
-
type Vector3Like,
|
|
4
|
-
fromValues as vector3FromValues
|
|
5
|
-
} from "./Vector3.js";
|
|
6
1
|
import type { Matrix2Like } from "./Matrix2.js";
|
|
7
2
|
import type { Matrix3Like } from "./Matrix3.js";
|
|
8
3
|
import type { Matrix4Like } from "./Matrix4.js";
|
|
4
|
+
import type { default as Vector, VectorLike } from "./Vector.js";
|
|
5
|
+
|
|
9
6
|
import approxRelative from "../algorithms/approxRelative.js";
|
|
7
|
+
import Vector3, {
|
|
8
|
+
fromValues as vector3FromValues,
|
|
9
|
+
type Vector3Like
|
|
10
|
+
} from "./Vector3.js";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* A quantity with magnitude and direction in two dimensions.
|
|
@@ -14,9 +15,11 @@ import approxRelative from "../algorithms/approxRelative.js";
|
|
|
14
15
|
*/
|
|
15
16
|
export interface Vector2Like extends VectorLike {
|
|
16
17
|
/** The first component of this vector. */
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
17
19
|
0: number;
|
|
18
20
|
|
|
19
21
|
/** The second component of this vector. */
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
20
23
|
1: number;
|
|
21
24
|
}
|
|
22
25
|
|
|
@@ -25,9 +28,9 @@ export interface Vector2Like extends VectorLike {
|
|
|
25
28
|
* @returns A 2x1 vector-like object.
|
|
26
29
|
* @public
|
|
27
30
|
*/
|
|
28
|
-
export const createVector2Like = (): Float32Array & Vector2Like =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
export const createVector2Like = (): Float32Array & Vector2Like =>
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
33
|
+
new Float32Array(2) as Float32Array & Vector2Like;
|
|
31
34
|
|
|
32
35
|
/**
|
|
33
36
|
* Create a vector with the given values.
|
|
@@ -54,8 +57,10 @@ export const fromValues = <T extends Vector2Like>(
|
|
|
54
57
|
* @returns Whether or not the vectors are equivalent.
|
|
55
58
|
* @public
|
|
56
59
|
*/
|
|
57
|
-
export const equals = (
|
|
58
|
-
|
|
60
|
+
export const equals = (
|
|
61
|
+
a: Readonly<Vector2Like>,
|
|
62
|
+
b: Readonly<Vector2Like>
|
|
63
|
+
): boolean => approxRelative(a[0], b[0]) && approxRelative(a[1], b[1]);
|
|
59
64
|
|
|
60
65
|
/**
|
|
61
66
|
* Determine whether or not two vectors are exactly equivalent.
|
|
@@ -64,8 +69,10 @@ export const equals = (a: Vector2Like, b: Vector2Like): boolean =>
|
|
|
64
69
|
* @returns Whether or not the vectors are equivalent.
|
|
65
70
|
* @public
|
|
66
71
|
*/
|
|
67
|
-
export const exactEquals = (
|
|
68
|
-
a
|
|
72
|
+
export const exactEquals = (
|
|
73
|
+
a: Readonly<Vector2Like>,
|
|
74
|
+
b: Readonly<Vector2Like>
|
|
75
|
+
): boolean => a[0] === b[0] && a[1] === b[1];
|
|
69
76
|
|
|
70
77
|
/**
|
|
71
78
|
* Add two vectors.
|
|
@@ -75,9 +82,9 @@ export const exactEquals = (a: Vector2Like, b: Vector2Like): boolean =>
|
|
|
75
82
|
* @returns The sum.
|
|
76
83
|
* @public
|
|
77
84
|
*/
|
|
78
|
-
export const add = <T extends Vector2Like
|
|
79
|
-
a: Vector2Like
|
|
80
|
-
b: Vector2Like
|
|
85
|
+
export const add = <T extends Readonly<Vector2Like>>(
|
|
86
|
+
a: Readonly<Vector2Like>,
|
|
87
|
+
b: Readonly<Vector2Like>,
|
|
81
88
|
out: T
|
|
82
89
|
): T => fromValues(a[0] + b[0], a[1] + b[1], out);
|
|
83
90
|
|
|
@@ -88,8 +95,10 @@ export const add = <T extends Vector2Like>(
|
|
|
88
95
|
* @returns The copy.
|
|
89
96
|
* @public
|
|
90
97
|
*/
|
|
91
|
-
export const copy = <T extends Vector2Like>(
|
|
92
|
-
|
|
98
|
+
export const copy = <T extends Vector2Like>(
|
|
99
|
+
vector: Readonly<Vector2Like>,
|
|
100
|
+
out: T
|
|
101
|
+
): T => fromValues(vector[0], vector[1], out);
|
|
93
102
|
|
|
94
103
|
/**
|
|
95
104
|
* Multiply the components in one vector by the corresponding components in another.
|
|
@@ -100,8 +109,8 @@ export const copy = <T extends Vector2Like>(vector: Vector2Like, out: T): T =>
|
|
|
100
109
|
* @public
|
|
101
110
|
*/
|
|
102
111
|
export const multiply = <T extends Vector2Like>(
|
|
103
|
-
a: Vector2Like
|
|
104
|
-
b: Vector2Like
|
|
112
|
+
a: Readonly<Vector2Like>,
|
|
113
|
+
b: Readonly<Vector2Like>,
|
|
105
114
|
out: T
|
|
106
115
|
): T => fromValues(a[0] * b[0], a[1] * b[1], out);
|
|
107
116
|
|
|
@@ -114,8 +123,8 @@ export const multiply = <T extends Vector2Like>(
|
|
|
114
123
|
* @public
|
|
115
124
|
*/
|
|
116
125
|
export const divide = <T extends Vector2Like>(
|
|
117
|
-
a: Vector2Like
|
|
118
|
-
b: Vector2Like
|
|
126
|
+
a: Readonly<Vector2Like>,
|
|
127
|
+
b: Readonly<Vector2Like>,
|
|
119
128
|
out: T
|
|
120
129
|
): T => fromValues(a[0] / b[0], a[1] / b[1], out);
|
|
121
130
|
|
|
@@ -128,8 +137,8 @@ export const divide = <T extends Vector2Like>(
|
|
|
128
137
|
* @public
|
|
129
138
|
*/
|
|
130
139
|
export const subtract = <T extends Vector2Like>(
|
|
131
|
-
a: Vector2Like
|
|
132
|
-
b: Vector2Like
|
|
140
|
+
a: Readonly<Vector2Like>,
|
|
141
|
+
b: Readonly<Vector2Like>,
|
|
133
142
|
out: T
|
|
134
143
|
): T => fromValues(a[0] - b[0], a[1] - b[1], out);
|
|
135
144
|
|
|
@@ -140,8 +149,10 @@ export const subtract = <T extends Vector2Like>(
|
|
|
140
149
|
* @returns The absolutized vector.
|
|
141
150
|
* @public
|
|
142
151
|
*/
|
|
143
|
-
export const abs = <T extends Vector2Like>(
|
|
144
|
-
|
|
152
|
+
export const abs = <T extends Vector2Like>(
|
|
153
|
+
vector: Readonly<Vector2Like>,
|
|
154
|
+
out: T
|
|
155
|
+
): T => fromValues(Math.abs(vector[0]), Math.abs(vector[1]), out);
|
|
145
156
|
|
|
146
157
|
/**
|
|
147
158
|
* Round up the components of a vector.
|
|
@@ -150,8 +161,10 @@ export const abs = <T extends Vector2Like>(vector: Vector2Like, out: T): T =>
|
|
|
150
161
|
* @returns The rounded vector.
|
|
151
162
|
* @public
|
|
152
163
|
*/
|
|
153
|
-
export const ceil = <T extends Vector2Like>(
|
|
154
|
-
|
|
164
|
+
export const ceil = <T extends Vector2Like>(
|
|
165
|
+
vector: Readonly<Vector2Like>,
|
|
166
|
+
out: T
|
|
167
|
+
): T => fromValues(Math.ceil(vector[0]), Math.ceil(vector[1]), out);
|
|
155
168
|
|
|
156
169
|
/**
|
|
157
170
|
* Round down the components of a vector.
|
|
@@ -160,8 +173,10 @@ export const ceil = <T extends Vector2Like>(vector: Vector2Like, out: T): T =>
|
|
|
160
173
|
* @returns The rounded vector.
|
|
161
174
|
* @public
|
|
162
175
|
*/
|
|
163
|
-
export const floor = <T extends Vector2Like>(
|
|
164
|
-
|
|
176
|
+
export const floor = <T extends Vector2Like>(
|
|
177
|
+
vector: Readonly<Vector2Like>,
|
|
178
|
+
out: T
|
|
179
|
+
): T => fromValues(Math.floor(vector[0]), Math.floor(vector[1]), out);
|
|
165
180
|
|
|
166
181
|
/**
|
|
167
182
|
* Round the components of a vector.
|
|
@@ -170,8 +185,10 @@ export const floor = <T extends Vector2Like>(vector: Vector2Like, out: T): T =>
|
|
|
170
185
|
* @returns The rounded vector.
|
|
171
186
|
* @public
|
|
172
187
|
*/
|
|
173
|
-
export const round = <T extends Vector2Like>(
|
|
174
|
-
|
|
188
|
+
export const round = <T extends Vector2Like>(
|
|
189
|
+
vector: Readonly<Vector2Like>,
|
|
190
|
+
out: T
|
|
191
|
+
): T => fromValues(Math.round(vector[0]), Math.round(vector[1]), out);
|
|
175
192
|
|
|
176
193
|
/**
|
|
177
194
|
* Return the minimum of two vectors.
|
|
@@ -182,8 +199,8 @@ export const round = <T extends Vector2Like>(vector: Vector2Like, out: T): T =>
|
|
|
182
199
|
* @public
|
|
183
200
|
*/
|
|
184
201
|
export const min = <T extends Vector2Like>(
|
|
185
|
-
a: Vector2Like
|
|
186
|
-
b: Vector2Like
|
|
202
|
+
a: Readonly<Vector2Like>,
|
|
203
|
+
b: Readonly<Vector2Like>,
|
|
187
204
|
out: T
|
|
188
205
|
): T => fromValues(Math.min(a[0], b[0]), Math.min(a[1], b[1]), out);
|
|
189
206
|
|
|
@@ -196,8 +213,8 @@ export const min = <T extends Vector2Like>(
|
|
|
196
213
|
* @public
|
|
197
214
|
*/
|
|
198
215
|
export const max = <T extends Vector2Like>(
|
|
199
|
-
a: Vector2Like
|
|
200
|
-
b: Vector2Like
|
|
216
|
+
a: Readonly<Vector2Like>,
|
|
217
|
+
b: Readonly<Vector2Like>,
|
|
201
218
|
out: T
|
|
202
219
|
): T => fromValues(Math.max(a[0], b[0]), Math.max(a[1], b[1]), out);
|
|
203
220
|
|
|
@@ -210,7 +227,7 @@ export const max = <T extends Vector2Like>(
|
|
|
210
227
|
* @public
|
|
211
228
|
*/
|
|
212
229
|
export const pow = <T extends Vector2Like>(
|
|
213
|
-
vector: Vector2Like
|
|
230
|
+
vector: Readonly<Vector2Like>,
|
|
214
231
|
scalar: number,
|
|
215
232
|
out: T
|
|
216
233
|
): T => fromValues(vector[0] ** scalar, vector[1] ** scalar, out);
|
|
@@ -224,7 +241,7 @@ export const pow = <T extends Vector2Like>(
|
|
|
224
241
|
* @public
|
|
225
242
|
*/
|
|
226
243
|
export const scale = <T extends Vector2Like>(
|
|
227
|
-
vector: Vector2Like
|
|
244
|
+
vector: Readonly<Vector2Like>,
|
|
228
245
|
scalar: number,
|
|
229
246
|
out: T
|
|
230
247
|
): T => fromValues(vector[0] * scalar, vector[1] * scalar, out);
|
|
@@ -239,8 +256,8 @@ export const scale = <T extends Vector2Like>(
|
|
|
239
256
|
* @public
|
|
240
257
|
*/
|
|
241
258
|
export const scaleAndAdd = <T extends Vector2Like>(
|
|
242
|
-
a: Vector2Like
|
|
243
|
-
b: Vector2Like
|
|
259
|
+
a: Readonly<Vector2Like>,
|
|
260
|
+
b: Readonly<Vector2Like>,
|
|
244
261
|
scalar: number,
|
|
245
262
|
out: T
|
|
246
263
|
): T => fromValues(a[0] + b[0] * scalar, a[1] + b[1] * scalar, out);
|
|
@@ -253,8 +270,10 @@ export const scaleAndAdd = <T extends Vector2Like>(
|
|
|
253
270
|
* @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
|
|
254
271
|
* @public
|
|
255
272
|
*/
|
|
256
|
-
export const distance = (
|
|
257
|
-
|
|
273
|
+
export const distance = (
|
|
274
|
+
a: Readonly<Vector2Like>,
|
|
275
|
+
b: Readonly<Vector2Like>
|
|
276
|
+
): number => Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
258
277
|
|
|
259
278
|
/**
|
|
260
279
|
* Calculate the squared Euclidean distance from one vector to another.
|
|
@@ -264,7 +283,10 @@ export const distance = (a: Vector2Like, b: Vector2Like): number =>
|
|
|
264
283
|
* @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
|
|
265
284
|
* @public
|
|
266
285
|
*/
|
|
267
|
-
export const squaredDistance = (
|
|
286
|
+
export const squaredDistance = (
|
|
287
|
+
a: Readonly<Vector2Like>,
|
|
288
|
+
b: Readonly<Vector2Like>
|
|
289
|
+
): number => {
|
|
268
290
|
const x = b[0] - a[0];
|
|
269
291
|
const y = b[1] - a[1];
|
|
270
292
|
return x * x + y * y;
|
|
@@ -276,7 +298,7 @@ export const squaredDistance = (a: Vector2Like, b: Vector2Like): number => {
|
|
|
276
298
|
* @returns The magnitude.
|
|
277
299
|
* @public
|
|
278
300
|
*/
|
|
279
|
-
export const getMagnitude = (vector: Vector2Like): number =>
|
|
301
|
+
export const getMagnitude = (vector: Readonly<Vector2Like>): number =>
|
|
280
302
|
Math.hypot(vector[0], vector[1]);
|
|
281
303
|
|
|
282
304
|
/**
|
|
@@ -285,7 +307,7 @@ export const getMagnitude = (vector: Vector2Like): number =>
|
|
|
285
307
|
* @returns The squared magnitude.
|
|
286
308
|
* @public
|
|
287
309
|
*/
|
|
288
|
-
export const getSquaredMagnitude = (vector: Vector2Like): number => {
|
|
310
|
+
export const getSquaredMagnitude = (vector: Readonly<Vector2Like>): number => {
|
|
289
311
|
const x = vector[0];
|
|
290
312
|
const y = vector[1];
|
|
291
313
|
return x * x + y * y;
|
|
@@ -298,8 +320,10 @@ export const getSquaredMagnitude = (vector: Vector2Like): number => {
|
|
|
298
320
|
* @returns The negated vector.
|
|
299
321
|
* @public
|
|
300
322
|
*/
|
|
301
|
-
export const negate = <T extends Vector2Like>(
|
|
302
|
-
|
|
323
|
+
export const negate = <T extends Vector2Like>(
|
|
324
|
+
vector: Readonly<Vector2Like>,
|
|
325
|
+
out: T
|
|
326
|
+
): T => fromValues(-vector[0], -vector[1], out);
|
|
303
327
|
|
|
304
328
|
/**
|
|
305
329
|
* Calculate the multiplicative inverse of the components of a vector.
|
|
@@ -308,8 +332,10 @@ export const negate = <T extends Vector2Like>(vector: Vector2Like, out: T): T =>
|
|
|
308
332
|
* @returns The inverted vector.
|
|
309
333
|
* @public
|
|
310
334
|
*/
|
|
311
|
-
export const invert = <T extends Vector2Like>(
|
|
312
|
-
|
|
335
|
+
export const invert = <T extends Vector2Like>(
|
|
336
|
+
vector: Readonly<Vector2Like>,
|
|
337
|
+
out: T
|
|
338
|
+
): T => fromValues(1 / vector[0], 1 / vector[1], out);
|
|
313
339
|
|
|
314
340
|
/**
|
|
315
341
|
* Normalize a vector.
|
|
@@ -320,7 +346,7 @@ export const invert = <T extends Vector2Like>(vector: Vector2Like, out: T): T =>
|
|
|
320
346
|
* @public
|
|
321
347
|
*/
|
|
322
348
|
export const normalize = <T extends Vector2Like>(
|
|
323
|
-
vector: Vector2Like
|
|
349
|
+
vector: Readonly<Vector2Like>,
|
|
324
350
|
out: T
|
|
325
351
|
): T => {
|
|
326
352
|
const x = vector[0];
|
|
@@ -342,8 +368,10 @@ export const normalize = <T extends Vector2Like>(
|
|
|
342
368
|
* @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
|
|
343
369
|
* @public
|
|
344
370
|
*/
|
|
345
|
-
export const dot = (
|
|
346
|
-
a
|
|
371
|
+
export const dot = (
|
|
372
|
+
a: Readonly<Vector2Like>,
|
|
373
|
+
b: Readonly<Vector2Like>
|
|
374
|
+
): number => a[0] * b[0] + a[1] * b[1];
|
|
347
375
|
|
|
348
376
|
/**
|
|
349
377
|
* Calculate the cross product of two vectors.
|
|
@@ -355,8 +383,8 @@ export const dot = (a: Vector2Like, b: Vector2Like): number =>
|
|
|
355
383
|
* @public
|
|
356
384
|
*/
|
|
357
385
|
export const cross = <T extends Vector3Like>(
|
|
358
|
-
a: Vector2Like
|
|
359
|
-
b: Vector2Like
|
|
386
|
+
a: Readonly<Vector2Like>,
|
|
387
|
+
b: Readonly<Vector2Like>,
|
|
360
388
|
out: T
|
|
361
389
|
): T => vector3FromValues(0, 0, a[0] * b[1] - a[1] * b[0], out);
|
|
362
390
|
|
|
@@ -371,8 +399,8 @@ export const cross = <T extends Vector3Like>(
|
|
|
371
399
|
* @public
|
|
372
400
|
*/
|
|
373
401
|
export const lerp = <T extends Vector2Like>(
|
|
374
|
-
a: Vector2Like
|
|
375
|
-
b: Vector2Like
|
|
402
|
+
a: Readonly<Vector2Like>,
|
|
403
|
+
b: Readonly<Vector2Like>,
|
|
376
404
|
t: number,
|
|
377
405
|
out: T
|
|
378
406
|
): T => {
|
|
@@ -405,8 +433,8 @@ export const random = <T extends Vector2Like>(magnitude: number, out: T): T => {
|
|
|
405
433
|
* @public
|
|
406
434
|
*/
|
|
407
435
|
export const transformMatrix2 = <T extends Vector2Like>(
|
|
408
|
-
vector: Vector2Like
|
|
409
|
-
matrix: Matrix2Like
|
|
436
|
+
vector: Readonly<Vector2Like>,
|
|
437
|
+
matrix: Readonly<Matrix2Like>,
|
|
410
438
|
out: T
|
|
411
439
|
): T => {
|
|
412
440
|
const x = vector[0];
|
|
@@ -429,8 +457,8 @@ export const transformMatrix2 = <T extends Vector2Like>(
|
|
|
429
457
|
* @public
|
|
430
458
|
*/
|
|
431
459
|
export const transformMatrix3 = <T extends Vector2Like>(
|
|
432
|
-
vector: Vector2Like
|
|
433
|
-
matrix: Matrix3Like
|
|
460
|
+
vector: Readonly<Vector2Like>,
|
|
461
|
+
matrix: Readonly<Matrix3Like>,
|
|
434
462
|
out: T
|
|
435
463
|
): T => {
|
|
436
464
|
const x = vector[0];
|
|
@@ -453,8 +481,8 @@ export const transformMatrix3 = <T extends Vector2Like>(
|
|
|
453
481
|
* @public
|
|
454
482
|
*/
|
|
455
483
|
export const transformMatrix4 = <T extends Vector2Like>(
|
|
456
|
-
vector: Vector2Like
|
|
457
|
-
matrix: Matrix4Like
|
|
484
|
+
vector: Readonly<Vector2Like>,
|
|
485
|
+
matrix: Readonly<Matrix4Like>,
|
|
458
486
|
out: T
|
|
459
487
|
): T => {
|
|
460
488
|
const x = vector[0];
|
|
@@ -477,8 +505,8 @@ export const transformMatrix4 = <T extends Vector2Like>(
|
|
|
477
505
|
* @public
|
|
478
506
|
*/
|
|
479
507
|
export const rotate = <T extends Vector2Like>(
|
|
480
|
-
vector: Vector2Like
|
|
481
|
-
origin: Vector2Like
|
|
508
|
+
vector: Readonly<Vector2Like>,
|
|
509
|
+
origin: Readonly<Vector2Like>,
|
|
482
510
|
r: number,
|
|
483
511
|
out: T
|
|
484
512
|
): T => {
|
|
@@ -501,7 +529,10 @@ export const rotate = <T extends Vector2Like>(
|
|
|
501
529
|
* @returns The angular distance.
|
|
502
530
|
* @public
|
|
503
531
|
*/
|
|
504
|
-
export const angle = (
|
|
532
|
+
export const angle = (
|
|
533
|
+
a: Readonly<Vector2Like>,
|
|
534
|
+
b: Readonly<Vector2Like>
|
|
535
|
+
): number => {
|
|
505
536
|
const x1 = a[0];
|
|
506
537
|
const y1 = a[1];
|
|
507
538
|
|
|
@@ -529,6 +560,40 @@ export default class Vector2
|
|
|
529
560
|
extends Float32Array
|
|
530
561
|
implements Vector, Vector2Like
|
|
531
562
|
{
|
|
563
|
+
/** The first component of this vector. */
|
|
564
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
565
|
+
public 0: number;
|
|
566
|
+
|
|
567
|
+
/** The second component of this vector. */
|
|
568
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
569
|
+
public 1: number;
|
|
570
|
+
|
|
571
|
+
/** The magnitude (length) of this vector. */
|
|
572
|
+
public get magnitude(): number {
|
|
573
|
+
return getMagnitude(this);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
public set magnitude(value: number) {
|
|
577
|
+
scale(normalize(this, this), value, this);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/** The squared magnitude (length) of this vector. */
|
|
581
|
+
public get squaredMagnitude(): number {
|
|
582
|
+
return getSquaredMagnitude(this);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
public set squaredMagnitude(value: number) {
|
|
586
|
+
this.magnitude = Math.sqrt(value);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Create a two-dimensional zero vector.
|
|
591
|
+
* @see {@link https://en.wikipedia.org/wiki/Euclidean_vector | Euclidean vector}
|
|
592
|
+
*/
|
|
593
|
+
public constructor() {
|
|
594
|
+
super(2);
|
|
595
|
+
}
|
|
596
|
+
|
|
532
597
|
/**
|
|
533
598
|
* Create a vector with the given values.
|
|
534
599
|
* @param x - The first component.
|
|
@@ -540,44 +605,37 @@ export default class Vector2
|
|
|
540
605
|
}
|
|
541
606
|
|
|
542
607
|
/**
|
|
543
|
-
*
|
|
544
|
-
* @
|
|
608
|
+
* Absolutize the components of this vector.
|
|
609
|
+
* @returns The absolutized vector.
|
|
545
610
|
*/
|
|
546
|
-
public
|
|
547
|
-
|
|
611
|
+
public abs(): Vector2 {
|
|
612
|
+
return abs(this, new Vector2());
|
|
548
613
|
}
|
|
549
614
|
|
|
550
|
-
/** The first component of this vector. */
|
|
551
|
-
public 0: number;
|
|
552
|
-
|
|
553
|
-
/** The second component of this vector. */
|
|
554
|
-
public 1: number;
|
|
555
|
-
|
|
556
615
|
/**
|
|
557
|
-
*
|
|
616
|
+
* Add another vector to this one.
|
|
558
617
|
* @param vector - The other vector.
|
|
559
|
-
* @returns
|
|
618
|
+
* @returns The sum of the vectors.
|
|
560
619
|
*/
|
|
561
|
-
public
|
|
562
|
-
return
|
|
620
|
+
public add(vector: Readonly<Vector2Like>): Vector2 {
|
|
621
|
+
return add(this, vector, new Vector2());
|
|
563
622
|
}
|
|
564
623
|
|
|
565
624
|
/**
|
|
566
|
-
*
|
|
625
|
+
* Get the angle from this to another vector in radians.
|
|
567
626
|
* @param vector - The other vector.
|
|
568
|
-
* @returns
|
|
627
|
+
* @returns The angular distance.
|
|
569
628
|
*/
|
|
570
|
-
public
|
|
571
|
-
return
|
|
629
|
+
public angle(vector: Readonly<Vector2Like>): number {
|
|
630
|
+
return angle(this, vector);
|
|
572
631
|
}
|
|
573
632
|
|
|
574
633
|
/**
|
|
575
|
-
*
|
|
576
|
-
* @
|
|
577
|
-
* @returns The sum of the vectors.
|
|
634
|
+
* Round up the components of this vector.
|
|
635
|
+
* @returns The rounded vector.
|
|
578
636
|
*/
|
|
579
|
-
public
|
|
580
|
-
return
|
|
637
|
+
public ceil(): Vector2 {
|
|
638
|
+
return ceil(this, new Vector2());
|
|
581
639
|
}
|
|
582
640
|
|
|
583
641
|
/**
|
|
@@ -593,17 +651,28 @@ export default class Vector2
|
|
|
593
651
|
* @param vector - The vector to copy.
|
|
594
652
|
* @returns This vector.
|
|
595
653
|
*/
|
|
596
|
-
public copy(vector: Vector2Like): this {
|
|
654
|
+
public copy(vector: Readonly<Vector2Like>): this {
|
|
597
655
|
return copy(vector, this);
|
|
598
656
|
}
|
|
599
657
|
|
|
600
658
|
/**
|
|
601
|
-
*
|
|
659
|
+
* Calculate the cross product of this and another vector.
|
|
602
660
|
* @param vector - The other vector.
|
|
603
|
-
* @returns The product
|
|
661
|
+
* @returns The cross product.
|
|
662
|
+
* @see {@link https://en.wikipedia.org/wiki/Cross_product | Cross product}
|
|
604
663
|
*/
|
|
605
|
-
public
|
|
606
|
-
return
|
|
664
|
+
public cross(vector: Readonly<Vector2Like>): Vector3 {
|
|
665
|
+
return cross(this, vector, new Vector3());
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Calculate the Euclidean distance from this vector to another.
|
|
670
|
+
* @param vector - The other vector.
|
|
671
|
+
* @returns The distance.
|
|
672
|
+
* @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
|
|
673
|
+
*/
|
|
674
|
+
public distance(vector: Readonly<Vector2Like>): number {
|
|
675
|
+
return distance(this, vector);
|
|
607
676
|
}
|
|
608
677
|
|
|
609
678
|
/**
|
|
@@ -611,33 +680,36 @@ export default class Vector2
|
|
|
611
680
|
* @param vector - The other vector.
|
|
612
681
|
* @returns The quotient of the vectors.
|
|
613
682
|
*/
|
|
614
|
-
public divide(vector: Vector2Like): Vector2 {
|
|
683
|
+
public divide(vector: Readonly<Vector2Like>): Vector2 {
|
|
615
684
|
return divide(this, vector, new Vector2());
|
|
616
685
|
}
|
|
617
686
|
|
|
618
687
|
/**
|
|
619
|
-
*
|
|
688
|
+
* Calculate the dot product of this and another vector.
|
|
620
689
|
* @param vector - The other vector.
|
|
621
|
-
* @returns The
|
|
690
|
+
* @returns The dot product.
|
|
691
|
+
* @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
|
|
622
692
|
*/
|
|
623
|
-
public
|
|
624
|
-
return
|
|
693
|
+
public dot(vector: Readonly<Vector2Like>): number {
|
|
694
|
+
return dot(this, vector);
|
|
625
695
|
}
|
|
626
696
|
|
|
627
697
|
/**
|
|
628
|
-
*
|
|
629
|
-
* @
|
|
698
|
+
* Determine whether this vector is roughly equivalent to another.
|
|
699
|
+
* @param vector - The other vector.
|
|
700
|
+
* @returns Whether the vectors are equivalent.
|
|
630
701
|
*/
|
|
631
|
-
public
|
|
632
|
-
return
|
|
702
|
+
public equals(vector: Readonly<Vector2Like>): boolean {
|
|
703
|
+
return equals(this, vector);
|
|
633
704
|
}
|
|
634
705
|
|
|
635
706
|
/**
|
|
636
|
-
*
|
|
637
|
-
* @
|
|
707
|
+
* Determine whether or not this vector is exactly equivalent to another.
|
|
708
|
+
* @param vector - The other vector.
|
|
709
|
+
* @returns Whether or not the vectors are equivalent.
|
|
638
710
|
*/
|
|
639
|
-
public
|
|
640
|
-
return
|
|
711
|
+
public exactEquals(vector: Readonly<Vector2Like>): boolean {
|
|
712
|
+
return exactEquals(this, vector);
|
|
641
713
|
}
|
|
642
714
|
|
|
643
715
|
/**
|
|
@@ -649,20 +721,22 @@ export default class Vector2
|
|
|
649
721
|
}
|
|
650
722
|
|
|
651
723
|
/**
|
|
652
|
-
*
|
|
653
|
-
* @returns The
|
|
724
|
+
* Calculate the multiplicative inverse of the components of this vector.
|
|
725
|
+
* @returns The inverted vector.
|
|
654
726
|
*/
|
|
655
|
-
public
|
|
656
|
-
return
|
|
727
|
+
public invert(): Vector2 {
|
|
728
|
+
return invert(this, new Vector2());
|
|
657
729
|
}
|
|
658
730
|
|
|
659
731
|
/**
|
|
660
|
-
*
|
|
732
|
+
* Perform a linear interpolation between this and another vector.
|
|
661
733
|
* @param vector - The other vector.
|
|
662
|
-
* @
|
|
734
|
+
* @param t - The interpolation amount (in `[0,1]`).
|
|
735
|
+
* @returns The interpolated vector.
|
|
736
|
+
* @see {@link https://en.wikipedia.org/wiki/Linear_interpolation | Linear interpolation}
|
|
663
737
|
*/
|
|
664
|
-
public
|
|
665
|
-
return
|
|
738
|
+
public lerp(vector: Readonly<Vector2Like>, t: number): Vector2 {
|
|
739
|
+
return lerp(this, vector, t, new Vector2());
|
|
666
740
|
}
|
|
667
741
|
|
|
668
742
|
/**
|
|
@@ -670,139 +744,117 @@ export default class Vector2
|
|
|
670
744
|
* @param vector - The other vector.
|
|
671
745
|
* @returns The maximum.
|
|
672
746
|
*/
|
|
673
|
-
public max(vector: Vector2Like): Vector2 {
|
|
747
|
+
public max(vector: Readonly<Vector2Like>): Vector2 {
|
|
674
748
|
return max(this, vector, new Vector2());
|
|
675
749
|
}
|
|
676
750
|
|
|
677
751
|
/**
|
|
678
|
-
*
|
|
679
|
-
* @param
|
|
680
|
-
* @returns The
|
|
752
|
+
* Return the minimum of this and another vector.
|
|
753
|
+
* @param vector - The other vector.
|
|
754
|
+
* @returns The minimum.
|
|
681
755
|
*/
|
|
682
|
-
public
|
|
683
|
-
return
|
|
756
|
+
public min(vector: Readonly<Vector2Like>): Vector2 {
|
|
757
|
+
return min(this, vector, new Vector2());
|
|
684
758
|
}
|
|
685
759
|
|
|
686
760
|
/**
|
|
687
|
-
*
|
|
688
|
-
* @param
|
|
689
|
-
* @returns The
|
|
761
|
+
* Multiply the components in this vector by the corresponding components in another.
|
|
762
|
+
* @param vector - The other vector.
|
|
763
|
+
* @returns The product of the vectors.
|
|
690
764
|
*/
|
|
691
|
-
public
|
|
692
|
-
return
|
|
765
|
+
public multiply(vector: Readonly<Vector2Like>): Vector2 {
|
|
766
|
+
return multiply(this, vector, new Vector2());
|
|
693
767
|
}
|
|
694
768
|
|
|
695
769
|
/**
|
|
696
|
-
*
|
|
697
|
-
* @
|
|
698
|
-
* @param scalar - The scalar.
|
|
699
|
-
* @returns The sum.
|
|
770
|
+
* Negate this vector.
|
|
771
|
+
* @returns The negated vector.
|
|
700
772
|
*/
|
|
701
|
-
public
|
|
702
|
-
return
|
|
773
|
+
public negate(): Vector2 {
|
|
774
|
+
return negate(this, new Vector2());
|
|
703
775
|
}
|
|
704
776
|
|
|
705
777
|
/**
|
|
706
|
-
*
|
|
707
|
-
* @
|
|
708
|
-
* @
|
|
709
|
-
* @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
|
|
778
|
+
* Normalize this vector.
|
|
779
|
+
* @returns The normalized vector.
|
|
780
|
+
* @see {@link https://en.wikipedia.org/wiki/Unit_vector | Unit vector}
|
|
710
781
|
*/
|
|
711
|
-
public
|
|
712
|
-
return
|
|
782
|
+
public normalize(): Vector2 {
|
|
783
|
+
return normalize(this, new Vector2());
|
|
713
784
|
}
|
|
714
785
|
|
|
715
786
|
/**
|
|
716
|
-
*
|
|
717
|
-
* @param
|
|
718
|
-
* @returns The
|
|
719
|
-
* @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
|
|
787
|
+
* Raise each component of this vector to the given power.
|
|
788
|
+
* @param scalar - The exponent (power) to raise each component to.
|
|
789
|
+
* @returns The power (result of the exponentiation).
|
|
720
790
|
*/
|
|
721
|
-
public
|
|
722
|
-
return
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
/** The magnitude (length) of this vector. */
|
|
726
|
-
public get magnitude(): number {
|
|
727
|
-
return getMagnitude(this);
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
public set magnitude(value: number) {
|
|
731
|
-
scale(normalize(this, this), value, this);
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
/** The squared magnitude (length) of this vector. */
|
|
735
|
-
public get squaredMagnitude(): number {
|
|
736
|
-
return getSquaredMagnitude(this);
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
public set squaredMagnitude(value: number) {
|
|
740
|
-
this.magnitude = Math.sqrt(value);
|
|
791
|
+
public pow(scalar: number): Vector2 {
|
|
792
|
+
return pow(this, scalar, new Vector2());
|
|
741
793
|
}
|
|
742
794
|
|
|
743
795
|
/**
|
|
744
|
-
*
|
|
745
|
-
* @
|
|
796
|
+
* Set this vector to a random value with the given magnitude.
|
|
797
|
+
* @param magnitude - The magnitude.
|
|
798
|
+
* @returns This vector.
|
|
746
799
|
*/
|
|
747
|
-
public
|
|
748
|
-
return
|
|
800
|
+
public random(magnitude = 1): this {
|
|
801
|
+
return random(magnitude, this);
|
|
749
802
|
}
|
|
750
803
|
|
|
751
804
|
/**
|
|
752
|
-
*
|
|
753
|
-
* @
|
|
805
|
+
* Rotate this vector.
|
|
806
|
+
* @param origin - The origin of the rotation.
|
|
807
|
+
* @param radians - The angle of rotation in radians.
|
|
808
|
+
* @returns The rotated vector.
|
|
754
809
|
*/
|
|
755
|
-
public
|
|
756
|
-
return
|
|
810
|
+
public rotate(origin: Readonly<Vector2Like>, radians: number): Vector2 {
|
|
811
|
+
return rotate(this, origin, radians, new Vector2());
|
|
757
812
|
}
|
|
758
813
|
|
|
759
814
|
/**
|
|
760
|
-
*
|
|
761
|
-
* @returns The
|
|
762
|
-
* @see {@link https://en.wikipedia.org/wiki/Unit_vector | Unit vector}
|
|
815
|
+
* Round the components of this vector.
|
|
816
|
+
* @returns The rounded vector.
|
|
763
817
|
*/
|
|
764
|
-
public
|
|
765
|
-
return
|
|
818
|
+
public round(): Vector2 {
|
|
819
|
+
return round(this, new Vector2());
|
|
766
820
|
}
|
|
767
821
|
|
|
768
822
|
/**
|
|
769
|
-
*
|
|
770
|
-
* @param
|
|
771
|
-
* @returns The
|
|
772
|
-
* @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
|
|
823
|
+
* Scale this vector by a scalar.
|
|
824
|
+
* @param scalar - The scalar.
|
|
825
|
+
* @returns The scaled vector.
|
|
773
826
|
*/
|
|
774
|
-
public
|
|
775
|
-
return
|
|
827
|
+
public scale(scalar: number): Vector2 {
|
|
828
|
+
return scale(this, scalar, new Vector2());
|
|
776
829
|
}
|
|
777
830
|
|
|
778
831
|
/**
|
|
779
|
-
*
|
|
832
|
+
* Add another vector to this one after scaling the other by a scalar.
|
|
780
833
|
* @param vector - The other vector.
|
|
781
|
-
* @
|
|
782
|
-
* @
|
|
834
|
+
* @param scalar - The scalar.
|
|
835
|
+
* @returns The sum.
|
|
783
836
|
*/
|
|
784
|
-
public
|
|
785
|
-
return
|
|
837
|
+
public scaleAndAdd(vector: Readonly<Vector2Like>, scalar: number): Vector2 {
|
|
838
|
+
return scaleAndAdd(this, vector, scalar, new Vector2());
|
|
786
839
|
}
|
|
787
840
|
|
|
788
841
|
/**
|
|
789
|
-
*
|
|
842
|
+
* Calculate the squared Euclidean distance from this vector to another.
|
|
790
843
|
* @param vector - The other vector.
|
|
791
|
-
* @
|
|
792
|
-
* @
|
|
793
|
-
* @see {@link https://en.wikipedia.org/wiki/Linear_interpolation | Linear interpolation}
|
|
844
|
+
* @returns The squared distance.
|
|
845
|
+
* @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
|
|
794
846
|
*/
|
|
795
|
-
public
|
|
796
|
-
return
|
|
847
|
+
public squaredDistance(vector: Readonly<Vector2Like>): number {
|
|
848
|
+
return squaredDistance(this, vector);
|
|
797
849
|
}
|
|
798
850
|
|
|
799
851
|
/**
|
|
800
|
-
*
|
|
801
|
-
* @param
|
|
802
|
-
* @returns
|
|
852
|
+
* Subtract another vector from this one.
|
|
853
|
+
* @param vector - The other vector.
|
|
854
|
+
* @returns The difference between the vectors.
|
|
803
855
|
*/
|
|
804
|
-
public
|
|
805
|
-
return
|
|
856
|
+
public subtract(vector: Readonly<Vector2Like>): Vector2 {
|
|
857
|
+
return subtract(this, vector, new Vector2());
|
|
806
858
|
}
|
|
807
859
|
|
|
808
860
|
/**
|
|
@@ -811,7 +863,7 @@ export default class Vector2
|
|
|
811
863
|
* @returns The transformed vector.
|
|
812
864
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
813
865
|
*/
|
|
814
|
-
public transformMatrix2(matrix: Matrix2Like): Vector2 {
|
|
866
|
+
public transformMatrix2(matrix: Readonly<Matrix2Like>): Vector2 {
|
|
815
867
|
return transformMatrix2(this, matrix, new Vector2());
|
|
816
868
|
}
|
|
817
869
|
|
|
@@ -821,7 +873,7 @@ export default class Vector2
|
|
|
821
873
|
* @returns The transformed vector.
|
|
822
874
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
823
875
|
*/
|
|
824
|
-
public transformMatrix3(matrix: Matrix3Like): Vector2 {
|
|
876
|
+
public transformMatrix3(matrix: Readonly<Matrix3Like>): Vector2 {
|
|
825
877
|
return transformMatrix3(this, matrix, new Vector2());
|
|
826
878
|
}
|
|
827
879
|
|
|
@@ -831,29 +883,10 @@ export default class Vector2
|
|
|
831
883
|
* @returns The transformed vector.
|
|
832
884
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
833
885
|
*/
|
|
834
|
-
public transformMatrix4(matrix: Matrix4Like): Vector2 {
|
|
886
|
+
public transformMatrix4(matrix: Readonly<Matrix4Like>): Vector2 {
|
|
835
887
|
return transformMatrix4(this, matrix, new Vector2());
|
|
836
888
|
}
|
|
837
889
|
|
|
838
|
-
/**
|
|
839
|
-
* Rotate this vector.
|
|
840
|
-
* @param origin - The origin of the rotation.
|
|
841
|
-
* @param radians - The angle of rotation in radians.
|
|
842
|
-
* @returns The rotated vector.
|
|
843
|
-
*/
|
|
844
|
-
public rotate(origin: Vector2Like, radians: number): Vector2 {
|
|
845
|
-
return rotate(this, origin, radians, new Vector2());
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
/**
|
|
849
|
-
* Get the angle from this to another vector in radians.
|
|
850
|
-
* @param vector - The other vector.
|
|
851
|
-
* @returns The angular distance.
|
|
852
|
-
*/
|
|
853
|
-
public angle(vector: Vector2Like): number {
|
|
854
|
-
return angle(this, vector);
|
|
855
|
-
}
|
|
856
|
-
|
|
857
890
|
/**
|
|
858
891
|
* Set this to the zero vector.
|
|
859
892
|
* @returns This vector.
|