diff --git a/region.cpp b/region.cpp index a8c81895..5bfcd02a 100644 --- a/region.cpp +++ b/region.cpp @@ -38,6 +38,16 @@ region::region (T _x, T _y, T _width, T _height): { ; } +template +region& +region::operator+= (const vector &rhs) { + x += rhs.x; + y += rhs.y; + + return *this; +} + + template T region::area (void) const @@ -57,6 +67,13 @@ region::empty (void) const { return almost_equal (area (), 0); } +template +point +region::base (void) const { + return { static_cast (x), static_cast (y), 0.0 }; +} + + template point region::centre (void) const { diff --git a/region.hpp b/region.hpp index 7da7e687..4da5b181 100644 --- a/region.hpp +++ b/region.hpp @@ -34,11 +34,14 @@ namespace util { region (T _x, T _y, T _width, T _height); + region& operator +=(const vector& rhs); + T area (void) const; T diameter (void) const; bool empty (void) const; + point base (void) const; point centre (void) const; bool includes (const point&) const; // inclusive of borders