Skip to main content

Class: Vec3Math

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

3D vector mathematical operations.

Constructors

Constructor

new Vec3Math(): Vec3Math

Returns

Vec3Math

Methods

abs()

static abs(v1): number

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

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

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.


copy()

static copy(from, to): Float64Array

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.