CVR-Lib last update 20 Sep 2009

cvr::euclideanDistantor< T, D > Class Template Reference

Policy class used by several classifiers/trees to measure the euclidean distance between two points of type T. More...

#include <cvrEuclideanDistantor.h>

List of all members.

Public Types

typedef D distance_type

Public Member Functions

distance_type operator() (const T &a, const T &b) const
Special methods for Minkowski distances
void accumulate (const distance_type element, distance_type &accumulator) const
void accumulate (const typename T::value_type element1, const typename T::value_type element2, distance_type &accumulator) const
distance_type computeDistance (const distance_type &accumulator) const
distance_type component (const typename T::value_type element1, const typename T::value_type element2) const
bool accLessThan (const distance_type acc, const distance_type dist) const
bool accGreaterThan (const distance_type acc, const distance_type dist) const


Detailed Description

template<class T, class D = typename distanceType<T>::fp_distance_type>
class cvr::euclideanDistantor< T, D >

Policy class used by several classifiers/trees to measure the euclidean distance between two points of type T.

The type T MUST define the value_type type, which exist for example for vectors, (t)points and (t)rgbPixels.

If you really want, you can use this class directly through the operator().

 euclideanDistantor< vector<double> > myDist;
 dvector a,b;
 ... // fill vectors with data
 double dist = myDist(a,b);

But remember that there is also a global template function distanceSqr() which can be more easily used:

 dvector a,b;
 ... // fill vectors with data
 double dist = sqrt(distanceSqr(a,b));

You can of course also use the cvr::l2Distance functor, as usual with its apply() methods.


Member Typedef Documentation

template<class T , class D = typename distanceType<T>::fp_distance_type>
typedef D cvr::euclideanDistantor< T, D >::distance_type

type returned by the distantor


Member Function Documentation

template<class T , class D = typename distanceType<T>::fp_distance_type>
bool cvr::euclideanDistantor< T, D >::accGreaterThan ( const distance_type  acc,
const distance_type  dist 
) const [inline]

Return true if the given partial computed from accumulator is greater than the given distance.

Assume you have accumulated acc until now, and you want to check if the partial distance derived from this accumulator is less than the given distance. So you check accLessThan(accumulator,distance)

For this norm it computes acc > (dist*dist)

template<class T , class D = typename distanceType<T>::fp_distance_type>
bool cvr::euclideanDistantor< T, D >::accLessThan ( const distance_type  acc,
const distance_type  dist 
) const [inline]

Return true if the given partial computed from accumulator is less than the given distance.

Assume you have accumulated acc until now, and you want to check if the partial distance derived from this accumulator is less than the given distance. So you check accLessThan(accumulator,distance)

For this norm it computes acc < (dist*dist)

template<class T , class D = typename distanceType<T>::fp_distance_type>
void cvr::euclideanDistantor< T, D >::accumulate ( const typename T::value_type  element1,
const typename T::value_type  element2,
distance_type accumulator 
) const [inline]

This member accumulates in the given accumulator, the difference of the given elements.

It can be used when the distance need to be computed manually, but using a distantor to still allow the flexibility of changing distances.

For the euclideanDistantor this is just acc+=((elem2-elem1)^2).

Parameters:
element1 component of the first point
element2 component of the second point
accumulator variable where the elements will be accumulated.

template<class T , class D = typename distanceType<T>::fp_distance_type>
void cvr::euclideanDistantor< T, D >::accumulate ( const distance_type  element,
distance_type accumulator 
) const [inline]

This member accumulates in the given accumulator, the given element.

It can be used when the distance need to be computed manually, but using a distantor to still allow the flexibility of changing distances.

For the euclideanDistantor this is just acc+=(elem*elem).

Parameters:
element component of the difference between two points.
accumulator variable where the elements will be accumulated.

template<class T , class D = typename distanceType<T>::fp_distance_type>
distance_type cvr::euclideanDistantor< T, D >::component ( const typename T::value_type  element1,
const typename T::value_type  element2 
) const [inline]

return the distance between two components, which is in some way a component of the total distance (that is the reason for the name).

For this distantor it return abs(element2-element1)

References cvr::abs().

template<class T , class D = typename distanceType<T>::fp_distance_type>
distance_type cvr::euclideanDistantor< T, D >::computeDistance ( const distance_type accumulator  )  const [inline]

Compute from the given accumulator the desired distance.

References cvr::sqrt().

template<class T , class D = typename distanceType<T>::fp_distance_type>
distance_type cvr::euclideanDistantor< T, D >::operator() ( const T &  a,
const T &  b 
) const [inline]

compute the distance between a and b

References cvr::euclideanDistance().


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

Generated on Sun Sep 20 22:08:57 2009 for CVR-Lib by Doxygen 1.5.8