I'm an idiot

the order in which a and b appear actually matters in add/sub.
This commit is contained in:
Landon Manning 2015-12-13 06:44:02 -04:00
parent b2367b6382
commit cda145629d
2 changed files with 4 additions and 4 deletions

View File

@ -68,7 +68,7 @@ function vector.__add(a,b)
if type(a) == "number" then
return new(a+b.x, a+b.y)
elseif type(b) == "number" then
return new(b+a.x, b+a.y)
return new(a.x+b, a.y+b)
else
assert(isvector(a) and isvector(b), "Add: wrong argument types (<vector> expected)")
return new(a.x+b.x, a.y+b.y)
@ -79,7 +79,7 @@ function vector.__sub(a,b)
if type(a) == "number" then
return new(a-b.x, a-b.y)
elseif type(b) == "number" then
return new(b-a.x, b-a.y)
return new(a.x-b, a.y-b)
else
assert(isvector(a) and isvector(b), "Sub: wrong argument types (<vector> expected)")
return new(a.x-b.x, a.y-b.y)

View File

@ -85,7 +85,7 @@ function vector.__add(a,b)
if type(a) == "number" then
return new(a+b.x, a+b.y, a+b.z)
elseif type(b) == "number" then
return new(b+a.x, b+a.y, b+a.z)
return new(a.x+b, a.y+b, a.z+b)
else
assert(isvector(a) and isvector(b), "Add: wrong argument types (<vector> expected)")
return new(a.x+b.x, a.y+b.y, a.z+b.z)
@ -96,7 +96,7 @@ function vector.__sub(a,b)
if type(a) == "number" then
return new(a-b.x, a-b.y, a-b.z)
elseif type(b) == "number" then
return new(b-a.x, b-a.y, b-a.z)
return new(a.x-b, a.y-b, a.z-b)
else
assert(isvector(a) and isvector(b), "Sub: wrong argument types (<vector> expected)")
return new(a.x-b.x, a.y-b.y, a.z-b.z)