Add overlaps query for regions

This commit is contained in:
Danny Robson 2011-10-10 22:37:27 +11:00
parent ed33f3ebce
commit e8c9e1a11f
2 changed files with 10 additions and 0 deletions

View File

@ -98,6 +98,15 @@ region<T>::empty (void) const
{ return almost_equal (area (), 0); }
template <typename T>
bool
region<T>::overlaps (const region<T> &rhs) const {
return x < rhs.x + rhs.width &&
x + width > rhs.x &&
y < rhs.y + rhs.height &&
y + height > rhs.y;
}
template <typename T>
bool
region<T>::operator ==(const region& rhs) const

View File

@ -54,6 +54,7 @@ namespace util {
T area (void) const;
bool empty (void) const;
bool overlaps (const region<T>&) const;
bool operator ==(const region<T>& rhs) const;
bool operator !=(const region<T>& rhs) const