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
Argument | Type | Required |
---|---|---|
other | vec2 | + |
returns | number |
vec:dist_to(other)
add
Argument | Type | Required |
---|---|---|
other | vec2 | + |
returns | number |
vec:add(other)
subtract
Argument | Type | Required |
---|---|---|
other | vec2 | + |
returns | number |
vec:subtract(other)
multiply
Argument | Type | Required |
---|---|---|
other | vec2 | + |
returns | number |
vec:multiply(other)
divide
Argument | Type | Required |
---|---|---|
other | vec2 | + |
returns | number |
vec:divide(other)
dist_to_squared
dot
length
Argument | Type | Required |
---|---|---|
returns | number |
vec:length()