vec3

Constructors

NamePrototype
newfunction(): vec3
newfunction(x: float, y: float, z: float): vec3

Metamethods

NamePrototype
__eqfunction(rhs: vec3): bool
__ltfunction(rhs: vec3): bool
__lefunction(rhs: vec3): bool
__addfunction(rhs: float|vec3): vec3 --[[scalar & vector]]
__subfunction(rhs: float|vec3): vec3 --[[scalar & vector]]
__mulfunction(rhs: float|vec3): vec3 --[[scalar & vector]]
__divfunction(rhs: float|vec3): vec3 --[[scalar & vector]]
__idivfunction(rhs: float|vec3): vec3 --[[scalar & vector]]

Members

NameType
xfloat
yfloat
zfloat

Methods

dot

Returns the dot product of two vectors

function vec3.dot(other: vec3): float
-- example usage
local dot = vec:dot(other_vec)

cross

Returns the cross product of two vectors

function vec3.cross(other: vec3): vec3
-- example usage
local cross = vec:cross(other_vec)

to_radians

Converts a rotation vector from degrees to radians

function vec3.to_radians(): void
-- example usage
vec:to_radians()

to_degrees

Converts a rotation vector from radians to degrees

function vec3.to_degrees(): void
-- example usage
vec:to_degrees()

distance_to

Returns the distance between two vectors

function vec3.distance_to(other: vec3): float
-- example usage
local dist = vec:distance_to(other_vec)

magnitude

Returns the magnitude of a vector

function vec3.magnitude(): float
-- example usage
local mag = vec:magnitude()

min_component

Returns the smallest component of a vector

function vec3.min_component(): float
-- example usage
local min = vec:min_component()

max_component

Returns the largest component of a vector

function vec3.max_component(): float
-- example usage
local max = vec:max_component()

normalize

Converts a vector to a unit vector

function vec3.normalize(): void
-- example usage
vec:normalize()

is_null

Returns true if all components of a vector are zero

function vec3.is_null(): bool
-- example usage
local null = vec:is_null()