@lakuna/umath 1.4.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/linalg/DualQuaternion.d.ts +23 -46
- package/dist/linalg/DualQuaternion.d.ts.map +1 -1
- package/dist/linalg/DualQuaternion.js +47 -70
- package/dist/linalg/DualQuaternion.js.map +1 -1
- package/dist/linalg/Matrix2.d.ts +16 -30
- package/dist/linalg/Matrix2.d.ts.map +1 -1
- package/dist/linalg/Matrix2.js +30 -44
- package/dist/linalg/Matrix2.js.map +1 -1
- package/dist/linalg/Matrix3.d.ts +21 -42
- package/dist/linalg/Matrix3.d.ts.map +1 -1
- package/dist/linalg/Matrix3.js +43 -84
- package/dist/linalg/Matrix3.js.map +1 -1
- package/dist/linalg/Matrix4.d.ts +40 -79
- package/dist/linalg/Matrix4.d.ts.map +1 -1
- package/dist/linalg/Matrix4.js +86 -171
- package/dist/linalg/Matrix4.js.map +1 -1
- package/dist/linalg/Quaternion.d.ts +29 -60
- package/dist/linalg/Quaternion.d.ts.map +1 -1
- package/dist/linalg/Quaternion.js +54 -85
- package/dist/linalg/Quaternion.js.map +1 -1
- package/dist/linalg/SlowMatrix.d.ts.map +1 -1
- package/dist/linalg/SlowMatrix.js +52 -78
- package/dist/linalg/SlowMatrix.js.map +1 -1
- package/dist/linalg/SlowSquareMatrix.js +1 -1
- package/dist/linalg/SlowSquareMatrix.js.map +1 -1
- package/dist/linalg/SlowVector.d.ts +165 -0
- package/dist/linalg/SlowVector.d.ts.map +1 -0
- package/dist/linalg/SlowVector.js +369 -0
- package/dist/linalg/SlowVector.js.map +1 -0
- package/dist/linalg/Vector.d.ts +20 -15
- package/dist/linalg/Vector.d.ts.map +1 -1
- package/dist/linalg/Vector2.d.ts +42 -48
- package/dist/linalg/Vector2.d.ts.map +1 -1
- package/dist/linalg/Vector2.js +74 -82
- package/dist/linalg/Vector2.js.map +1 -1
- package/dist/linalg/Vector3.d.ts +46 -56
- package/dist/linalg/Vector3.d.ts.map +1 -1
- package/dist/linalg/Vector3.js +82 -104
- package/dist/linalg/Vector3.js.map +1 -1
- package/dist/linalg/Vector4.d.ts +40 -44
- package/dist/linalg/Vector4.d.ts.map +1 -1
- package/dist/linalg/Vector4.js +69 -79
- package/dist/linalg/Vector4.js.map +1 -1
- package/dist/utility/MatrixSizeError.d.ts +1 -1
- package/dist/utility/MatrixSizeError.d.ts.map +1 -1
- package/dist/utility/MatrixSizeError.js +1 -1
- package/dist/utility/MatrixSizeError.js.map +1 -1
- package/dist/utility/VectorSizeError.d.ts +12 -0
- package/dist/utility/VectorSizeError.d.ts.map +1 -0
- package/dist/utility/VectorSizeError.js +15 -0
- package/dist/utility/VectorSizeError.js.map +1 -0
- package/dist/utility/createAxisAngleLike.d.ts +10 -0
- package/dist/utility/createAxisAngleLike.d.ts.map +1 -0
- package/dist/utility/createAxisAngleLike.js +10 -0
- package/dist/utility/createAxisAngleLike.js.map +1 -0
- package/package.json +8 -10
- package/src/index.ts +16 -0
- package/src/linalg/DualQuaternion.ts +51 -134
- package/src/linalg/Matrix2.ts +32 -83
- package/src/linalg/Matrix3.ts +55 -149
- package/src/linalg/Matrix4.ts +136 -292
- package/src/linalg/Quaternion.ts +62 -153
- package/src/linalg/SlowMatrix.ts +82 -81
- package/src/linalg/SlowSquareMatrix.ts +1 -1
- package/src/linalg/SlowVector.ts +449 -0
- package/src/linalg/Vector.ts +21 -16
- package/src/linalg/Vector2.ts +84 -147
- package/src/linalg/Vector3.ts +102 -188
- package/src/linalg/Vector4.ts +88 -137
- package/src/utility/MatrixSizeError.ts +1 -1
- package/src/utility/VectorSizeError.ts +14 -0
- package/src/utility/createAxisAngleLike.ts +13 -0
package/dist/linalg/Vector4.d.ts
CHANGED
|
@@ -142,6 +142,15 @@ export declare const min: <T extends Vector4Like>(a: Vector4Like, b: Vector4Like
|
|
|
142
142
|
* @public
|
|
143
143
|
*/
|
|
144
144
|
export declare const max: <T extends Vector4Like>(a: Vector4Like, b: Vector4Like, out: T) => T;
|
|
145
|
+
/**
|
|
146
|
+
* Raise each component of a vector to the given power.
|
|
147
|
+
* @param vector - The base.
|
|
148
|
+
* @param scalar - The exponent (power) to raise each component to.
|
|
149
|
+
* @param out - The vector to store the result in.
|
|
150
|
+
* @returns The power (result of the exponentiation).
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
export declare const pow: <T extends Vector4Like>(vector: Vector4Like, scalar: number, out: T) => T;
|
|
145
154
|
/**
|
|
146
155
|
* Scale a vector by a scalar.
|
|
147
156
|
* @param vector - The multiplier.
|
|
@@ -298,10 +307,9 @@ export default class Vector4 extends Float32Array implements Vector, Vector4Like
|
|
|
298
307
|
* @param y - The second component.
|
|
299
308
|
* @param z - The third component.
|
|
300
309
|
* @param w - The fourth component.
|
|
301
|
-
* @param out - The vector to store the result in.
|
|
302
310
|
* @returns A new vector.
|
|
303
311
|
*/
|
|
304
|
-
static fromValues
|
|
312
|
+
static fromValues(x: number, y: number, z: number, w: number): Vector4;
|
|
305
313
|
/**
|
|
306
314
|
* Create a four-dimensional zero vector.
|
|
307
315
|
* @see {@link https://en.wikipedia.org/wiki/Euclidean_vector | Euclidean vector}
|
|
@@ -330,16 +338,14 @@ export default class Vector4 extends Float32Array implements Vector, Vector4Like
|
|
|
330
338
|
/**
|
|
331
339
|
* Add two vectors of the same size.
|
|
332
340
|
* @param vector - The other vector.
|
|
333
|
-
* @param out - The vector to store the result in.
|
|
334
341
|
* @returns The sum of the vectors.
|
|
335
342
|
*/
|
|
336
|
-
add
|
|
343
|
+
add(vector: Vector4Like): Vector4;
|
|
337
344
|
/**
|
|
338
345
|
* Copy the values from this vector to another one.
|
|
339
|
-
* @param out - The vector to store the result in.
|
|
340
346
|
* @returns The copy.
|
|
341
347
|
*/
|
|
342
|
-
clone
|
|
348
|
+
clone(): Vector4;
|
|
343
349
|
/**
|
|
344
350
|
* Copy the values from another vector into this one.
|
|
345
351
|
* @param vector - The vector to copy.
|
|
@@ -349,77 +355,72 @@ export default class Vector4 extends Float32Array implements Vector, Vector4Like
|
|
|
349
355
|
/**
|
|
350
356
|
* Multiply this vector by another.
|
|
351
357
|
* @param vector - The other vector.
|
|
352
|
-
* @param out - The vector to store the result in.
|
|
353
358
|
* @returns The product of the vectors.
|
|
354
359
|
*/
|
|
355
|
-
multiply
|
|
360
|
+
multiply(vector: Vector4Like): Vector4;
|
|
356
361
|
/**
|
|
357
362
|
* Divide this vector by another.
|
|
358
363
|
* @param vector - The other vector.
|
|
359
|
-
* @param out - The vector to store the result in.
|
|
360
364
|
* @returns The quotient of the vectors.
|
|
361
365
|
*/
|
|
362
|
-
divide
|
|
366
|
+
divide(vector: Vector4Like): Vector4;
|
|
363
367
|
/**
|
|
364
368
|
* Subtract another vector from this one.
|
|
365
369
|
* @param vector - The other vector.
|
|
366
|
-
* @param out - The vector to store the result in.
|
|
367
370
|
* @returns The difference between the vectors.
|
|
368
371
|
*/
|
|
369
|
-
subtract
|
|
372
|
+
subtract(vector: Vector4Like): Vector4;
|
|
370
373
|
/**
|
|
371
374
|
* Absolutize the components of this vector.
|
|
372
|
-
* @param out - The vector to store the result in.
|
|
373
375
|
* @returns The absolutized vector.
|
|
374
376
|
*/
|
|
375
|
-
abs
|
|
377
|
+
abs(): Vector4;
|
|
376
378
|
/**
|
|
377
379
|
* Round up the components of this vector.
|
|
378
|
-
* @param out - The vector to store the result in.
|
|
379
380
|
* @returns The rounded vector.
|
|
380
381
|
*/
|
|
381
|
-
ceil
|
|
382
|
+
ceil(): Vector4;
|
|
382
383
|
/**
|
|
383
384
|
* Round down the components of this vector.
|
|
384
|
-
* @param out - The vector to store the result in.
|
|
385
385
|
* @returns The rounded vector.
|
|
386
386
|
*/
|
|
387
|
-
floor
|
|
387
|
+
floor(): Vector4;
|
|
388
388
|
/**
|
|
389
389
|
* Round the components of this vector.
|
|
390
|
-
* @param out - The vector to store the result in.
|
|
391
390
|
* @returns The rounded vector.
|
|
392
391
|
*/
|
|
393
|
-
round
|
|
392
|
+
round(): Vector4;
|
|
394
393
|
/**
|
|
395
394
|
* Return the minimum of this and another vector.
|
|
396
395
|
* @param vector - The other vector.
|
|
397
|
-
* @param out - The vector to store the result in.
|
|
398
396
|
* @returns The minimum.
|
|
399
397
|
*/
|
|
400
|
-
min
|
|
398
|
+
min(vector: Vector4Like): Vector4;
|
|
401
399
|
/**
|
|
402
400
|
* Return the maximum of this and another vector.
|
|
403
401
|
* @param vector - The other vector.
|
|
404
|
-
* @param out - The vector to store the result in.
|
|
405
402
|
* @returns The maximum.
|
|
406
403
|
*/
|
|
407
|
-
max
|
|
404
|
+
max(vector: Vector4Like): Vector4;
|
|
405
|
+
/**
|
|
406
|
+
* Raise each component of this vector to the given power.
|
|
407
|
+
* @param scalar - The exponent (power) to raise each component to.
|
|
408
|
+
* @returns The power (result of the exponentiation).
|
|
409
|
+
*/
|
|
410
|
+
pow(scalar: number): Vector4;
|
|
408
411
|
/**
|
|
409
412
|
* Scale this vector by a scalar.
|
|
410
413
|
* @param scalar - The scalar.
|
|
411
|
-
* @param out - The vector to store the result in.
|
|
412
414
|
* @returns The scaled vector.
|
|
413
415
|
*/
|
|
414
|
-
scale
|
|
416
|
+
scale(scalar: number): Vector4;
|
|
415
417
|
/**
|
|
416
418
|
* Add another vector to this one after scaling the other by a scalar.
|
|
417
419
|
* @param vector - The other vector.
|
|
418
420
|
* @param scalar - The scalar.
|
|
419
|
-
* @param out - The vector to store the result in.
|
|
420
421
|
* @returns The sum.
|
|
421
422
|
*/
|
|
422
|
-
scaleAndAdd
|
|
423
|
+
scaleAndAdd(vector: Vector4Like, scalar: number): Vector4;
|
|
423
424
|
/**
|
|
424
425
|
* Calculate the Euclidean distance between this vector and another.
|
|
425
426
|
* @param vector - The other vector.
|
|
@@ -434,29 +435,28 @@ export default class Vector4 extends Float32Array implements Vector, Vector4Like
|
|
|
434
435
|
* @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
|
|
435
436
|
*/
|
|
436
437
|
squaredDistance(vector: Vector4Like): number;
|
|
437
|
-
/**
|
|
438
|
+
/** The magnitude (length) of this vector. */
|
|
438
439
|
get magnitude(): number;
|
|
439
|
-
|
|
440
|
+
set magnitude(value: number);
|
|
441
|
+
/** The squared magnitude (length) of this vector. */
|
|
440
442
|
get squaredMagnitude(): number;
|
|
443
|
+
set squaredMagnitude(value: number);
|
|
441
444
|
/**
|
|
442
445
|
* Negate this vector.
|
|
443
|
-
* @param out - The vector to store the result in.
|
|
444
446
|
* @returns The negated vector.
|
|
445
447
|
*/
|
|
446
|
-
negate
|
|
448
|
+
negate(): Vector4;
|
|
447
449
|
/**
|
|
448
450
|
* Calculate the multiplicative inverse of the components of this vector.
|
|
449
|
-
* @param out - The vector to store the result in.
|
|
450
451
|
* @returns The inverted vector.
|
|
451
452
|
*/
|
|
452
|
-
invert
|
|
453
|
+
invert(): Vector4;
|
|
453
454
|
/**
|
|
454
455
|
* Normalize this vector.
|
|
455
|
-
* @param out - The vector to store the result in.
|
|
456
456
|
* @returns The normalized vector.
|
|
457
457
|
* @see {@link https://en.wikipedia.org/wiki/Unit_vector | Unit vector}
|
|
458
458
|
*/
|
|
459
|
-
normalize
|
|
459
|
+
normalize(): Vector4;
|
|
460
460
|
/**
|
|
461
461
|
* Calculate the dot product of this and another vector.
|
|
462
462
|
* @param vector - The other vector.
|
|
@@ -468,20 +468,18 @@ export default class Vector4 extends Float32Array implements Vector, Vector4Like
|
|
|
468
468
|
* Calculate the cross product of this and two other vectors in a four-dimensional space.
|
|
469
469
|
* @param a - One other vector.
|
|
470
470
|
* @param b - The other other vector.
|
|
471
|
-
* @param out - The vector to store the result in.
|
|
472
471
|
* @returns The cross product.
|
|
473
472
|
* @see {@link https://en.wikipedia.org/wiki/Cross_product | Cross product}
|
|
474
473
|
*/
|
|
475
|
-
cross
|
|
474
|
+
cross(a: Vector4Like, b: Vector4Like): Vector4;
|
|
476
475
|
/**
|
|
477
476
|
* Perform a linear interpolation between this and another vector.
|
|
478
477
|
* @param vector - The other vector.
|
|
479
478
|
* @param t - The interpolation amount (in `[0,1]`).
|
|
480
|
-
* @param out - The vector to store the result in.
|
|
481
479
|
* @returns The interpolated vector.
|
|
482
480
|
* @see {@link https://en.wikipedia.org/wiki/Linear_interpolation | Linear interpolation}
|
|
483
481
|
*/
|
|
484
|
-
lerp
|
|
482
|
+
lerp(vector: Vector4Like, t: number): Vector4;
|
|
485
483
|
/**
|
|
486
484
|
* Set this vector to a random value with the given magnitude.
|
|
487
485
|
* @param magnitude - The magnitude.
|
|
@@ -491,11 +489,10 @@ export default class Vector4 extends Float32Array implements Vector, Vector4Like
|
|
|
491
489
|
/**
|
|
492
490
|
* Transform this vector by a four-by-four matrix.
|
|
493
491
|
* @param matrix - The matrix.
|
|
494
|
-
* @param out - The vector to store the result in.
|
|
495
492
|
* @returns The transformed vector.
|
|
496
493
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
497
494
|
*/
|
|
498
|
-
transformMatrix4
|
|
495
|
+
transformMatrix4(matrix: Matrix4Like): Vector4;
|
|
499
496
|
/**
|
|
500
497
|
* Set this to the zero vector.
|
|
501
498
|
* @returns This vector.
|
|
@@ -504,10 +501,9 @@ export default class Vector4 extends Float32Array implements Vector, Vector4Like
|
|
|
504
501
|
/**
|
|
505
502
|
* Transform this vector by a quaternion.
|
|
506
503
|
* @param quaternion - The quaternion.
|
|
507
|
-
* @param out - The vector to store the result in.
|
|
508
504
|
* @returns The transformed vector.
|
|
509
505
|
* @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
|
|
510
506
|
*/
|
|
511
|
-
transformQuaternion
|
|
507
|
+
transformQuaternion(quaternion: QuaternionLike): Vector4;
|
|
512
508
|
}
|
|
513
509
|
//# sourceMappingURL=Vector4.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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;;OAKG;IACI,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM;IAI5C;;;;;OAKG;IACI,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM;IAInD,6CAA6C;IAC7C,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED,IAAW,SAAS,CAAC,KAAK,EAAE,MAAM,EAEjC;IAED,qDAAqD;IACrD,IAAW,gBAAgB,IAAI,MAAM,CAEpC;IAED,IAAW,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAExC;IAED;;;OAGG;IACI,MAAM,IAAI,OAAO;IAIxB;;;OAGG;IACI,MAAM,IAAI,OAAO;IAIxB;;;;OAIG;IACI,SAAS,IAAI,OAAO;IAI3B;;;;;OAKG;IACI,GAAG,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM;IAIvC;;;;;;OAMG;IACI,KAAK,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO;IAIrD;;;;;;OAMG;IACI,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;IAIpD;;;;OAIG;IACI,MAAM,CAAC,SAAS,SAAI,GAAG,IAAI;IAIlC;;;;;OAKG;IACI,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO;IAIrD;;;OAGG;IACI,IAAI,IAAI,IAAI;IAInB;;;;;OAKG;IACI,mBAAmB,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO;CAG/D"}
|
package/dist/linalg/Vector4.js
CHANGED
|
@@ -137,6 +137,15 @@ export const min = (a, b, out) => fromValues(Math.min(a[0], b[0]), Math.min(a[1]
|
|
|
137
137
|
* @public
|
|
138
138
|
*/
|
|
139
139
|
export const max = (a, b, out) => fromValues(Math.max(a[0], b[0]), Math.max(a[1], b[1]), Math.max(a[2], b[2]), Math.max(a[3], b[3]), out);
|
|
140
|
+
/**
|
|
141
|
+
* Raise each component of a vector to the given power.
|
|
142
|
+
* @param vector - The base.
|
|
143
|
+
* @param scalar - The exponent (power) to raise each component to.
|
|
144
|
+
* @param out - The vector to store the result in.
|
|
145
|
+
* @returns The power (result of the exponentiation).
|
|
146
|
+
* @public
|
|
147
|
+
*/
|
|
148
|
+
export const pow = (vector, scalar, out) => fromValues(vector[0] ** scalar, vector[1] ** scalar, vector[2] ** scalar, vector[3] ** scalar, out);
|
|
140
149
|
/**
|
|
141
150
|
* Scale a vector by a scalar.
|
|
142
151
|
* @param vector - The multiplier.
|
|
@@ -164,13 +173,7 @@ export const scaleAndAdd = (a, b, scalar, out) => fromValues(a[0] + b[0] * scala
|
|
|
164
173
|
* @see {@link https://en.wikipedia.org/wiki/Euclidean_distance | Euclidean distance}
|
|
165
174
|
* @public
|
|
166
175
|
*/
|
|
167
|
-
export const distance = (a, b) =>
|
|
168
|
-
const x = a[0] - b[0];
|
|
169
|
-
const y = a[1] - b[1];
|
|
170
|
-
const z = a[2] - b[2];
|
|
171
|
-
const w = a[3] - b[3];
|
|
172
|
-
return Math.sqrt(x * x + y * y + z * z + w * w); // `Math.hypot` is slower.
|
|
173
|
-
};
|
|
176
|
+
export const distance = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2], a[3] - b[3]);
|
|
174
177
|
/**
|
|
175
178
|
* Calculate the squared Euclidean distance between two vectors.
|
|
176
179
|
* @param a - The first vector.
|
|
@@ -192,13 +195,7 @@ export const squaredDistance = (a, b) => {
|
|
|
192
195
|
* @returns The magnitude.
|
|
193
196
|
* @public
|
|
194
197
|
*/
|
|
195
|
-
export const getMagnitude = (vector) =>
|
|
196
|
-
const x = vector[0];
|
|
197
|
-
const y = vector[1];
|
|
198
|
-
const z = vector[2];
|
|
199
|
-
const w = vector[3];
|
|
200
|
-
return Math.sqrt(x * x + y * y + z * z + w * w); // `Math.hypot` is slower.
|
|
201
|
-
};
|
|
198
|
+
export const getMagnitude = (vector) => Math.hypot(vector[0], vector[1], vector[2], vector[3]);
|
|
202
199
|
/**
|
|
203
200
|
* Calculate the squared magnitude (length) of a vector.
|
|
204
201
|
* @param vector - The vector.
|
|
@@ -380,11 +377,10 @@ export default class Vector4 extends Float32Array {
|
|
|
380
377
|
* @param y - The second component.
|
|
381
378
|
* @param z - The third component.
|
|
382
379
|
* @param w - The fourth component.
|
|
383
|
-
* @param out - The vector to store the result in.
|
|
384
380
|
* @returns A new vector.
|
|
385
381
|
*/
|
|
386
|
-
static fromValues(x, y, z, w
|
|
387
|
-
return fromValues(x, y, z, w,
|
|
382
|
+
static fromValues(x, y, z, w) {
|
|
383
|
+
return fromValues(x, y, z, w, new Vector4());
|
|
388
384
|
}
|
|
389
385
|
/**
|
|
390
386
|
* Create a four-dimensional zero vector.
|
|
@@ -420,19 +416,17 @@ export default class Vector4 extends Float32Array {
|
|
|
420
416
|
/**
|
|
421
417
|
* Add two vectors of the same size.
|
|
422
418
|
* @param vector - The other vector.
|
|
423
|
-
* @param out - The vector to store the result in.
|
|
424
419
|
* @returns The sum of the vectors.
|
|
425
420
|
*/
|
|
426
|
-
add(vector
|
|
427
|
-
return add(this, vector,
|
|
421
|
+
add(vector) {
|
|
422
|
+
return add(this, vector, new Vector4());
|
|
428
423
|
}
|
|
429
424
|
/**
|
|
430
425
|
* Copy the values from this vector to another one.
|
|
431
|
-
* @param out - The vector to store the result in.
|
|
432
426
|
* @returns The copy.
|
|
433
427
|
*/
|
|
434
|
-
clone(
|
|
435
|
-
return copy(this,
|
|
428
|
+
clone() {
|
|
429
|
+
return copy(this, new Vector4());
|
|
436
430
|
}
|
|
437
431
|
/**
|
|
438
432
|
* Copy the values from another vector into this one.
|
|
@@ -445,98 +439,95 @@ export default class Vector4 extends Float32Array {
|
|
|
445
439
|
/**
|
|
446
440
|
* Multiply this vector by another.
|
|
447
441
|
* @param vector - The other vector.
|
|
448
|
-
* @param out - The vector to store the result in.
|
|
449
442
|
* @returns The product of the vectors.
|
|
450
443
|
*/
|
|
451
|
-
multiply(vector
|
|
452
|
-
return multiply(this, vector,
|
|
444
|
+
multiply(vector) {
|
|
445
|
+
return multiply(this, vector, new Vector4());
|
|
453
446
|
}
|
|
454
447
|
/**
|
|
455
448
|
* Divide this vector by another.
|
|
456
449
|
* @param vector - The other vector.
|
|
457
|
-
* @param out - The vector to store the result in.
|
|
458
450
|
* @returns The quotient of the vectors.
|
|
459
451
|
*/
|
|
460
|
-
divide(vector
|
|
461
|
-
return divide(this, vector,
|
|
452
|
+
divide(vector) {
|
|
453
|
+
return divide(this, vector, new Vector4());
|
|
462
454
|
}
|
|
463
455
|
/**
|
|
464
456
|
* Subtract another vector from this one.
|
|
465
457
|
* @param vector - The other vector.
|
|
466
|
-
* @param out - The vector to store the result in.
|
|
467
458
|
* @returns The difference between the vectors.
|
|
468
459
|
*/
|
|
469
|
-
subtract(vector
|
|
470
|
-
return subtract(this, vector,
|
|
460
|
+
subtract(vector) {
|
|
461
|
+
return subtract(this, vector, new Vector4());
|
|
471
462
|
}
|
|
472
463
|
/**
|
|
473
464
|
* Absolutize the components of this vector.
|
|
474
|
-
* @param out - The vector to store the result in.
|
|
475
465
|
* @returns The absolutized vector.
|
|
476
466
|
*/
|
|
477
|
-
abs(
|
|
478
|
-
return abs(this,
|
|
467
|
+
abs() {
|
|
468
|
+
return abs(this, new Vector4());
|
|
479
469
|
}
|
|
480
470
|
/**
|
|
481
471
|
* Round up the components of this vector.
|
|
482
|
-
* @param out - The vector to store the result in.
|
|
483
472
|
* @returns The rounded vector.
|
|
484
473
|
*/
|
|
485
|
-
ceil(
|
|
486
|
-
return ceil(this,
|
|
474
|
+
ceil() {
|
|
475
|
+
return ceil(this, new Vector4());
|
|
487
476
|
}
|
|
488
477
|
/**
|
|
489
478
|
* Round down the components of this vector.
|
|
490
|
-
* @param out - The vector to store the result in.
|
|
491
479
|
* @returns The rounded vector.
|
|
492
480
|
*/
|
|
493
|
-
floor(
|
|
494
|
-
return floor(this,
|
|
481
|
+
floor() {
|
|
482
|
+
return floor(this, new Vector4());
|
|
495
483
|
}
|
|
496
484
|
/**
|
|
497
485
|
* Round the components of this vector.
|
|
498
|
-
* @param out - The vector to store the result in.
|
|
499
486
|
* @returns The rounded vector.
|
|
500
487
|
*/
|
|
501
|
-
round(
|
|
502
|
-
return round(this,
|
|
488
|
+
round() {
|
|
489
|
+
return round(this, new Vector4());
|
|
503
490
|
}
|
|
504
491
|
/**
|
|
505
492
|
* Return the minimum of this and another vector.
|
|
506
493
|
* @param vector - The other vector.
|
|
507
|
-
* @param out - The vector to store the result in.
|
|
508
494
|
* @returns The minimum.
|
|
509
495
|
*/
|
|
510
|
-
min(vector
|
|
511
|
-
return min(this, vector,
|
|
496
|
+
min(vector) {
|
|
497
|
+
return min(this, vector, new Vector4());
|
|
512
498
|
}
|
|
513
499
|
/**
|
|
514
500
|
* Return the maximum of this and another vector.
|
|
515
501
|
* @param vector - The other vector.
|
|
516
|
-
* @param out - The vector to store the result in.
|
|
517
502
|
* @returns The maximum.
|
|
518
503
|
*/
|
|
519
|
-
max(vector
|
|
520
|
-
return max(this, vector,
|
|
504
|
+
max(vector) {
|
|
505
|
+
return max(this, vector, new Vector4());
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Raise each component of this vector to the given power.
|
|
509
|
+
* @param scalar - The exponent (power) to raise each component to.
|
|
510
|
+
* @returns The power (result of the exponentiation).
|
|
511
|
+
*/
|
|
512
|
+
pow(scalar) {
|
|
513
|
+
return pow(this, scalar, new Vector4());
|
|
521
514
|
}
|
|
522
515
|
/**
|
|
523
516
|
* Scale this vector by a scalar.
|
|
524
517
|
* @param scalar - The scalar.
|
|
525
|
-
* @param out - The vector to store the result in.
|
|
526
518
|
* @returns The scaled vector.
|
|
527
519
|
*/
|
|
528
|
-
scale(scalar
|
|
529
|
-
return scale(this, scalar,
|
|
520
|
+
scale(scalar) {
|
|
521
|
+
return scale(this, scalar, new Vector4());
|
|
530
522
|
}
|
|
531
523
|
/**
|
|
532
524
|
* Add another vector to this one after scaling the other by a scalar.
|
|
533
525
|
* @param vector - The other vector.
|
|
534
526
|
* @param scalar - The scalar.
|
|
535
|
-
* @param out - The vector to store the result in.
|
|
536
527
|
* @returns The sum.
|
|
537
528
|
*/
|
|
538
|
-
scaleAndAdd(vector, scalar
|
|
539
|
-
return scaleAndAdd(this, vector, scalar,
|
|
529
|
+
scaleAndAdd(vector, scalar) {
|
|
530
|
+
return scaleAndAdd(this, vector, scalar, new Vector4());
|
|
540
531
|
}
|
|
541
532
|
/**
|
|
542
533
|
* Calculate the Euclidean distance between this vector and another.
|
|
@@ -556,38 +547,41 @@ export default class Vector4 extends Float32Array {
|
|
|
556
547
|
squaredDistance(vector) {
|
|
557
548
|
return squaredDistance(this, vector);
|
|
558
549
|
}
|
|
559
|
-
/**
|
|
550
|
+
/** The magnitude (length) of this vector. */
|
|
560
551
|
get magnitude() {
|
|
561
552
|
return getMagnitude(this);
|
|
562
553
|
}
|
|
563
|
-
|
|
554
|
+
set magnitude(value) {
|
|
555
|
+
scale(normalize(this, this), value, this);
|
|
556
|
+
}
|
|
557
|
+
/** The squared magnitude (length) of this vector. */
|
|
564
558
|
get squaredMagnitude() {
|
|
565
559
|
return getSquaredMagnitude(this);
|
|
566
560
|
}
|
|
561
|
+
set squaredMagnitude(value) {
|
|
562
|
+
this.magnitude = Math.sqrt(value);
|
|
563
|
+
}
|
|
567
564
|
/**
|
|
568
565
|
* Negate this vector.
|
|
569
|
-
* @param out - The vector to store the result in.
|
|
570
566
|
* @returns The negated vector.
|
|
571
567
|
*/
|
|
572
|
-
negate(
|
|
573
|
-
return negate(this,
|
|
568
|
+
negate() {
|
|
569
|
+
return negate(this, new Vector4());
|
|
574
570
|
}
|
|
575
571
|
/**
|
|
576
572
|
* Calculate the multiplicative inverse of the components of this vector.
|
|
577
|
-
* @param out - The vector to store the result in.
|
|
578
573
|
* @returns The inverted vector.
|
|
579
574
|
*/
|
|
580
|
-
invert(
|
|
581
|
-
return invert(this,
|
|
575
|
+
invert() {
|
|
576
|
+
return invert(this, new Vector4());
|
|
582
577
|
}
|
|
583
578
|
/**
|
|
584
579
|
* Normalize this vector.
|
|
585
|
-
* @param out - The vector to store the result in.
|
|
586
580
|
* @returns The normalized vector.
|
|
587
581
|
* @see {@link https://en.wikipedia.org/wiki/Unit_vector | Unit vector}
|
|
588
582
|
*/
|
|
589
|
-
normalize(
|
|
590
|
-
return normalize(this,
|
|
583
|
+
normalize() {
|
|
584
|
+
return normalize(this, new Vector4());
|
|
591
585
|
}
|
|
592
586
|
/**
|
|
593
587
|
* Calculate the dot product of this and another vector.
|
|
@@ -602,23 +596,21 @@ export default class Vector4 extends Float32Array {
|
|
|
602
596
|
* Calculate the cross product of this and two other vectors in a four-dimensional space.
|
|
603
597
|
* @param a - One other vector.
|
|
604
598
|
* @param b - The other other vector.
|
|
605
|
-
* @param out - The vector to store the result in.
|
|
606
599
|
* @returns The cross product.
|
|
607
600
|
* @see {@link https://en.wikipedia.org/wiki/Cross_product | Cross product}
|
|
608
601
|
*/
|
|
609
|
-
cross(a, b
|
|
610
|
-
return cross(this, a, b,
|
|
602
|
+
cross(a, b) {
|
|
603
|
+
return cross(this, a, b, new Vector4());
|
|
611
604
|
}
|
|
612
605
|
/**
|
|
613
606
|
* Perform a linear interpolation between this and another vector.
|
|
614
607
|
* @param vector - The other vector.
|
|
615
608
|
* @param t - The interpolation amount (in `[0,1]`).
|
|
616
|
-
* @param out - The vector to store the result in.
|
|
617
609
|
* @returns The interpolated vector.
|
|
618
610
|
* @see {@link https://en.wikipedia.org/wiki/Linear_interpolation | Linear interpolation}
|
|
619
611
|
*/
|
|
620
|
-
lerp(vector, t
|
|
621
|
-
return lerp(this, vector, t,
|
|
612
|
+
lerp(vector, t) {
|
|
613
|
+
return lerp(this, vector, t, new Vector4());
|
|
622
614
|
}
|
|
623
615
|
/**
|
|
624
616
|
* Set this vector to a random value with the given magnitude.
|
|
@@ -631,12 +623,11 @@ export default class Vector4 extends Float32Array {
|
|
|
631
623
|
/**
|
|
632
624
|
* Transform this vector by a four-by-four matrix.
|
|
633
625
|
* @param matrix - The matrix.
|
|
634
|
-
* @param out - The vector to store the result in.
|
|
635
626
|
* @returns The transformed vector.
|
|
636
627
|
* @see {@link https://en.wikipedia.org/wiki/Transformation_matrix | Transformation matrix}
|
|
637
628
|
*/
|
|
638
|
-
transformMatrix4(matrix
|
|
639
|
-
return transformMatrix4(this, matrix,
|
|
629
|
+
transformMatrix4(matrix) {
|
|
630
|
+
return transformMatrix4(this, matrix, new Vector4());
|
|
640
631
|
}
|
|
641
632
|
/**
|
|
642
633
|
* Set this to the zero vector.
|
|
@@ -648,12 +639,11 @@ export default class Vector4 extends Float32Array {
|
|
|
648
639
|
/**
|
|
649
640
|
* Transform this vector by a quaternion.
|
|
650
641
|
* @param quaternion - The quaternion.
|
|
651
|
-
* @param out - The vector to store the result in.
|
|
652
642
|
* @returns The transformed vector.
|
|
653
643
|
* @see {@link https://en.wikipedia.org/wiki/Quaternion | Quaternion}
|
|
654
644
|
*/
|
|
655
|
-
transformQuaternion(quaternion
|
|
656
|
-
return transformQuaternion(this, quaternion,
|
|
645
|
+
transformQuaternion(quaternion) {
|
|
646
|
+
return transformQuaternion(this, quaternion, new Vector4());
|
|
657
647
|
}
|
|
658
648
|
}
|
|
659
649
|
//# sourceMappingURL=Vector4.js.map
|