aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-11-23 20:48:35 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-18 19:34:21 +0100
commitf12ecf7f9de6eb140e662f16483893689aa776b0 (patch)
tree09637144c0935b704937aaaeceed56534da846d1 /src/utils
parent579463633c120d5097aae00083ceff5970170114 (diff)
downloadusdx-f12ecf7f9de6eb140e662f16483893689aa776b0.tar.gz
usdx-f12ecf7f9de6eb140e662f16483893689aa776b0.tar.xz
usdx-f12ecf7f9de6eb140e662f16483893689aa776b0.zip
utils/rectangle: add is_in(Point)
Add possibility to check whether a Point is inside the rectangle.
Diffstat (limited to '')
-rw-r--r--src/utils/rectangle.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/utils/rectangle.hpp b/src/utils/rectangle.hpp
index 5ea2787f..1d8abda2 100644
--- a/src/utils/rectangle.hpp
+++ b/src/utils/rectangle.hpp
@@ -163,6 +163,21 @@ namespace usdx
this->point2 = Point<T>(left + width, top + height);
return *this;
}
+
+ bool is_in(const Point<T>& p) const
+ {
+ if (p.get_x() < get_left())
+ return false;
+ if (p.get_x() > get_right())
+ return false;
+
+ if (p.get_y() < get_top())
+ return false;
+ if (p.get_y() > get_bottom())
+ return false;
+
+ return true;
+ }
};
};