Go to the documentation of this file.00001
00002
00003 #include "nabo/nabo.h"
00004 #include <iostream>
00005
00006 int main()
00007 {
00008 using namespace Nabo;
00009 using namespace Eigen;
00010 using namespace std;
00011
00012
00013 MatrixXf M = MatrixXf::Random(3, 100);
00014
00015 MatrixXf q = MatrixXf::Random(3, 50);
00016
00017
00018 NNSearchF* nns = NNSearchF::createKDTreeLinearHeap(M);
00019
00020
00021
00022
00023 MatrixXi indices;
00024 MatrixXf dists2;
00025
00026
00027
00028 indices.resize(5, q.cols());
00029 dists2.resize(5, q.cols());
00030 nns->knn(q, indices, dists2, 5, 0, NNSearchF::SORT_RESULTS);
00031
00032
00033
00034
00035 indices.resize(3, M.cols());
00036 dists2.resize(3, M.cols());
00037 nns->knn(M, indices, dists2, 3, 0, NNSearchF::SORT_RESULTS | NNSearchF::ALLOW_SELF_MATCH);
00038
00039
00040 for (int i = 0; i < 100; ++i)
00041 {
00042
00043 if (indices.coeff(0, i) != i)
00044 cerr << "Oups, something went wrong: " << indices.coeff(0, i) << " " << i << endl;
00045 }
00046
00047
00048
00049
00050 indices.resize(2, M.cols());
00051 dists2.resize(2, M.cols());
00052 nns->knn(M, indices, dists2, 2, 0.1, 0);
00053 for (int i = 0; i < 50; ++i)
00054 {
00055
00056 if (indices.coeff(0, i) == i)
00057 cerr << "Oups, something went wrong: " << indices.coeff(0, i) << " " << i << endl;
00058 }
00059
00060
00061 delete nns;
00062
00063 return 0;
00064 }