diff --git a/region.cpp b/region.cpp index c50239e4..5e9a67c4 100644 --- a/region.cpp +++ b/region.cpp @@ -98,6 +98,16 @@ region::empty (void) const { return almost_equal (area (), 0); } +template +point +region::centre (void) const { + double cx = x + static_cast(width / 2.0), + cy = y + static_cast(height / 2.0); + + return { cx, cy, 0.0 }; +} + + template bool region::includes (const point &p) const { diff --git a/region.hpp b/region.hpp index 788ec277..cb47d3bc 100644 --- a/region.hpp +++ b/region.hpp @@ -56,6 +56,7 @@ namespace util { T area (void) const; bool empty (void) const; + point centre (void) const; bool includes (const point&) const; // inclusive of borders bool contains (const point&) const; // exclusive of borders