diff --git a/src/kd_tree.cc b/src/kd_tree.cc index c68e94b..fd3bc5d 100644 --- a/src/kd_tree.cc +++ b/src/kd_tree.cc @@ -1,5 +1,6 @@ #include "kd_tree.h" #include +#include KdTree::Point::Point(): x{0}, y{0}, z{0} {} KdTree::Point::Point(double x, double y, double z): x{x}, y{y}, z{z} {} @@ -19,7 +20,7 @@ double KdTree::Point::dist2(Point const &other) const { return x_ * x_ + y_ * y_ + z_ * z_; } -ostream& operator<<(ostream& os, KdTree::Point const & point) { +ostream& operator<<(ostream &os, KdTree::Point const &point) { os << "[" << point.x << ", " << point.y << ", " << point.z << "]"; return os; } @@ -40,7 +41,7 @@ void KdTree::fill(std::vector &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::max(); bestNode = nullptr; queryRec(root, point, 0); return bestNode->position; diff --git a/src/kd_tree.h b/src/kd_tree.h index 6aebaa6..e8232b1 100644 --- a/src/kd_tree.h +++ b/src/kd_tree.h @@ -20,7 +20,7 @@ public: double operator[] (std::size_t i) const; double dist2(Point const &other) const; - friend ostream& operator<<(ostream& os, Point const & point); + friend ostream& operator<<(ostream &os, Point const &point); }; using Tuple = std::pair;