Skip to main content

Class: VecNMath

Defined in: src/sdk/math/VecMath.ts:592

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:633

Gets the magnitude of a vector.

Parameters​

ParameterTypeDescription
vecReadonlyFloat64ArrayThe 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:717

Copies one vector to another.

Parameters​

ParameterTypeDescription
fromReadonlyFloat64ArrayThe vector from which to copy.
toFloat64ArrayThe 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:598

Creates an N-dimensional vector with all components initialized to 0.

Parameters​
ParameterTypeDescription
lengthnumberThe 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:605

Creates an N-dimensional vector with specified components.

Parameters​
ParameterTypeDescription
lengthnumberThe length of the new vector.
...componentsnumber[]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:644

Gets the dot product of two vectors.

Parameters​

ParameterTypeDescription
v1ReadonlyFloat64ArrayThe first vector.
v2ReadonlyFloat64ArrayThe 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:681

Checks if two vectors are equal.

Parameters​

ParameterTypeDescription
vec1ReadonlyFloat64ArrayThe first vector.
vec2ReadonlyFloat64ArrayThe second vector.

Returns​

boolean

Whether the two vectors are equal.


isFinite()​

static isFinite(vec): boolean

Defined in: src/sdk/math/VecMath.ts:700

Checks if a vector is finite. A vector is considered finite if all of its components are finite.

Parameters​

ParameterTypeDescription
vecReadonlyFloat64ArrayThe vector to check.

Returns​

boolean

Whether the specified vector is finite.


normalize()​

static normalize(v1, out): Float64Array

Defined in: src/sdk/math/VecMath.ts:664

Normalizes a vector to a unit vector.

Parameters​

ParameterTypeDescription
v1ReadonlyFloat64ArrayThe vector to normalize.
outFloat64ArrayThe vector to write the results to.

Returns​

Float64Array

The normalized vector.


set()​

static set(vec, ...components): Float64Array

Defined in: src/sdk/math/VecMath.ts:621

Sets the components of a vector.

Parameters​

ParameterTypeDescription
vecFloat64ArrayThe vector to change.
...componentsnumber[]The new components.

Returns​

Float64Array

The vector after it has been changed.