diff --git a/modules/vec2.lua b/modules/vec2.lua index 7140d0f..e21ec19 100644 --- a/modules/vec2.lua +++ b/modules/vec2.lua @@ -78,8 +78,14 @@ function vector.__mul(a,b) end function vector.__div(a,b) - assert(isvector(a) and type(b) == "number", "wrong argument types (expected / )") - return new(a.x / b, a.y / 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) + else + assert(isvector(a) and isvector(b), "Div: wrong argument types ( or expected)") + return new(a.x/b.x, a.y/b.y) + end end function vector.__eq(a,b) diff --git a/modules/vec3.lua b/modules/vec3.lua index d9b9cf6..afd550b 100644 --- a/modules/vec3.lua +++ b/modules/vec3.lua @@ -88,8 +88,14 @@ function vector.__mul(a,b) end function vector.__div(a,b) - assert(isvector(a) and type(b) == "number", "wrong argument types (expected / )") - return new(a.x / b, a.y / b, a.z / b) + if type(a) == "number" then + return new(a / b.x, a / b.y, a / b.z) + elseif type(b) == "number" then + return new(a.x / b, a.y / b, a.z / b) + else + assert(isvector(a) and isvector(b), "Div: wrong argument types ( or expected)") + return new(a.x/b.x, a.y/b.y, a.z/b.z) + end end function vector.__eq(a,b)