DGtal  0.9.3beta
Public Types | Public Member Functions | Private Member Functions | Private Attributes
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue > Class Template Reference

#include <DGtal/geometry/volumes/distance/InexactPredicateLpSeparableMetric.h>

Inheritance diagram for DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >:
[legend]
Collaboration diagram for DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >:
[legend]

Public Types

typedef TSpace Space
 
typedef Space::Point Point
 
typedef Point::Coordinate Abscissa
 
typedef Space::Vector Vector
 
typedef TValue Value
 
typedef TValue RawValue
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CEuclideanRing< TValue >))
 
 InexactPredicateLpSeparableMetric (const double anExponent)
 
 ~InexactPredicateLpSeparableMetric ()
 
 InexactPredicateLpSeparableMetric (const InexactPredicateLpSeparableMetric &other)
 
InexactPredicateLpSeparableMetricoperator= (const InexactPredicateLpSeparableMetric &other)
 
Value operator() (const Point &aP, const Point &aQ) const
 
RawValue rawDistance (const Point &aP, const Point &aQ) const
 
Closest closest (const Point &origin, const Point &first, const Point &second) const
 
bool hiddenBy (const Point &u, const Point &v, const Point &w, const Point &startingPoint, const Point &endPoint, const typename Point::UnsignedComponent dim) const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Private Member Functions

Value distanceLp (const Point &aP, const Point &aQ) const
 
Abscissa binarySearchHidden (const Abscissa &udim, const Abscissa &vdim, const Value &nu, const Value &nv, const Abscissa &lower, const Abscissa &upper) const
 

Private Attributes

Value myExponent
 

Detailed Description

template<typename TSpace, typename TValue = double>
class DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >

Aim: implements separable l_p metrics with approximated predicates.

Description of template class 'InexactPredicateLpSeparableMetric'

Given a parameter p, the class implement classical l_p metric as a model of CSeparableMetric. Hence, given two points \( x=(x_0...x_{n-1})\), \( y=(y_0...y_{n-1})\) in the given digital space (see below), we define a metric such that:

\( distance(x,y)= \left( \sum_{i=0}^{n-1} |x_i-y_i|^p\right)^{1/p}\)

This class is said to be inexact in the sense that the power p a real number (of type TValue, e.g. double or float) and the power is given by std::pow on double numbers. As a consequence, hiddenBy and closest methods may be inexact (numerical issues).

The exponent p is specifed at the constructor.

Template Parameters
TSpacethe model of CSpace on which the metric is defined.
TValuevalue type of the distance computation (e.g. float or double –defaut–). Model of CEuclideanRing.

Definition at line 81 of file InexactPredicateLpSeparableMetric.h.

Member Typedef Documentation

template<typename TSpace, typename TValue = double>
typedef Point::Coordinate DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::Abscissa

Type for points.

Definition at line 96 of file InexactPredicateLpSeparableMetric.h.

template<typename TSpace, typename TValue = double>
typedef Space::Point DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::Point

Type for points.

Definition at line 94 of file InexactPredicateLpSeparableMetric.h.

template<typename TSpace, typename TValue = double>
typedef TValue DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::RawValue

Type for raw distance values.

Definition at line 102 of file InexactPredicateLpSeparableMetric.h.

template<typename TSpace, typename TValue = double>
typedef TSpace DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::Space

Copy the space type.

Definition at line 88 of file InexactPredicateLpSeparableMetric.h.

template<typename TSpace, typename TValue = double>
typedef TValue DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::Value

Type for distance values.

Definition at line 100 of file InexactPredicateLpSeparableMetric.h.

template<typename TSpace, typename TValue = double>
typedef Space::Vector DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::Vector

Type for vectors.

Definition at line 98 of file InexactPredicateLpSeparableMetric.h.

Constructor & Destructor Documentation

template<typename TSpace, typename TValue = double>
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::InexactPredicateLpSeparableMetric ( const double  anExponent)

Constructor.

template<typename TSpace, typename TValue = double>
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::~InexactPredicateLpSeparableMetric ( )

Destructor.

template<typename TSpace, typename TValue = double>
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::InexactPredicateLpSeparableMetric ( const InexactPredicateLpSeparableMetric< TSpace, TValue > &  other)
inline

Copy constructor.

Parameters
otherthe object to clone.

Definition at line 119 of file InexactPredicateLpSeparableMetric.h.

References DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::myExponent.

120  {
121  myExponent = other.myExponent;
122  }

Member Function Documentation

template<typename TSpace, typename TValue = double>
Abscissa DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::binarySearchHidden ( const Abscissa udim,
const Abscissa vdim,
const Value nu,
const Value nv,
const Abscissa lower,
const Abscissa upper 
) const
private

Perform a binary search on the interval [lower,upper] to detect the mid-point between u and v according to the l_p distance. It returns the abscissa q such that q belongs to the power cell of u (strictly) but not q-1.

Precondition
udim < vdim
Parameters
udimcoordinate of u along dimension dim
vdimcoordinate of v along dimension dim
nupartial distance of u (sum of |xj-x_i|^p) discarding the term along the dimension dim
nvpartial distance of v (sum of |xj-x_i|^p) discarding the term along the dimension dim
lowerinterval lower bound
upperinterval upper bound
Returns
the u Voronoi cell greatest point coordinates along dimension dim.
template<typename TSpace, typename TValue = double>
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::BOOST_CONCEPT_ASSERT ( (concepts::CSpace< TSpace >)  )
template<typename TSpace, typename TValue = double>
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::BOOST_CONCEPT_ASSERT ( (concepts::CEuclideanRing< TValue >)  )
template<typename TSpace, typename TValue = double>
Closest DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::closest ( const Point origin,
const Point first,
const Point second 
) const

Given an origin and two points, this method decides which one is closest to the origin. This method should be faster than comparing distance values.

Parameters
originthe origin
firstthe first point
secondthe second point
Returns
a Closest enum: FIRST, SECOND or BOTH.
template<typename TSpace, typename TValue = double>
Value DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::distanceLp ( const Point aP,
const Point aQ 
) const
private

Compute the Lp distance without the computation of the power 1/p. I.e. only \( \sum |p_i- q_i|^p\) is given.

Parameters
aPa first point
aQa second point
Returns
the power p of the l_p distance between aP and aQ.
template<typename TSpace, typename TValue = double>
bool DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::hiddenBy ( const Point u,
const Point v,
const Point w,
const Point startingPoint,
const Point endPoint,
const typename Point::UnsignedComponent  dim 
) const

Given three sites (u,v,w) and a straight segment [startingPoint,endPoint] along dimension dim, we detect if the voronoi cells of u and w strictly hide the voronoi cell of v on the straight line.

This method is in \( O(log(n))\) if n is the size of the straight segment.

Precondition
u,v and w must be such that u[dim] < v[dim] < w[dim]
Parameters
ua site
va site
wa site
startingPointstarting point of the segment
endPointend point of the segment
dimdirection of the straight line
Returns
true if (u,w) hides v (strictly).
template<typename TSpace, typename TValue = double>
bool DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.
template<typename TSpace, typename TValue = double>
Value DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::operator() ( const Point aP,
const Point aQ 
) const

Compute the distance between aP and aQ.

Parameters
aPa first point.
aQa second point.
Returns
the distance between aP and aQ.
template<typename TSpace, typename TValue = double>
InexactPredicateLpSeparableMetric& DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::operator= ( const InexactPredicateLpSeparableMetric< TSpace, TValue > &  other)
inline

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

Definition at line 129 of file InexactPredicateLpSeparableMetric.h.

References DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::myExponent.

130  {
131  myExponent = other.myExponent;
132  return *this;
133  }
template<typename TSpace, typename TValue = double>
RawValue DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::rawDistance ( const Point aP,
const Point aQ 
) const

Compute the raw distance between aP and aQ.

Parameters
aPa first point.
aQa second point.
Returns
the distance between aP and aQ.
template<typename TSpace, typename TValue = double>
void DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Field Documentation

template<typename TSpace, typename TValue = double>
Value DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::myExponent
private

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