template<typename CRTP, typename Coordinate, std::size_t Dimension, typename Region = BoundingRegion<Coordinate>, typename Distance = SquaredDistance<Coordinate, Dimension>, typename NodeCmp = NodeCmp<Dimension>>
class maliput::math::details::KDTreeBase< CRTP, Coordinate, Dimension, Region, Distance, NodeCmp >
KDTree provides a space-partitioning data structure for organizing points in a k-dimensional space.
The tree is built from a set of points, where each point is a vector of length k. The tree is built balanced, to guarantee an average of O(log(n)) time for nearest-neighbor queries.
Inspired on https://rosettacode.org/wiki/K-d_tree.
- Template Parameters
-
CRTP | Derived class. It follows the curiously recurring template pattern. |
Coordinate | Data type being used, must have:
- operator[] for accessing the value in each dimension.
|
Dimension | Dimension of the KD-tree. |
Region | The type of the region. |
Distance | A functor used for getting the distance between two coordinates. By default, details::SquaredDistance is used. |
NodeCmp | A functor used for comparing two nodes at certain index/dimension. By default, details::NodeCmp is used. |
|
template<typename Iterator > |
| KDTreeBase (Iterator begin, Iterator end) |
| Constructs a KDTreeBase taking a pair of iterators. More...
|
|
template<typename Collection > |
| KDTreeBase (Collection &&points) |
| Constructs a KDTreeBase taking a vector of points. More...
|
|
const Coordinate & | nearest_point (const Coordinate &point) const |
| Finds the nearest point in the tree to the given point. More...
|
|
const Coordinate & | nearest_point (const Coordinate &point, double tolerance) const |
| Finds the nearest point in the tree to the given point. More...
|
|