Thunderbots Project
Loading...
Searching...
No Matches
nearest_neighbor_search.hpp
1#pragma once
2
3#include <vector>
4
20template <class T, typename Func>
21std::vector<T> findNeighboursInThreshold(const T& candidate,
22 const std::vector<T>& neighbors,
23 double threshold, Func distanceFunc)
24{
25 std::vector<T> subset;
26 for (const T& neighbor : neighbors)
27 {
28 if (distanceFunc(candidate, neighbor) <= threshold)
29 {
30 subset.push_back(neighbor);
31 }
32 }
33 return subset;
34}