Vector3D
Summary
Class representing a vector in 3D space.đź’ˇ
This class isn't a full implementation of a Vector, it just provides all necessary functionality
within this library.
Constructor
Constructs an instance with the given values.
Signature
new Vector3D(x: number, y: number, z: number)
Name | Type | Description |
---|---|---|
x | number | x-value |
y | number | y-value |
z | number | z-value |
Methods
copy
cross
Computs the cross-product between this instance and another one.
Signature
cross(other: Vector3D)
Name | Type | Description |
---|---|---|
other | Vector3D | the other instance |
Returns
Vector3D
the cross product resultgetDifference
Returns the difference between this instance and another one.
Signature
getDifference(other: Vector3D)
Name | Type | Description |
---|---|---|
other | Vector3D | subtrahend |
Returns
Vector3D
differencegetLength
Returns the length of this vector.
Signature
getLength()
Returns
number
L2-normnormalize
Normalizes this instance to a length of 1.
In case the previous length was 0, no changes are made.
Signature
normalize()
Returns
Vector3D
this instance for chaining operationsscale
Scales this instance by a given factor.
Signature
scale(factor: number)
Name | Type | Description |
---|---|---|
factor | number | scaling factor |
Returns
Vector3D
this iinstance for chaining operationsset
Sets the values of this instance.
Signature
set(x: number, y: number, z: number)
Name | Type | Description |
---|---|---|
x | number | new x-value |
y | number | new y-value |
z | number | new z-value |
Returns
Vector3D
the updated instance