DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue > Class Template Reference

Aim: implements separable l_p metrics with approximated predicates. More...

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

Public Types

typedef TSpace Space
 Copy the space type. More...
 
typedef Space::Point Point
 Type for points. More...
 
typedef Point::Coordinate Abscissa
 Type for points. More...
 
typedef Space::Vector Vector
 Type for vectors. More...
 
typedef TValue Value
 Type for distance values. More...
 
typedef TValue RawValue
 Type for raw distance values. More...
 

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
 Exponent value. More...
 

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

◆ Abscissa

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

Type for points.

Definition at line 95 of file InexactPredicateLpSeparableMetric.h.

◆ Point

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

Type for points.

Definition at line 93 of file InexactPredicateLpSeparableMetric.h.

◆ RawValue

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

Type for raw distance values.

Definition at line 101 of file InexactPredicateLpSeparableMetric.h.

◆ Space

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

Copy the space type.

Definition at line 87 of file InexactPredicateLpSeparableMetric.h.

◆ Value

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

Type for distance values.

Definition at line 99 of file InexactPredicateLpSeparableMetric.h.

◆ Vector

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

Type for vectors.

Definition at line 97 of file InexactPredicateLpSeparableMetric.h.

Constructor & Destructor Documentation

◆ InexactPredicateLpSeparableMetric() [1/2]

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

Constructor.

◆ ~InexactPredicateLpSeparableMetric()

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

Destructor.

◆ InexactPredicateLpSeparableMetric() [2/2]

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 118 of file InexactPredicateLpSeparableMetric.h.

119 {
120 myExponent = other.myExponent;
121 }

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

Member Function Documentation

◆ binarySearchHidden()

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.

◆ BOOST_CONCEPT_ASSERT() [1/2]

template<typename TSpace , typename TValue = double>
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::BOOST_CONCEPT_ASSERT ( (concepts::CEuclideanRing< TValue >)  )

◆ BOOST_CONCEPT_ASSERT() [2/2]

template<typename TSpace , typename TValue = double>
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::BOOST_CONCEPT_ASSERT ( (concepts::CSpace< TSpace >)  )

◆ closest()

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.

◆ distanceLp()

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.

◆ hiddenBy()

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

Referenced by testInexactMetrics().

◆ isValid()

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.

◆ operator()()

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.

◆ operator=()

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 128 of file InexactPredicateLpSeparableMetric.h.

129 {
130 myExponent = other.myExponent;
131 return *this;
132 }

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

◆ rawDistance()

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.

◆ selfDisplay()

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

◆ myExponent

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

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