13 MatrixXf M = MatrixXf::Random(3, 100);
15 MatrixXf
q = MatrixXf::Random(3, 50);
28 indices.resize(5, q.cols());
29 dists2.resize(5, q.cols());
35 indices.resize(3, M.cols());
36 dists2.resize(3, M.cols());
40 for (
int i = 0; i < 100; ++i)
43 if (indices.coeff(0, i) != i)
44 cerr <<
"Oups, something went wrong: " << indices.coeff(0, i) <<
" " << i << endl;
50 indices.resize(2, M.cols());
51 dists2.resize(2, M.cols());
52 nns->
knn(M, indices, dists2, 2, 0.1, 0);
53 for (
int i = 0; i < 50; ++i)
56 if (indices.coeff(0, i) == i)
57 cerr <<
"Oups, something went wrong: " << indices.coeff(0, i) <<
" " << i << endl;
sort points by distances, when k > 1; do not sort by default
allows the return of the same point as the query, if this point is in the data cloud; forbidden by de...
Nearest neighbour search interface, templatized on scalar type.
static NearestNeighbourSearch * createKDTreeLinearHeap(const CloudType &cloud, const Index dim=std::numeric_limits< Index >::max(), const unsigned creationOptionFlags=0, const Parameters &additionalParameters=Parameters())
Create a nearest-neighbour search, using a kd-tree with linear heap, good for small k (~up to 30) ...
unsigned long knn(const Vector &query, IndexVector &indices, Vector &dists2, const Index k=1, const T epsilon=0, const unsigned optionFlags=0, const T maxRadius=std::numeric_limits< T >::infinity()) const
Find the k nearest neighbours of query.