Structs
vec2

vec2

Members

  • x: number
  • y: number

Operators

constructor

local v = vec2.new(2, 5)

+

local v = vec2.new(1, 2) + vec2.new(3, 2)
 
print(v) -- vec2(4, 4)

-

local v = vec2.new(1, 2) - vec2.new(1, 3)
 
print(v) -- vec2(0, -1)

*

local v = vec2.new(1, 2) * vec2.new(1, 3)
 
print(v) -- vec2(1, 6)

/

local v = vec2.new(2, 2) / vec2.new(2, 2)
local v2 = vec2.new(2, 2) / 2
 
print(v) -- vec2(1, 1)
print(v2) -- vec2(1, 1)

Functions

dist_to

ArgumentTypeRequired
othervec2+
returnsnumber
vec:dist_to(other)

add

ArgumentTypeRequired
othervec2+
returnsnumber
vec:add(other)

subtract

ArgumentTypeRequired
othervec2+
returnsnumber
vec:subtract(other)

multiply

ArgumentTypeRequired
othervec2+
returnsnumber
vec:multiply(other)

divide

ArgumentTypeRequired
othervec2+
returnsnumber
vec:divide(other)

dist_to_squared

dot

length

ArgumentTypeRequired
returnsnumber
vec:length()

length_squared

normalize

normalize_in_place

extend