#include <kdTree.h>
Public Member Functions | |
| KDComparator (unsigned int axis=0) | |
| Constructor. | |
| virtual | ~KDComparator () |
| Destructor. | |
| double | computeDistance (Type const &arg0, Type const &arg1) const |
| This member function computes the square of the Euclidean distance between two Type instances. | |
| double | getPrimarySeparation (Type const &arg0, Type const &arg1) const |
| This member function computes a lower bound on the distance between the specified Type instance and Type instances contained in the "far" branch of a KD-Tree. | |
| bool | isEqual (Type const &arg0, Type const &arg1) const |
| This member function returns true if its two arguments represent the same point. | |
| bool | operator() (Type const &arg0, Type const &arg1) const |
| This operator implements "arg0 < arg1" so that sequences of Type instances can be sorted using std::sort(). | |
It provides functions for comparing points during a sort, for computing the distance between points, and for finding the lower bound on the distance between a particular point and the region of space represented by a particular branch of the KD-Tree. Template argument Dimension specifies how many dimension the tree spans. Template argument Type specifies what kind of element is contained in the tree. Logically, Type represents a point in multi-dimensional space. In order to work with this class template, Type must allow access to individual coordinates via Type::operator[](size_t), which will be called with arguments in the range [0 ... (Dimension - 1)]. Also, operator==(Type const&, Type const&) must return true if the two arguments represent the same point.
If you need to build a KD-Tree using a Type that doesn't support this interface, you can simply specialize KDComparator (or specific member functions of KDComparator) for your type. For an example of such a specialization, see the file dlrComputerVision/test/kdTreeTest.cpp.
Definition at line 50 of file kdTree.h.
| dlr::computerVision::KDComparator< Dimension, Type >::KDComparator | ( | unsigned int | axis = 0 |
) | [inline] |
Constructor.
Each KDComparator is associated with a specific level of the KD-Tree, and therefor with a specific axis in multi-dimensional space. This constructor specifies whith which axis *this is associated.
| axis | This argument must be an integer between 0 and (Dimension - 1), inclusive. |
| virtual dlr::computerVision::KDComparator< Dimension, Type >::~KDComparator | ( | ) | [inline, virtual] |
| double dlr::computerVision::KDComparator< Dimension, Type >::computeDistance | ( | Type const & | arg0, | |
| Type const & | arg1 | |||
| ) | const [inline] |
This member function computes the square of the Euclidean distance between two Type instances.
| arg0 | This argument is the first of the two Type instances. | |
| arg1 | This argument is the second of the two Type instances. |
| double dlr::computerVision::KDComparator< Dimension, Type >::getPrimarySeparation | ( | Type const & | arg0, | |
| Type const & | arg1 | |||
| ) | const [inline] |
This member function computes a lower bound on the distance between the specified Type instance and Type instances contained in the "far" branch of a KD-Tree.
The dividing hyperplane between the two brances is assumed to run perpendicular to the axis specified by this->m_axis, and intersect the point specified by argument arg1.
| arg0 | This argument is the point for which to compute the lower bound distance. | |
| arg1 | This argument is the point through which the separating hyperplane passes. |
| bool dlr::computerVision::KDComparator< Dimension, Type >::isEqual | ( | Type const & | arg0, | |
| Type const & | arg1 | |||
| ) | const [inline] |
This member function returns true if its two arguments represent the same point.
| arg0 | This argument is the first Type instance to be compared. | |
| arg1 | This argument is the second Type instance to be compared. |
| bool dlr::computerVision::KDComparator< Dimension, Type >::operator() | ( | Type const & | arg0, | |
| Type const & | arg1 | |||
| ) | const [inline] |
This operator implements "arg0 < arg1" so that sequences of Type instances can be sorted using std::sort().
KDComparator instances will be passed as the final (functor) argument to std::sort(). For normal KD-Tree operation, it should begin by comparing the locations of arg1 and arg0 along the axis associated with *this. In the current implementation, Type instances that have identical coordinates on this one axis will be compared along other axes.
1.5.8