Skip to main content

Class: Vec3Math

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

3D vector mathematical operations.

Constructors​

Constructor​

new Vec3Math(): Vec3Math

Returns​

Vec3Math

Methods​

abs()​

static abs(v1): number

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

Gets the magnitude of a vector.

Parameters​

ParameterTypeDescription
v1ReadonlyFloat64ArrayThe vector to get the magnitude for.

Returns​

number

the vector's magnitude.


add()​

static add(v1, v2, out): Float64Array

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

Add one vector to another.

Parameters​

ParameterTypeDescription
v1ReadonlyFloat64ArrayThe first vector.
v2ReadonlyFloat64ArrayThe second vector.
outFloat64ArrayThe vector to write the results to.

Returns​

Float64Array

the vector sum.


angle()​

static angle(vec1, vec2): number

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

Gets the angle between two vectors, in radians.

Parameters​

ParameterTypeDescription
vec1ReadonlyFloat64ArrayThe first vector.
vec2ReadonlyFloat64ArrayThe second vector.

Returns​

number

The angle between the two specified unit vectors, in radians, or NaN if either of the vectors has a magnitude equal to zero.


copy()​

static copy(from, to): Float64Array

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

Copies one vector to another.

Parameters​

ParameterTypeDescription
fromReadonlyFloat64ArrayThe vector from which to copy.
toFloat64ArrayThe vector to which to copy.

Returns​

Float64Array

the changed vector.


create()​

Call Signature​

static create(): Float64Array

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

Creates a 3D vector initialized to [0, 0, 0].

Returns​

Float64Array

A new 3D vector initialized to [0, 0, 0].

Call Signature​

static create(x, y, z): Float64Array

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

Creates a 3D vector with specified x-, y-, and z- components.

Parameters​
ParameterTypeDescription
xnumberThe x-component of the new vector.
ynumberThe y-component of the new vector.
znumberThe z-component of the new vector.
Returns​

Float64Array

A new 3D vector with the specified components.


cross()​

static cross(v1, v2, out): Float64Array

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

Gets the cross product of two vectors.

Parameters​

ParameterTypeDescription
v1ReadonlyFloat64Arraythe first vector.
v2ReadonlyFloat64Arraythe second vector.
outFloat64Arraythe vector to which to write the result.

Returns​

Float64Array

the cross product.


distance()​

static distance(vec1, vec2): number

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

Gets the Euclidean distance between two vectors.

Parameters​

ParameterTypeDescription
vec1ReadonlyFloat64ArrayThe first vector.
vec2ReadonlyFloat64ArrayThe second vector.

Returns​

number

the Euclidean distance between the two vectors.


dot()​

static dot(v1, v2): number

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

Gets the dot product of two vectors.

Parameters​

ParameterTypeDescription
v1ReadonlyFloat64ArrayThe first vector.
v2ReadonlyFloat64ArrayThe second vector.

Returns​

number

The dot product of the vectors.


equals()​

static equals(vec1, vec2): boolean

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

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

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.


multScalar()​

static multScalar(v1, scalar, out): Float64Array

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

Multiplies a vector by a scalar.

Parameters​

ParameterTypeDescription
v1ReadonlyFloat64ArrayThe vector to multiply.
scalarnumberThe scalar to apply.
outFloat64ArrayThe vector to write the results to.

Returns​

Float64Array

The scaled vector.


normalize()​

static normalize(v1, out): Float64Array

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

Normalizes the vector to a unit vector.

Parameters​

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

Returns​

Float64Array

the normalized vector.


phi()​

static phi(vec): number

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

Gets the spherical angle phi (azimuthal angle) of a vector in radians.

Parameters​

ParameterTypeDescription
vecReadonlyFloat64ArrayA vector.

Returns​

number

The spherical angle phi of the vector.


set()​

static set(x, y, z, vec): Float64Array

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

Sets the components of a vector.

Parameters​

ParameterTypeDescription
xnumberThe new x-component.
ynumberThe new y-component.
znumberThe new z-component.
vecFloat64ArrayThe vector to change.

Returns​

Float64Array

The vector after it has been changed.


setFromSpherical()​

static setFromSpherical(r, theta, phi, vec): Float64Array

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

Sets the spherical components of a vector.

Parameters​

ParameterTypeDescription
rnumberThe new length (magnitude).
thetanumberThe new spherical angle theta (polar angle), in radians.
phinumberThe new spherical angle phi (azimuthal angle), in radians.
vecFloat64ArrayThe vector to change.

Returns​

Float64Array

The vector after it has been changed.


setMagnitude()​

static setMagnitude(v1, magnitude, out): Float64Array

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

Sets the magnitude of a vector.

Parameters​

ParameterTypeDescription
v1ReadonlyFloat64ArrayThe vector to receive a new length.
magnitudenumberThe length to apply.
outFloat64ArrayThe vector to write the results to.

Returns​

Float64Array

The scaled vector.


sub()​

static sub(v1, v2, out): Float64Array

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

Subtracts one vector from another.

Parameters​

ParameterTypeDescription
v1ReadonlyFloat64ArrayThe first vector.
v2ReadonlyFloat64ArrayThe second vector.
outFloat64ArrayThe vector to write the results to.

Returns​

Float64Array

the vector difference.


theta()​

static theta(vec): number

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

Gets the spherical angle theta (polar angle) of a vector in radians.

Parameters​

ParameterTypeDescription
vecReadonlyFloat64ArrayA vector.

Returns​

number

The spherical angle theta of the vector.


unitAngle()​

static unitAngle(vec1, vec2): number

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

Gets the angle between two unit vectors, in radians.

Parameters​

ParameterTypeDescription
vec1ReadonlyFloat64ArrayThe first unit vector.
vec2ReadonlyFloat64ArrayThe second unit vector.

Returns​

number

The angle between the two specified unit vectors, in radians.