vector3

From Teverse

A vector3 represents a single point in 3D space.

Constructors

vector3

vector3 vector3(number x, number y, number z) Creates a vector3 containing the coordinates x, y, and z.

Example:

local vector = vector3(1, 1, 1)
print(vector)

This would output 1,1,1

Properties

x

Type: number
The x-coordinate.

y

Type: number
The y-coordinate.

z

Type: number
The z-coordinate.

Operators

vector3 + vector3

Adds two vector3s together and returns a new vector3 with the coordinates combined.

vector3 - vector3

Subtracts two vector3s and returns a new vector3.

vector3 * vector3

vector3 / vector3

Methods

cross

vector3 vector3:cross(vector3 other)

dot

number vector3:dot(vector3 other)

length

number vector3:length()
Returns the length or magnitude.

lerp

vector3 vector3:lerp(vector3 target, number t)
returns an interpolated copy of the vector3.
t is clamped between 0 and 1. If t is 0, the returned vector3 will be unchanged. If t is 1, the returned vector3 will be target

.

max

vector3 vector3:max(vector3 vector)
Returns a new vector3 composed of the largest component of this vector3 and the vector3 provided.
Example:
local vector = vector3(1, 1, 1)
local otherVector = vector3(2, 2, 0)
local newVector = vector:max(otherVector) -- 2, 2, 1

min

vector3 vector3:min(vector3 vector)
Returns a new vector3 composed of the smallest component of this vector3 and the vector3 provided.
Example:
local vector = vector3(1, 1, 1)
local otherVector = vector3(2, 2, 0)
local newVector = vector:min(otherVector) -- 1, 1, 0

normal

vector3 vector3:normal()