ellipsoid_tree 0.1.0
Exact intersection tests for ellipsoids and friends
Loading...
Searching...
No Matches
ellipsoid_tree::AABBTree Class Reference

Axis-aligned bounding box (AABB) tree over a set of leaf boxes. More...

#include <ellipsoid_tree/aabb_tree.hpp>

Public Member Functions

 AABBTree ()=default
 Constructs an empty tree.
 
 AABBTree (const Eigen::Ref< const Eigen::MatrixXd > &leaf_lo, const Eigen::Ref< const Eigen::MatrixXd > &leaf_hi)
 Builds a tree over the leaf boxes given as columns of leaf_lo and leaf_hi.
 
void build (const Eigen::Ref< const Eigen::MatrixXd > &leaf_lo, const Eigen::Ref< const Eigen::MatrixXd > &leaf_hi)
 (Re)builds the tree over the leaf boxes given as columns of leaf_lo and leaf_hi.
 
int dim () const
 Spatial dimension of the leaf boxes.
 
int num_leaves () const
 Number of leaf boxes (external objects) in the tree.
 
int num_nodes () const
 Total number of nodes (2 * num_leaves - 1, or 0 when empty).
 
bool empty () const
 True when the tree contains no nodes.
 
bool is_leaf (int node) const
 True when node is a leaf (has no children in the heap layout).
 
int left_child (int node) const
 Heap index of node's left child.
 
int right_child (int node) const
 Heap index of node's right child.
 
int external_index (int node) const
 External object index stored at a leaf node (-1 for internal nodes).
 
Eigen::Ref< const Eigen::VectorXd > node_lo (int node) const
 Lower corner of node's bounding box.
 
Eigen::Ref< const Eigen::VectorXd > node_hi (int node) const
 Upper corner of node's bounding box.
 
const Eigen::MatrixXd & node_lo_matrix () const
 All node lower corners as a (dim, num_nodes) matrix.
 
const Eigen::MatrixXd & node_hi_matrix () const
 All node upper corners as a (dim, num_nodes) matrix.
 
template<class NodePredicate , class LeafCallback >
bool visit (NodePredicate &&overlaps_node, LeafCallback &&on_leaf) const
 Depth-first traversal.
 
std::vector< int > point_collisions (const Eigen::Ref< const Eigen::VectorXd > &p) const
 External indices of all leaf boxes that contain the query point p.
 
std::vector< int > box_collisions (const Eigen::Ref< const Eigen::VectorXd > &qlo, const Eigen::Ref< const Eigen::VectorXd > &qhi) const
 External indices of all leaf boxes that overlap the query box [qlo, qhi].
 
std::vector< int > ball_collisions (const Eigen::Ref< const Eigen::VectorXd > &center, double radius) const
 External indices of all leaf boxes that intersect the ball of given center and radius.
 

Detailed Description

Axis-aligned bounding box (AABB) tree over a set of leaf boxes.

Constructor & Destructor Documentation

◆ AABBTree() [1/2]

ellipsoid_tree::AABBTree::AABBTree ( )
default

Constructs an empty tree.

◆ AABBTree() [2/2]

ellipsoid_tree::AABBTree::AABBTree ( const Eigen::Ref< const Eigen::MatrixXd > &  leaf_lo,
const Eigen::Ref< const Eigen::MatrixXd > &  leaf_hi 
)
inline

Builds a tree over the leaf boxes given as columns of leaf_lo and leaf_hi.

Member Function Documentation

◆ build()

void ellipsoid_tree::AABBTree::build ( const Eigen::Ref< const Eigen::MatrixXd > &  leaf_lo,
const Eigen::Ref< const Eigen::MatrixXd > &  leaf_hi 
)
inline

(Re)builds the tree over the leaf boxes given as columns of leaf_lo and leaf_hi.

◆ dim()

int ellipsoid_tree::AABBTree::dim ( ) const
inline

Spatial dimension of the leaf boxes.

◆ num_leaves()

int ellipsoid_tree::AABBTree::num_leaves ( ) const
inline

Number of leaf boxes (external objects) in the tree.

◆ num_nodes()

int ellipsoid_tree::AABBTree::num_nodes ( ) const
inline

Total number of nodes (2 * num_leaves - 1, or 0 when empty).

◆ empty()

bool ellipsoid_tree::AABBTree::empty ( ) const
inline

True when the tree contains no nodes.

◆ is_leaf()

bool ellipsoid_tree::AABBTree::is_leaf ( int  node) const
inline

True when node is a leaf (has no children in the heap layout).

◆ left_child()

int ellipsoid_tree::AABBTree::left_child ( int  node) const
inline

Heap index of node's left child.

◆ right_child()

int ellipsoid_tree::AABBTree::right_child ( int  node) const
inline

Heap index of node's right child.

◆ external_index()

int ellipsoid_tree::AABBTree::external_index ( int  node) const
inline

External object index stored at a leaf node (-1 for internal nodes).

◆ node_lo()

Eigen::Ref< const Eigen::VectorXd > ellipsoid_tree::AABBTree::node_lo ( int  node) const
inline

Lower corner of node's bounding box.

◆ node_hi()

Eigen::Ref< const Eigen::VectorXd > ellipsoid_tree::AABBTree::node_hi ( int  node) const
inline

Upper corner of node's bounding box.

◆ node_lo_matrix()

const Eigen::MatrixXd & ellipsoid_tree::AABBTree::node_lo_matrix ( ) const
inline

All node lower corners as a (dim, num_nodes) matrix.

◆ node_hi_matrix()

const Eigen::MatrixXd & ellipsoid_tree::AABBTree::node_hi_matrix ( ) const
inline

All node upper corners as a (dim, num_nodes) matrix.

◆ visit()

template<class NodePredicate , class LeafCallback >
bool ellipsoid_tree::AABBTree::visit ( NodePredicate &&  overlaps_node,
LeafCallback &&  on_leaf 
) const
inline

Depth-first traversal.

overlaps_node(lo, hi) decides whether to descend into a node; on_leaf(external_index) is called for each overlapping leaf and stops the whole traversal by returning false. Returns false iff the traversal was stopped early.

◆ point_collisions()

std::vector< int > ellipsoid_tree::AABBTree::point_collisions ( const Eigen::Ref< const Eigen::VectorXd > &  p) const
inline

External indices of all leaf boxes that contain the query point p.

Convenience query; exact for the leaf boxes themselves.

◆ box_collisions()

std::vector< int > ellipsoid_tree::AABBTree::box_collisions ( const Eigen::Ref< const Eigen::VectorXd > &  qlo,
const Eigen::Ref< const Eigen::VectorXd > &  qhi 
) const
inline

External indices of all leaf boxes that overlap the query box [qlo, qhi].

◆ ball_collisions()

std::vector< int > ellipsoid_tree::AABBTree::ball_collisions ( const Eigen::Ref< const Eigen::VectorXd > &  center,
double  radius 
) const
inline

External indices of all leaf boxes that intersect the ball of given center and radius.


The documentation for this class was generated from the following file: