wow
This commit is contained in:
parent
73b432d0c8
commit
2425729a72
@ -1,5 +1,6 @@
|
||||
#include "kd_tree.h"
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
KdTree::Point::Point(): x{0}, y{0}, z{0} {}
|
||||
KdTree::Point::Point(double x, double y, double z): x{x}, y{y}, z{z} {}
|
||||
@ -40,7 +41,7 @@ void KdTree::fill(std::vector<Tuple> &points) {
|
||||
KdTree::Node *KdTree::fillRec(std::size_t begin, std::size_t end, int axis) {
|
||||
if(end <= begin) return nullptr;
|
||||
|
||||
size_t n = begin + (end - begin) / 2;
|
||||
std::size_t n = begin + (end - begin) / 2;
|
||||
auto i = nodes.begin();
|
||||
std::nth_element(i + begin, i + n, i + end, [&](Node &p1, Node &p2) {
|
||||
return p1.position[axis] < p2.position[axis];
|
||||
@ -54,7 +55,7 @@ KdTree::Node *KdTree::fillRec(std::size_t begin, std::size_t end, int axis) {
|
||||
}
|
||||
|
||||
KdTree::Point KdTree::query(Point const &point) {
|
||||
bestDist = 99999.;
|
||||
bestDist = std::numeric_limits<double>::max();
|
||||
bestNode = nullptr;
|
||||
queryRec(root, point, 0);
|
||||
return bestNode->position;
|
||||
|
Loading…
Reference in New Issue
Block a user