geom/plane: add furthest point finder
This commit is contained in:
parent
87dda1c568
commit
6290f0be93
@ -94,4 +94,27 @@ namespace util::geom {
|
||||
{
|
||||
return -distance (q, p);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <size_t S, typename T>
|
||||
auto
|
||||
furthest (plane<S,T> p, const std::vector<util::point<S,T>> &cloud)
|
||||
{
|
||||
T maxd = -INFINITY;
|
||||
auto best = cloud.begin ();
|
||||
|
||||
for (auto q = cloud.begin (), last = cloud.end (); q != last; ++q) {
|
||||
if (auto d = distance (p, *q); d > maxd) {
|
||||
maxd = d;
|
||||
best = q;
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_tuple (best, maxd);
|
||||
}
|
||||
|
||||
template <size_t S, typename T>
|
||||
auto
|
||||
furthest (plane<S,T>, std::vector<util::point<S,T>> &&) = delete;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user