Add centre method to region
This commit is contained in:
parent
0347936983
commit
1f4a744b29
10
region.cpp
10
region.cpp
@ -98,6 +98,16 @@ region<T>::empty (void) const
|
|||||||
{ return almost_equal (area (), 0); }
|
{ return almost_equal (area (), 0); }
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
point
|
||||||
|
region<T>::centre (void) const {
|
||||||
|
double cx = x + static_cast<T>(width / 2.0),
|
||||||
|
cy = y + static_cast<T>(height / 2.0);
|
||||||
|
|
||||||
|
return { cx, cy, 0.0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool
|
bool
|
||||||
region<T>::includes (const point &p) const {
|
region<T>::includes (const point &p) const {
|
||||||
|
@ -56,6 +56,7 @@ namespace util {
|
|||||||
|
|
||||||
T area (void) const;
|
T area (void) const;
|
||||||
bool empty (void) const;
|
bool empty (void) const;
|
||||||
|
point centre (void) const;
|
||||||
|
|
||||||
bool includes (const point&) const; // inclusive of borders
|
bool includes (const point&) const; // inclusive of borders
|
||||||
bool contains (const point&) const; // exclusive of borders
|
bool contains (const point&) const; // exclusive of borders
|
||||||
|
Loading…
Reference in New Issue
Block a user