Add more operators to region
This commit is contained in:
parent
d1187ecf3a
commit
f7075fd9d2
17
region.cpp
17
region.cpp
@ -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 {
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user