Add includes query for region and point

This commit is contained in:
Danny Robson 2011-10-17 17:20:17 +11:00
parent d749be578a
commit b71049df85
2 changed files with 14 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>
bool
region<T>::includes (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 {

View File

@ -21,6 +21,8 @@
#ifndef __UTIL_REGION_HPP #ifndef __UTIL_REGION_HPP
#define __UTIL_REGION_HPP #define __UTIL_REGION_HPP
#include "point.hpp"
namespace util { namespace util {
/** /**
* A pure two-dimensional size, without positioning * A pure two-dimensional size, without positioning
@ -54,6 +56,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 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;