Add centre method to region

This commit is contained in:
Danny Robson 2011-10-20 23:53:18 +11:00
parent 0347936983
commit 1f4a744b29
2 changed files with 11 additions and 0 deletions

View File

@ -98,6 +98,16 @@ region<T>::empty (void) const
{ return almost_equal (area (), 0); } { return almost_equal (area (), 0); }
template <typename T>
point
region<T>::centre (void) const {
double cx = x + static_cast<T>(width / 2.0),
cy = y + static_cast<T>(height / 2.0);
return { cx, cy, 0.0 };
}
template <typename T> template <typename T>
bool bool
region<T>::includes (const point &p) const { region<T>::includes (const point &p) const {

View File

@ -56,6 +56,7 @@ namespace util {
T area (void) const; T area (void) const;
bool empty (void) const; bool empty (void) const;
point centre (void) const;
bool includes (const point&) const; // inclusive of borders bool includes (const point&) const; // inclusive of borders
bool contains (const point&) const; // exclusive of borders bool contains (const point&) const; // exclusive of borders