Vector4

A vector that holds 4 numbers
Can be created using functions in the "vectors" api
Meta name Allowed other parameters Meta execution method
__le
  • Vector4
x <= y
__lt
  • Vector4
x < y
__len
#x
__unm
-x
__eq
  • Vector4
x == y
__mod
  • Number
  • Vector4
x % y
__div
  • Number
  • Vector4
x / y
__mul
  • Number
  • Vector4
  • Matrix4
x * y
__add
  • Vector4
x + y
__sub
  • Vector4
x - y

Vector4.add

Adds the given vector or values to this one, and returns self for chaining
overload 1:
Vector4:add(vec)
Method Property Fluent Description Representation
vec accepts a Vector4
Return Value a Vector4
overload 2:
Vector4:add(x, y, z, w)
Method Property Fluent Description Representation
x accepts a Number
y accepts a Number
z accepts a Number
w accepts a Number
Return Value a Vector4

Vector4.length

Returns the length of this vector
overload 1:
Vector4:length()
Method Property Fluent Description Representation
Return Value a Number

Vector4.floor

Returns a copy of this vector with its values rounded down
overload 1:
Vector4:floor()
Method Property Fluent Description Representation
Return Value a Vector4

Vector4.ceil

Returns a copy of this vector with its values rounded up
overload 1:
Vector4:ceil()
Method Property Fluent Description Representation
Return Value a Vector4

Vector4.scale

Scales this vector by the given factor, and returns self for chaining
overload 1:
Vector4:scale(factor)
Method Property Fluent Description Representation
factor accepts a Number
Return Value a Vector4

Vector4.offset

Offsets this vector by the given factor, adding the factor to all components, and returns self for chaining
overload 1:
Vector4:offset(factor)
Method Property Fluent Description Representation
factor accepts a Number
Return Value a Vector4

Vector4.transform

Transforms this vector by the given matrix, and returns self for chaining
overload 1:
Vector4:transform(mat)
Method Property Fluent Description Representation
mat accepts a Matrix4
Return Value a Vector4

Vector4.dot

Returns the dot product of this vector with the other
overload 1:
Vector4:dot(vec)
Method Property Fluent Description Representation
vec accepts a Vector4
Return Value a Number

Vector4.set

Sets this vector to have the given values
Nil values are treated as zero
Returns self for chaining
overload 1:
Vector4:set(vec)
Method Property Fluent Description Representation
vec accepts a Vector4
Return Value a Vector4
overload 2:
Vector4:set(x, y, z, w)
Method Property Fluent Description Representation
x accepts a Number
y accepts a Number
z accepts a Number
w accepts a Number
Return Value a Vector4

Vector4.copy

Creates and returns a copy of this vector
overload 1:
Vector4:copy()
Method Property Fluent Description Representation
Return Value a Vector4

Vector4.normalize

Modifies this vector so that its length is 1 unless its length was originally 0
Returns self for chaining
overload 1:
Vector4:normalize()
Method Property Fluent Description Representation
Return Value a Vector4

Vector4.reset

Resets this vector back to being all zeroes, and returns itself for chaining
overload 1:
Vector4:reset()
Method Property Fluent Description Representation
Return Value a Vector4

Vector4.reduce

Reduces this vector modulo the given vector or values, and returns self for chaining
overload 1:
Vector4:reduce(vec)
Method Property Fluent Description Representation
vec accepts a Vector4
Return Value a Vector4
overload 2:
Vector4:reduce(x, y, z, w)
Method Property Fluent Description Representation
x accepts a Number
y accepts a Number
z accepts a Number
w accepts a Number
Return Value a Vector4

Vector4.normalized

Returns a copy of this vector with length 1 unless its length was originally 0
overload 1:
Vector4:normalized()
Method Property Fluent Description Representation
Return Value a Vector4

Vector4.sub

Subtracts the given vector or values from this one, and returns self for chaining
overload 1:
Vector4:sub(vec)
Method Property Fluent Description Representation
vec accepts a Vector4
Return Value a Vector4
overload 2:
Vector4:sub(x, y, z, w)
Method Property Fluent Description Representation
x accepts a Number
y accepts a Number
z accepts a Number
w accepts a Number
Return Value a Vector4

Vector4.mul

Multiplies the given vector or values into this one, and returns self for chaining
overload 1:
Vector4:mul(vec)
Method Property Fluent Description Representation
vec accepts a Vector4
Return Value a Vector4
overload 2:
Vector4:mul(x, y, z, w)
Method Property Fluent Description Representation
x accepts a Number
y accepts a Number
z accepts a Number
w accepts a Number
Return Value a Vector4

Vector4.div

Divides this vector by the given vector or values, and returns self for chaining
overload 1:
Vector4:div(vec)
Method Property Fluent Description Representation
vec accepts a Vector4
Return Value a Vector4
overload 2:
Vector4:div(x, y, z, w)
Method Property Fluent Description Representation
x accepts a Number
y accepts a Number
z accepts a Number
w accepts a Number
Return Value a Vector4

Vector4.unpack

Returns this vector's values as separate numbers
overload 1:
Vector4:unpack()
Method Property Fluent Description Representation
Return Value a Varargs

Vector4.clamped

Returns a modified copy of this vector, with its length clamped from minLength to maxLength
If the vector has length zero,
then the copy does too
overload 1:
Vector4:clamped(minLength, maxLength)
Method Property Fluent Description Representation
minLength accepts a Number
maxLength accepts a Number
Return Value a Vector4

Vector4.clampLength

Modifies this vector so that its length is between minLength and maxLength
If the vector has length zero,
it is unmodified
Returns self for chaining
overload 1:
Vector4:clampLength(minLength, maxLength)
Method Property Fluent Description Representation
minLength accepts a Number
maxLength accepts a Number
Return Value a Vector4

Vector4.toDeg

Returns a copy of this vector, in degrees
overload 1:
Vector4:toDeg()
Method Property Fluent Description Representation
Return Value a Vector4

Vector4.applyFunc

Calls the given function on each element of this vector, and sets the values of the vector to the returns
The current index and its value is given as arguments of the function
Returns self for chaining
overload 1:
Vector4:applyFunc(func)
Method Property Fluent Description Representation
func accepts a function that takes a Number and an Integer and will return a Number
Return Value a Vector4

Vector4.toRad

Returns a copy of this vector, in radians
overload 1:
Vector4:toRad()
Method Property Fluent Description Representation
Return Value a Vector4

Vector4.lengthSquared

Returns the length of this vector squared
Suitable when you only care about relative lengths,
because it avoids a square root
overload 1:
Vector4:lengthSquared()
Method Property Fluent Description Representation
Return Value a Number

Vector4.x

The first coordinate of this vector
Can also be gotten with the indices "r" and [1]
field signature:
x
Method Property Fluent Description Representation
Field Type a Number

Vector4.y

The second coordinate of this vector
Can also be gotten with the indices "g" and [2]
field signature:
y
Method Property Fluent Description Representation
Field Type a Number

Vector4.z

The third coordinate of this vector
Can also be gotten with the indices "b" and [3]
field signature:
z
Method Property Fluent Description Representation
Field Type a Number

Vector4.w

The fourth coordinate of this vector
Can also be gotten with the indices "a" and [4]
field signature:
w
Method Property Fluent Description Representation
Field Type a Number
a a