vector
Built-in vector library, loaded by requiring vector
vector(x: number, y: number, z: number)
: vectorArgument | Type | Description |
---|---|---|
x | number | X coordinate of 3D position |
y | number | Y coordinate of 3D position |
z | number | Z coordinate of 3D position |
Creates a new vector object. Please note that you need to load the built-in vector library with require "vector"
vector_object:angles()
: number, number, numberConverts the vector to an angle and returns the pitch, yaw and roll
vector_object:dist2d(other: vector)
: numberArgument | Type | Description |
---|---|---|
other | vector | Other vector |
Returns the cross product / vector product of itself and another vector
vector_object:dist(other: vector)
: numberArgument | Type | Description |
---|---|---|
other | vector | Vector to calculate the distance to |
Returns the 3d distance to another vector
vector_object:dist(other: vector)
: numberArgument | Type | Description |
---|---|---|
other | vector | Vector to calculate the distance to |
Returns the 2d distance to another vector
vector_object:dot()
: numberReturns the dot product of the vector
vector_object:init(x: number, y: number, z: number)
: vectorArgument | Type | Description |
---|---|---|
x | number | X coordinate of 3D position |
y | number | Y coordinate of 3D position |
z | number | Z coordinate of 3D position |
Overwrites the X, Y and Z coordinates of the vector object, returning itself
vector_object:init_from_angles(pitch: number, yaw: number[, roll: number])
: vectorArgument | Type | Description |
---|---|---|
pitch | number | Pitch component of angle |
yaw | number | Yaw component of angle |
roll | number | Roll component of angle |
Converts the pitch, yaw and roll passed to a forward vector and overwrites the X, Y and Z coordinates with that. Returns itself
vector_object:length()
: numberReturns the length (magnitude)
vector_object:length2d()
: numberReturns the 2d length (X and Y components)
vector_object:length2dsqr()
: numberReturns the squared 2d length (X and Y components, faster than :length2d)
vector_object:lengthsqr()
: numberReturns the squared length (faster than :length)
vector_object:lerp(to: vector, percentage: number)
: vectorArgument | Type | Description |
---|---|---|
to | vector | Vector to lerp to |
percentage | number | Interpolation percentage (0-1) |
Interpolates by the specified percentage between the 2 vectors.
vector_object:normalize()
Normalizes the vector, dividing it by it's own length (resulting in a unit vector with length = 1)
vector_object:normalized()
: vectorReturns a new unit vector, divided it by it's own length
vector_object:scale(scalar: number)
Argument | Type | Description |
---|---|---|
scalar | number | Scalar value |
Scales the vector by the specified value.
vector_object:scaled(scalar: number)
: vectorArgument | Type | Description |
---|---|---|
scalar | number | Scalar value |
Returns a new vector, scaled by the specified value.
vector_object:to(other: vector)
: vectorArgument | Type | Description |
---|---|---|
other | vector | Other vector |
Returns the forward vector from itself to another vector
vector_object:unpack()
: number, number, numberReturns the X, Y and Z coordinate of the vector object. They can also be accessed by vec.x, vec.y, etc
vector_object:vectors()
: vector, vectorReturns the right and up vector of a forward vector
Last modified 1yr ago