|
template<class TDerivedP> |
| KdTree (Eigen::DenseBase< TDerivedP > const &P, Index maxPointsInLeaf=8) |
| Construct a k-D tree from a set of points.
|
|
template<class TDerivedP> |
void | Construct (Eigen::DenseBase< TDerivedP > const &P, Index maxPointsInLeaf) |
| Construct a k-D tree from a set of points.
|
|
template<class FVisit> |
void | DepthFirstSearch (FVisit visit, Index root=0) const |
| Depth-first search over the k-D tree.
|
|
std::vector< KdTreeNode > const & | Nodes () const |
| Returns the nodes of the k-D tree.
|
|
IndexVectorX const & | Permutation () const |
| Returns the permutation of the points in the k-D tree.
|
|
auto | PointsInNode (Index const nodeIdx) const |
| Returns the points in a node.
|
|
auto | PointsInNode (KdTreeNode const &node) const |
| Returns the points in a node.
|
|
Index constexpr | Root () const |
| Returns the root node index.
|
|
template<int Dims>
class pbat::geometry::KdTree< Dims >
KDTree class.
- Template Parameters
-
Dims | Number of dimensions of the points' coordinate system in the k-D tree |
template<int Dims>
template<class TDerivedP>
Construct a k-D tree from a set of points.
Implements a top-down median splitting strategy to construct the k-D tree. The median is chosen along the largest axis at each node of the tree, where the left child will inherit the parent node's points less than the median and the right child will inherit the rest. At each node, we use std::nth_element, i.e. introselect, which has \( O(n) \) average complexity (and \( O(n) \) worst-case complexity in recent compiler versions, i.e. Microsoft STL), to partition the points in-place. The largest k-D tree occurs when maxPointsInLeaf == 1
, and the tree is always a full binary tree with \( 2n - 1 \) nodes.
Thus, tree construction has \( O(n log(n)) \) average, and \( O(n log^2 n) \) worst-case time complexity.
- Note
- For fast construction, radix tree is potentially a better choice. However, our radix tree does not support multiple points per leaf.
-
We could parallelize construction quite easily in the future, since the node ranges are non-overlapping.
- Template Parameters
-
TDerivedP | Eigen dense expression type |
- Parameters
-
P | Points to construct the k-D tree from |
maxPointsInLeaf | Maximum number of points in a leaf node |