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
Parameter | Type | Description |
---|---|---|
v1 | ReadonlyFloat64Array | The 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
Parameter | Type | Description |
---|---|---|
v1 | ReadonlyFloat64Array | The first vector. |
v2 | ReadonlyFloat64Array | The second vector. |
out | Float64Array | The 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
Parameter | Type | Description |
---|---|---|
from | ReadonlyFloat64Array | The vector from which to copy. |
to | Float64Array | The 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
Parameter | Type | Description |
---|---|---|
x | number | The x-component of the new vector. |
y | number | The y-component of the new vector. |
z | number | The 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
Parameter | Type | Description |
---|---|---|
v1 | ReadonlyFloat64Array | the first vector. |
v2 | ReadonlyFloat64Array | the second vector. |
out | Float64Array | the 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
Parameter | Type | Description |
---|---|---|
vec1 | ReadonlyFloat64Array | The first vector. |
vec2 | ReadonlyFloat64Array | The 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
Parameter | Type | Description |
---|---|---|
v1 | ReadonlyFloat64Array | The first vector. |
v2 | ReadonlyFloat64Array | The 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
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:518
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.
multScalar()
static
multScalar(v1
,scalar
,out
):Float64Array
Defined in: src/sdk/math/VecMath.ts:445
Multiplies a vector by a scalar.
Parameters
Parameter | Type | Description |
---|---|---|
v1 | ReadonlyFloat64Array | The vector to multiply. |
scalar | number | The scalar to apply. |
out | Float64Array | The 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
Parameter | Type | Description |
---|---|---|
v1 | ReadonlyFloat64Array | The vector to normalize. |
out | Float64Array | The 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
Parameter | Type | Description |
---|---|---|
vec | ReadonlyFloat64Array | A 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
Parameter | Type | Description |
---|---|---|
x | number | The new x-component. |
y | number | The new y-component. |
z | number | The new z-component. |
vec | Float64Array | The 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
Parameter | Type | Description |
---|---|---|
r | number | The new length (magnitude). |
theta | number | The new spherical angle theta (polar angle), in radians. |
phi | number | The new spherical angle phi (azimuthal angle), in radians. |
vec | Float64Array | The 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
Parameter | Type | Description |
---|---|---|
v1 | ReadonlyFloat64Array | The vector to receive a new length. |
magnitude | number | The length to apply. |
out | Float64Array | The 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
Parameter | Type | Description |
---|---|---|
v1 | ReadonlyFloat64Array | The first vector. |
v2 | ReadonlyFloat64Array | The second vector. |
out | Float64Array | The 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
Parameter | Type | Description |
---|---|---|
vec | ReadonlyFloat64Array | A vector. |
Returns
number
The spherical angle theta of the vector.