vector
Interact with mathematical objects.
Functions:
Initialization
vector(float: x, float: y, float: z)The constructor vector(float x, float y, float z) initializes a vector with the specified x, y, and z.
Equal
vector:is_equal(vector)Returns true if the current vector is equal to another vector.
Zero
vector:is_zero()Returns true if all values of the vector are zero.
Scale
vector:scale(factor)Scales the vector by a given factor and returns a new vector with the scaled values, without modifying the original vector.
Length
vector:length()Calculates and returns the length (magnitude) of the vector.
Length 2D
vector:length_2d()Calculates and returns the 2D length (magnitude) of the vector, using only the x and y components.
Square Length
vector:length_sqr()Calculates and returns the squared length (magnitude) of the vector, which is the sum of the squares of its components.
Square Length 2D
vector:length_2f()Calculates and returns the squared length of the vector in 2D space, using only the x and y components.
Dot
vector:dot(vector)Calculates and returns the dot product of the current vector with another vector.
Cross
vector:cross(vector)Computes and returns the cross product of the current vector with another vector.
Distance
vector:dist_to(vector)Calculates and returns the distance between the current vector and another vector.
Unpack
vector:unpack()Returns the vector's components (e.g., x, y, z)
Normalize
vector:normalize()Normalizes the vector (scales it to a unit length) and returns the result. If the vector has zero length, it returns the original vector unchanged.
Last updated