diff --git a/geom/plane.hpp b/geom/plane.hpp index d13aa2e5..f20a1ee6 100644 --- a/geom/plane.hpp +++ b/geom/plane.hpp @@ -94,4 +94,27 @@ namespace util::geom { { return -distance (q, p); } + + + /////////////////////////////////////////////////////////////////////////// + template + auto + furthest (plane p, const std::vector> &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 + auto + furthest (plane, std::vector> &&) = delete; }