Use # operator for vector length

This commit is contained in:
Quinn
2021-12-28 15:53:58 -08:00
parent 491d94d647
commit f473777684
4 changed files with 10 additions and 10 deletions
+2 -2
View File
@@ -15,8 +15,7 @@ vec2 = {
end,
normal = function(self)
local length = self:length()
return vec2:new(self.x/length, self.y/length)
return vec2:new(self.x/#self, self.y/#self)
end,
bounce = function(self, n)
@@ -41,6 +40,7 @@ vec2.__mul = function(o1,o2)
end
vec2.__div = function(v,s) return vec2:new(v.x/s,v.y/s) end
vec2.__unm = function(v) return vec2:new(-v.x,-v.y) end
vec2.__len = function(v) return v:length() end
vec2.__tostring = function(v) return "{x: "..v.x..",y: "..v.y.."}" end
vec2.__index = vec2