summaryrefslogtreecommitdiff
path: root/math.lua
diff options
context:
space:
mode:
Diffstat (limited to 'math.lua')
-rw-r--r--math.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/math.lua b/math.lua
index dc5ba64..429e1ab 100644
--- a/math.lua
+++ b/math.lua
@@ -14,6 +14,10 @@ Vec2.__div = function(a, b)
end
Vec2.__tostring = function(a) return "(" .. fmt(a.x) .. "," .. fmt(a.y) .. ")" end
+function Vec2:in_bounds(low, hi)
+ return self.x >= low.x and self.x <= hi.x and self.y >= low.y and self.y <= hi.y
+end
+
function Vec2:magnitude()
return sqrt(self.x * self.x + self.y * self.y)
end