-
Notifications
You must be signed in to change notification settings - Fork 6
Point search with a quadtree
Martijn Koopman edited this page Jun 8, 2019
·
2 revisions
Given a set of points in 2D space. Construct a quadtree and perform a point search.
Input points: (0,0), (10,10), (8.5,8.5), (8.5,9.5), (9.5,8.5), (4,1), (9,4)
Tree
0-0
0-1
0-2
0 ----- 0-3
1
root -- 2
3 ----- 3-0
3-1
3-2
3-3 --- 3-3-0
3-3-1
3-3-2
3-3-3
C++
// Input points
std::vector<std::array<double, 2>> points = { {0,0}, {10,10}, {8.5,8.5}, {8.5,9.5}, {9.5,8.5}, {4,1}, {9,4} };
// Construct tree
auto tree = idx::PointQuadtree::buildFromPoints(points, 1);
// Find points (Not implemented yet)
// std::vector<std::array<double, 2>> ps = tree.findPoints({8,8}, 1.5);
//
// for(auto it = tree.findPointsIterator({8,8}, 1.5); it.hasNext(); it.next())
//{
// std::array<double,2> p = *it;
//}