Class: VecNMath
N-dimensional vector mathematical operations.
Constructors
constructor
• new VecNMath(): VecNMath
Returns
Methods
abs
▸ abs(vec
): number
Gets the magnitude of a vector.
Parameters
Name | Type | Description |
---|---|---|
vec | 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:561
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.
Throws
Error if the vectors are of unequal lengths.
Defined in
src/sdk/math/VecMath.ts:645
create
▸ create(length
): Float64Array
Creates an N-dimensional vector with all components initialized to 0
.
Parameters
Name | Type | Description |
---|---|---|
length | number | The length of the new vector. |
Returns
Float64Array
A new N-dimensional vector with the specified length and all components initialized to 0
.
Defined in
src/sdk/math/VecMath.ts:526
▸ create(length
, ...components
): Float64Array
Creates an N-dimensional vector with specified components.
Parameters
Name | Type | Description |
---|---|---|
length | number | The length of the new vector. |
...components | number [] | The components of the new vector. |
Returns
Float64Array
A new N-dimensional vector with the specified length and components.
Defined in
src/sdk/math/VecMath.ts:533
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.
Throws
Error if the two vectors are of unequal lengths.
Defined in
src/sdk/math/VecMath.ts:572
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:609
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:628
normalize
▸ normalize(v1
, out
): Float64Array
Normalizes a 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:592
set
▸ set(vec
, ...components
): Float64Array
Sets the components of a vector.
Parameters
Name | Type | Description |
---|---|---|
vec | Float64Array | The vector to change. |
...components | number [] | The new components. |
Returns
Float64Array
The vector after it has been changed.
Defined in
src/sdk/math/VecMath.ts:549