diff --git a/region.cpp b/region.cpp index 52ade9b4..d305dea2 100644 --- a/region.cpp +++ b/region.cpp @@ -23,6 +23,7 @@ #include "enable_if.hpp" #include "debug.hpp" +#include #include using namespace util; @@ -37,6 +38,13 @@ extent::extent (const T _width, const T _height): { ; } +template +T +extent::diameter (void) const { + return (T)sqrt (width * width + height * height); +} + + template T extent::area (void) const @@ -92,6 +100,13 @@ region::area (void) const { return width * height; } +template +T +region::diameter (void) const { + return (T)sqrt (width * width + height * height); +} + + template bool region::empty (void) const diff --git a/region.hpp b/region.hpp index 3eb73984..a8e6f46a 100644 --- a/region.hpp +++ b/region.hpp @@ -34,6 +34,8 @@ namespace util { extent (const T _width, const T _height); T area (void) const; + T diameter (void) const; + bool empty (void) const; bool operator ==(const extent& rhs) const; @@ -54,8 +56,11 @@ namespace util { region (T _x, T _y, T _width, T _height); - T area (void) const; + T area (void) const; + T diameter (void) const; + bool empty (void) const; + point centre (void) const; bool includes (const point&) const; // inclusive of borders