diff --git a/region.cpp b/region.cpp index 7e956483..c50239e4 100644 --- a/region.cpp +++ b/region.cpp @@ -108,6 +108,16 @@ region::includes (const point &p) const { } +template +bool +region::contains (const point& p) const { + return p.x > x && + p.y > y && + p.x < x + width && + p.y < y + height; +} + + template bool region::overlaps (const region &rhs) const { diff --git a/region.hpp b/region.hpp index 83987967..788ec277 100644 --- a/region.hpp +++ b/region.hpp @@ -57,7 +57,8 @@ namespace util { T area (void) const; bool empty (void) const; - bool includes (const point&) const; + bool includes (const point&) const; // inclusive of borders + bool contains (const point&) const; // exclusive of borders bool overlaps (const region&) const; bool operator ==(const region& rhs) const;