forked from crvs/KDTree
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_kdtree.cpp
More file actions
78 lines (61 loc) · 1.47 KB
/
test_kdtree.cpp
File metadata and controls
78 lines (61 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <iostream>
#include <vector>
#include "KDTree.hpp"
// using point_t = std::vector< double >;
// using pointVec = std::vector< point_t >;
// point_t pt(2);
int main() {
pointVec points;
point_t pt;
pt = {0.0, 0.0};
points.push_back(pt);
pt = {1.0, 0.0};
points.push_back(pt);
pt = {0.0, 1.0};
points.push_back(pt);
pt = {1.0, 1.0};
points.push_back(pt);
pt = {0.5, 0.5};
points.push_back(pt);
KDTree tree(points);
std::cout << "nearest test\n";
pt = {0.8, 0.2};
auto res = tree.nearest_point(pt);
for (double b : res) {
std::cout << b << " ";
}
std::cout << '\n';
/*
std::cout << "going down the tree\n";
for (auto b : point_t(*tree)) {
std::cout << b << " ";
}
std::cout << '\n';
for (auto b : point_t(*tree->left)) {
std::cout << b << " ";
}
std::cout << '\n';
for (auto b : point_t(*tree->right)) {
std::cout << b << " ";
}
std::cout << '\n';
for (auto b : point_t(*tree->left->left)) {
std::cout << b << " ";
}
std::cout << '\n';
for (auto b : point_t(*tree->right->left)) {
std::cout << b << " ";
}
std::cout << '\n';
std::cout << "printing nbh\n";
pt = {.0, .5};
*/
auto res2 = tree.neighborhood_points(pt, .55);
for (point_t a : res2) {
for (double b : a) {
std::cout << b << " ";
}
std::cout << '\n';
}
return 0;
}