Add manhattan closest calculation
This commit is contained in:
parent
7849001750
commit
0e36781721
15
region.cpp
15
region.cpp
@ -102,6 +102,21 @@ region<T>::centre (void) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
point<2>
|
||||||
|
region<T>::closest (point<2> p) const {
|
||||||
|
return {
|
||||||
|
p.x < x ? x :
|
||||||
|
p.x > x + w ? x + w :
|
||||||
|
p.x,
|
||||||
|
|
||||||
|
p.y < y ? y :
|
||||||
|
p.y < y + h ? y + h :
|
||||||
|
p.y
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool
|
bool
|
||||||
|
@ -50,8 +50,9 @@ namespace util {
|
|||||||
|
|
||||||
bool empty (void) const;
|
bool empty (void) const;
|
||||||
|
|
||||||
point2 base (void) const;
|
point2 base (void) const;
|
||||||
point2 centre (void) const;
|
point2 centre (void) const;
|
||||||
|
point2 closest (point2) const;
|
||||||
|
|
||||||
bool includes (const point2&) const; // inclusive of borders
|
bool includes (const point2&) const; // inclusive of borders
|
||||||
bool contains (const point2&) const; // exclusive of borders
|
bool contains (const point2&) const; // exclusive of borders
|
||||||
|
Loading…
Reference in New Issue
Block a user