Merge pull request #102 from qwertystop/master

Add floor division to hump.vector and hump.vector-light
This commit is contained in:
Matthias Richter 2018-05-27 11:39:03 +02:00 committed by GitHub
commit 38d0e5c060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -38,6 +38,10 @@ local function div(s, x,y)
return x/s, y/s
end
local function idiv(s, x,y)
return x//s, y//s
end
local function add(x1,y1, x2,y2)
return x1+x2, y1+y2
end

View File

@ -97,6 +97,11 @@ function vector.__div(a,b)
return new(a.x / b, a.y / b)
end
function vector.__idiv(a,b)
assert(isvector(a) and type(b) == "number", "wrong argument types (expected <vector> / <number>)")
return new(a.x // b, a.y // b)
end
function vector.__eq(a,b)
return a.x == b.x and a.y == b.y
end