Class: VecNMath
Defined in: src/sdk/math/VecMath.ts:536
N-dimensional vector mathematical operations.
Constructors
Constructor
new VecNMath():
VecNMath
Returns
VecNMath
Methods
abs()
static
abs(vec
):number
Defined in: src/sdk/math/VecMath.ts:577
Gets the magnitude of a vector.
Parameters
Parameter | Type | Description |
---|---|---|
vec | ReadonlyFloat64Array | The vector to get the magnitude for. |
Returns
number
The vector's magnitude.
copy()
static
copy(from
,to
):Float64Array
Defined in: src/sdk/math/VecMath.ts:661
Copies one vector to another.
Parameters
Parameter | Type | Description |
---|---|---|
from | ReadonlyFloat64Array | The vector from which to copy. |
to | Float64Array | The vector to which to copy. |
Returns
Float64Array
The changed vector.
Throws
Error if the vectors are of unequal lengths.
create()
Call Signature
static
create(length
):Float64Array
Defined in: src/sdk/math/VecMath.ts:542
Creates an N-dimensional vector with all components initialized to 0
.
Parameters
Parameter | Type | Description |
---|---|---|
length | number | The length of the new vector. |
Returns
Float64Array
A new N-dimensional vector with the specified length and all components initialized to 0
.
Call Signature
static
create(length
, ...components
):Float64Array
Defined in: src/sdk/math/VecMath.ts:549
Creates an N-dimensional vector with specified components.
Parameters
Parameter | Type | Description |
---|---|---|
length | number | The length of the new vector. |
...components | number [] | The components of the new vector. |
Returns
Float64Array
A new N-dimensional vector with the specified length and components.
dot()
static
dot(v1
,v2
):number
Defined in: src/sdk/math/VecMath.ts:588
Gets the dot product of two vectors.
Parameters
Parameter | Type | Description |
---|---|---|
v1 | ReadonlyFloat64Array | The first vector. |
v2 | ReadonlyFloat64Array | The second vector. |
Returns
number
The dot product of the vectors.
Throws
Error if the two vectors are of unequal lengths.
equals()
static
equals(vec1
,vec2
):boolean
Defined in: src/sdk/math/VecMath.ts:625
Checks if two vectors are equal.
Parameters
Parameter | Type | Description |
---|---|---|
vec1 | ReadonlyFloat64Array | The first vector. |
vec2 | ReadonlyFloat64Array | The second vector. |
Returns
boolean
Whether the two vectors are equal.
isFinite()
static
isFinite(vec
):boolean
Defined in: src/sdk/math/VecMath.ts:644
Checks if a vector is finite. A vector is considered finite if all of its components are finite.
Parameters
Parameter | Type | Description |
---|---|---|
vec | ReadonlyFloat64Array | The vector to check. |
Returns
boolean
Whether the specified vector is finite.
normalize()
static
normalize(v1
,out
):Float64Array
Defined in: src/sdk/math/VecMath.ts:608
Normalizes a vector to a unit vector.
Parameters
Parameter | Type | Description |
---|---|---|
v1 | ReadonlyFloat64Array | The vector to normalize. |
out | Float64Array | The vector to write the results to. |
Returns
Float64Array
The normalized vector.
set()
static
set(vec
, ...components
):Float64Array
Defined in: src/sdk/math/VecMath.ts:565
Sets the components of a vector.
Parameters
Parameter | Type | Description |
---|---|---|
vec | Float64Array | The vector to change. |
...components | number [] | The new components. |
Returns
Float64Array
The vector after it has been changed.