vector
Built-in vector library, loaded by requiring vector
Last updated
Built-in vector library, loaded by requiring vector
Last updated
vector(x: number, y: number, z: number)
: vector
Argument | Type | Description |
---|---|---|
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, number
Converts the vector to an angle and returns the pitch, yaw and roll
vector_object:dist2d(other: vector)
: number
Argument | Type | Description |
---|---|---|
Returns the cross product / vector product of itself and another vector
vector_object:dist(other: vector)
: number
Returns the 3d distance to another vector
vector_object:dist(other: vector)
: number
Returns the 2d distance to another vector
vector_object:dot()
: number
Returns the dot product of the vector
vector_object:init(x: number, y: number, z: number)
: vector
Overwrites the X, Y and Z coordinates of the vector object, returning itself
vector_object:init_from_angles(pitch: number, yaw: number[, roll: number])
: vector
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()
: number
Returns the length (magnitude)
vector_object:length2d()
: number
Returns the 2d length (X and Y components)
vector_object:length2dsqr()
: number
Returns the squared 2d length (X and Y components, faster than :length2d)
vector_object:lengthsqr()
: number
Returns the squared length (faster than :length)
vector_object:lerp(to: vector, percentage: number)
: vector
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()
: vector
Returns a new unit vector, divided it by it's own length
vector_object:scale(scalar: number)
Scales the vector by the specified value.
vector_object:scaled(scalar: number)
: vector
Returns a new vector, scaled by the specified value.
vector_object:to(other: vector)
: vector
Returns the forward vector from itself to another vector
vector_object:unpack()
: number, number, number
Returns 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, vector
Returns the right and up vector of a forward vector
Argument | Type | Description |
---|---|---|
Argument | Type | Description |
---|---|---|
Argument | Type | Description |
---|---|---|
Argument | Type | Description |
---|---|---|
Argument | Type | Description |
---|---|---|
Argument | Type | Description |
---|---|---|
Argument | Type | Description |
---|---|---|
Argument | Type | Description |
---|---|---|
x
number
X coordinate of 3D position
y
number
Y coordinate of 3D position
z
number
Z coordinate of 3D position
other
vector
Other vector
other
vector
Vector to calculate the distance to
other
vector
Vector to calculate the distance to
x
number
X coordinate of 3D position
y
number
Y coordinate of 3D position
z
number
Z coordinate of 3D position
pitch
number
Pitch component of angle
yaw
number
Yaw component of angle
roll
number
Roll component of angle
to
vector
Vector to lerp to
percentage
number
Interpolation percentage (0-1)
scalar
number
Scalar value
scalar
number
Scalar value
other
vector
Other vector