Add region::contains method
This commit is contained in:
parent
2aee108e79
commit
0347936983
10
region.cpp
10
region.cpp
@ -108,6 +108,16 @@ region<T>::includes (const point &p) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool
|
||||||
|
region<T>::contains (const point& p) const {
|
||||||
|
return p.x > x &&
|
||||||
|
p.y > y &&
|
||||||
|
p.x < x + width &&
|
||||||
|
p.y < y + height;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool
|
bool
|
||||||
region<T>::overlaps (const region<T> &rhs) const {
|
region<T>::overlaps (const region<T> &rhs) const {
|
||||||
|
@ -57,7 +57,8 @@ namespace util {
|
|||||||
T area (void) const;
|
T area (void) const;
|
||||||
bool empty (void) const;
|
bool empty (void) const;
|
||||||
|
|
||||||
bool includes (const point&) const;
|
bool includes (const point&) const; // inclusive of borders
|
||||||
|
bool contains (const point&) const; // exclusive of borders
|
||||||
bool overlaps (const region<T>&) const;
|
bool overlaps (const region<T>&) const;
|
||||||
|
|
||||||
bool operator ==(const region<T>& rhs) const;
|
bool operator ==(const region<T>& rhs) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user