Go to the documentation of this file.
45 ifstream ifs(fileName);
56 ifs.getline(line,
sizeof(line));
57 line[
sizeof(line)-1] = 0;
59 char *token = strtok(line,
" \t,;");
64 data.push_back(atof(token));
66 token = strtok(NULL,
" \t,;");
71 return Matrix::Map(&data[0], dim, data.size() / dim);
77 if (coord.size() == 2)
79 <<
"<circle cx=\"" << zoom*coord(0)
80 <<
"\" cy=\"" << zoom*coord(1)
81 <<
"\" r=\"" << ptSize
82 <<
"\" stroke-width=\"" << 0.2 * ptSize
83 <<
"\" " << style <<
"/>" << endl;
88 int main(
int argc,
char* argv[])
95 typedef Nabo::KDTree<float> KDTF;
99 cerr <<
"Usage " << argv[0] <<
" DATA" << endl;
103 Matrix
d(load<float>(argv[1]));
111 const int itCount(100);
112 for (
int i = 0; i < itCount; ++i)
117 Vector
q(
d.col(rand() %
d.cols()));
120 Indexes indexes_bf(bfs.
knn(
q, K,
false));
122 Indexes indexes_kdtree(kdt.knn(
q, K,
false));
124 if (ndexes_bf.size() != indexes_kdtree.size())
126 assert(indexes_bf.size() == indexes_kdtree.size());
127 assert(indexes_bf.size() == K);
129 for (
size_t j = 0; j < K; ++j)
131 Vector pbf(
d.col(indexes_bf[j]));
132 Vector pkdtree(
d.col(indexes_kdtree[j]));
135 assert(indexes_bf[j] == indexes_kdtree[j]);
136 assert(
dist2(pbf, pkdtree) < numeric_limits<float>::epsilon());
139 cerr <<
"stats kdtree: "
140 << kdt.getStatistics().totalVisitCount <<
" on "
141 << itCount *
d.cols() <<
" ("
142 << double(100 * kdt.getStatistics().totalVisitCount) / double(itCount *
d.cols()) <<
" %"
virtual unsigned long knn(const Matrix &query, IndexMatrix &indices, Matrix &dists2, const Index k, const T epsilon, const unsigned optionFlags, const T maxRadius) const
void dumpCoordinateForSVG(const typename NearestNeighbourSearch< T >::Vector coord, const float zoom=1, const float ptSize=1, const char *style="stroke=\"black\" fill=\"red\"")
int main(int argc, char *argv[])
NearestNeighbourSearch< T >::Matrix load(const char *fileName)
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
a column-major Eigen matrix in which each column is a point; this matrix has dim rows
Nabo::BruteForceSearch< float > BFSF
Nearest neighbour search interface, templatized on scalar type.
T dist2(const A &v0, const B &v1)
Euclidean distance.
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
an Eigen vector of type T, to hold the coordinates of a point
int Index
an index to a Vector or a Matrix, for refering to data points
Brute-force nearest neighbour.
mp2p_icp
Author(s):
autogenerated on Thu Dec 26 2024 03:48:12