dlr::computerVision::KDComparator< Dimension, Type > Class Template Reference

This class template is used by the KDTree class template to interact with the data points to be stored in the KD-Tree. More...

#include <kdTree.h>

List of all members.

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().


Detailed Description

template<unsigned int Dimension, class Type>
class dlr::computerVision::KDComparator< Dimension, Type >

This class template is used by the KDTree class template to interact with the data points to be stored in the KD-Tree.

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.


Constructor & Destructor Documentation

template<unsigned int Dimension, class Type >
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.

Parameters:
axis This argument must be an integer between 0 and (Dimension - 1), inclusive.

Definition at line 64 of file kdTree.h.

template<unsigned int Dimension, class Type >
virtual dlr::computerVision::KDComparator< Dimension, Type >::~KDComparator (  )  [inline, virtual]

Destructor.

Definition at line 72 of file kdTree.h.


Member Function Documentation

template<unsigned int Dimension, class Type >
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.

Parameters:
arg0 This argument is the first of the two Type instances.
arg1 This argument is the second of the two Type instances.
Returns:
The return value is the Euclidean distance between arg0 and arg1.

Definition at line 89 of file kdTree.h.

template<unsigned int Dimension, class Type >
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.

Parameters:
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.
Returns:
The return value is the minimum distance between arg0 and the separating hyperplane.

Definition at line 117 of file kdTree.h.

template<unsigned int Dimension, class Type >
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.

Parameters:
arg0 This argument is the first Type instance to be compared.
arg1 This argument is the second Type instance to be compared.
Returns:
The return value is true if the two arguments represent the same point, false otherwise.

Definition at line 136 of file kdTree.h.

template<unsigned int Dimension, class Type >
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.

Returns:
The return value is true if arg0 is "less than" arg1, false otherwise.

Definition at line 155 of file kdTree.h.


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

Generated on Wed Nov 25 12:15:09 2009 for dlrComputerVision Utility Library by  doxygen 1.5.8