Add more operators to region

This commit is contained in:
Danny Robson 2011-10-26 21:43:55 +11:00
parent d1187ecf3a
commit f7075fd9d2
2 changed files with 20 additions and 0 deletions

View File

@ -38,6 +38,16 @@ region<T>::region (T _x, T _y, T _width, T _height):
{ ; } { ; }
template <typename T>
region<T>&
region<T>::operator+= (const vector &rhs) {
x += rhs.x;
y += rhs.y;
return *this;
}
template <typename T> template <typename T>
T T
region<T>::area (void) const region<T>::area (void) const
@ -57,6 +67,13 @@ region<T>::empty (void) const
{ return almost_equal (area (), 0); } { return almost_equal (area (), 0); }
template <typename T>
point
region<T>::base (void) const {
return { static_cast<double> (x), static_cast<double> (y), 0.0 };
}
template <typename T> template <typename T>
point point
region<T>::centre (void) const { region<T>::centre (void) const {

View File

@ -34,11 +34,14 @@ namespace util {
region (T _x, T _y, T _width, T _height); region (T _x, T _y, T _width, T _height);
region& operator +=(const vector& rhs);
T area (void) const; T area (void) const;
T diameter (void) const; T diameter (void) const;
bool empty (void) const; bool empty (void) const;
point base (void) const;
point centre (void) const; point centre (void) const;
bool includes (const point&) const; // inclusive of borders bool includes (const point&) const; // inclusive of borders