I'm an idiot
the order in which a and b appear actually matters in add/sub.
This commit is contained in:
parent
b2367b6382
commit
cda145629d
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user