Class: Vec3Math
3D vector mathematical operations.
Constructors
constructor
• new Vec3Math(): Vec3Math
Returns
Methods
abs
▸ abs(v1
): number
Gets the magnitude of a vector.
Parameters
Name | Type | Description |
---|---|---|
v1 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The vector to get the magnitude for. |
Returns
number
the vector's magnitude.
Defined in
src/sdk/math/VecMath.ts:458
add
▸ add(v1
, v2
, out
): Float64Array
Add one vector to another.
Parameters
Name | Type | Description |
---|---|---|
v1 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The first vector. |
v2 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The second vector. |
out | Float64Array | The vector to write the results to. |
Returns
Float64Array
the vector sum.
Defined in
src/sdk/math/VecMath.ts:384
copy
▸ copy(from
, to
): Float64Array
Copies one vector to another.
Parameters
Name | Type | Description |
---|---|---|
from | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The vector from which to copy. |
to | Float64Array | The vector to which to copy. |
Returns
Float64Array
the changed vector.
Defined in
src/sdk/math/VecMath.ts:512
create
▸ create(): Float64Array
Creates a 3D vector initialized to [0, 0, 0]
.
Returns
Float64Array
A new 3D vector initialized to [0, 0, 0]
.
Defined in
src/sdk/math/VecMath.ts:308
▸ create(x
, y
, z
): Float64Array
Creates a 3D vector with specified x-, y-, and z- components.
Parameters
Name | 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.
Defined in
src/sdk/math/VecMath.ts:316
cross
▸ cross(v1
, v2
, out
): Float64Array
Gets the cross product of two vectors.
Parameters
Name | Type | Description |
---|---|---|
v1 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | the first vector. |
v2 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | the second vector. |
out | Float64Array | the vector to which to write the result. |
Returns
Float64Array
the cross product.
Defined in
src/sdk/math/VecMath.ts:424
distance
▸ distance(vec1
, vec2
): number
Gets the Euclidean distance between two vectors.
Parameters
Name | Type | Description |
---|---|---|
vec1 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The first vector. |
vec2 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The second vector. |
Returns
number
the Euclidean distance between the two vectors.
Defined in
src/sdk/math/VecMath.ts:483
dot
▸ dot(v1
, v2
): number
Gets the dot product of two vectors.
Parameters
Name | Type | Description |
---|---|---|
v1 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The first vector. |
v2 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The second vector. |
Returns
number
The dot product of the vectors.
Defined in
src/sdk/math/VecMath.ts:413
equals
▸ equals(vec1
, vec2
): boolean
Checks if two vectors are equal.
Parameters
Name | Type | Description |
---|---|---|
vec1 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The first vector. |
vec2 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The second vector. |
Returns
boolean
Whether the two vectors are equal.
Defined in
src/sdk/math/VecMath.ts:493
isFinite
▸ isFinite(vec
): boolean
Checks if a vector is finite. A vector is considered finite if all of its components are finite.
Parameters
Name | Type | Description |
---|---|---|
vec | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The vector to check. |
Returns
boolean
Whether the specified vector is finite.
Defined in
src/sdk/math/VecMath.ts:502
multScalar
▸ multScalar(v1
, scalar
, out
): Float64Array
Multiplies a vector by a scalar.
Parameters
Name | Type | Description |
---|---|---|
v1 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The vector to multiply. |
scalar | number | The scalar to apply. |
out | Float64Array | The vector to write the results to. |
Returns
Float64Array
The scaled vector.
Defined in
src/sdk/math/VecMath.ts:445
normalize
▸ normalize(v1
, out
): Float64Array
Normalizes the vector to a unit vector.
Parameters
Name | Type | Description |
---|---|---|
v1 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The vector to normalize. |
out | Float64Array | The vector to write the results to. |
Returns
Float64Array
the normalized vector.
Defined in
src/sdk/math/VecMath.ts:468
phi
▸ phi(vec
): number
Gets the spherical angle phi (azimuthal angle) of a vector in radians.
Parameters
Name | Type | Description |
---|---|---|
vec | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | A vector. |
Returns
number
The spherical angle phi of the vector.
Defined in
src/sdk/math/VecMath.ts:342
set
▸ set(x
, y
, z
, vec
): Float64Array
Sets the components of a vector.
Parameters
Name | 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.
Defined in
src/sdk/math/VecMath.ts:354
setFromSpherical
▸ setFromSpherical(r
, theta
, phi
, vec
): Float64Array
Sets the spherical components of a vector.
Parameters
Name | 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.
Defined in
src/sdk/math/VecMath.ts:369
sub
▸ sub(v1
, v2
, out
): Float64Array
Subtracts one vector from another.
Parameters
Name | Type | Description |
---|---|---|
v1 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The first vector. |
v2 | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | The second vector. |
out | Float64Array | The vector to write the results to. |
Returns
Float64Array
the vector difference.
Defined in
src/sdk/math/VecMath.ts:399
theta
▸ theta(vec
): number
Gets the spherical angle theta (polar angle) of a vector in radians.
Parameters
Name | Type | Description |
---|---|---|
vec | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | A vector. |
Returns
number
The spherical angle theta of the vector.
Defined in
src/sdk/math/VecMath.ts:333