Types
vec3
Constructors
| Name | Prototype |
|---|---|
new | function(): vec3 |
new | function(x: float, y: float, z: float): vec3 |
Metamethods
| Name | Prototype |
|---|---|
__eq | function(rhs: vec3): bool |
__lt | function(rhs: vec3): bool |
__le | function(rhs: vec3): bool |
__add | function(rhs: float|vec3): vec3 --[[scalar & vector]] |
__sub | function(rhs: float|vec3): vec3 --[[scalar & vector]] |
__mul | function(rhs: float|vec3): vec3 --[[scalar & vector]] |
__div | function(rhs: float|vec3): vec3 --[[scalar & vector]] |
__idiv | function(rhs: float|vec3): vec3 --[[scalar & vector]] |
Members
| Name | Type |
|---|---|
x | float |
y | float |
z | float |
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()