DGtal  0.9.4beta
Public Types | Public Member Functions
DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue > Class Template Reference

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

Inheritance diagram for DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >:
[legend]
Collaboration diagram for DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >:
[legend]

Public Types

typedef std::binary_function< typename TSpace::Point, typename TSpace::Point, double > Base
 
typedef Base::first_argument_type first_argument_type
 
typedef Base::second_argument_type second_argument_type
 
typedef Base::result_type result_type
 
typedef TSpace Space
 
typedef Space::Point Point
 
typedef Point::Coordinate Abscissa
 
typedef Space::Vector Vector
 
typedef TRawValue RawValue
 
typedef double Value
 
typedef ExactPredicateLpSeparableMetric< TSpace, p, RawValueSelf
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CInteger< RawValue >))
 
 ExactPredicateLpSeparableMetric ()
 
 ~ExactPredicateLpSeparableMetric ()
 
 ExactPredicateLpSeparableMetric (const Self &other)
 
Selfoperator= (const Self &other)
 
Value operator() (const Point &aP, const Point &aQ) const
 
Closest closest (const Point &origin, const Point &first, const Point &second) const
 
RawValue rawDistance (const Point &aP, const Point &aQ) 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
 
Abscissa binarySearchHidden (const Abscissa &udim, const Abscissa &vdim, const RawValue &nu, const RawValue &nv, const Abscissa &lower, const Abscissa &upper) const
 

Detailed Description

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
class DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >

Aim: implements separable l_p metrics with exact predicates.

Description of template class 'ExactPredicateLpSeparableMetric'

Given a template 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 exact in the sense that the power p is computed without approximation (exponentiation by squaring in \( O(log(p))\) per computation, see functions::power). As a consequence, hiddenBy and closest methods are error free if the capacity of the template type TPromoted allows to store sums of \( |x_i-y_i|^p\) quantities.

Template Parameters
TSpacethe model of CSpace on which the metric is defined.
pthe exponent of the metric (static DGtal::uint32_t)
TRawValuemodel of CSignedInteger used to store power p sums (default: DGtal::int64_t)
Examples:
geometry/surfaces/dvcm-2d-curvature.cpp, geometry/surfaces/dvcm-3d.cpp, geometry/volumes/distance/voronoimap2D.cpp, geometry/volumes/dvcm-2d.cpp, graph/volDistanceTraversal.cpp, and tutorial-examples/volDTGranulo.cpp.

Definition at line 87 of file ExactPredicateLpSeparableMetric.h.

Member Typedef Documentation

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
typedef Point::Coordinate DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Abscissa

Type for points.

Definition at line 104 of file ExactPredicateLpSeparableMetric.h.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
typedef std::binary_function< typename TSpace::Point, typename TSpace::Point, double > DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Base

Definition at line 92 of file ExactPredicateLpSeparableMetric.h.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
typedef Base::first_argument_type DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::first_argument_type

Definition at line 93 of file ExactPredicateLpSeparableMetric.h.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
typedef Space::Point DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Point

Type for points.

Definition at line 102 of file ExactPredicateLpSeparableMetric.h.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
typedef TRawValue DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::RawValue

Type for internal distance values.

Definition at line 109 of file ExactPredicateLpSeparableMetric.h.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
typedef Base::result_type DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::result_type

Definition at line 95 of file ExactPredicateLpSeparableMetric.h.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
typedef Base::second_argument_type DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::second_argument_type

Definition at line 94 of file ExactPredicateLpSeparableMetric.h.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
typedef ExactPredicateLpSeparableMetric<TSpace,p,RawValue> DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Self

Self type.

Definition at line 116 of file ExactPredicateLpSeparableMetric.h.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
typedef TSpace DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Space

Copy the space type.

Definition at line 98 of file ExactPredicateLpSeparableMetric.h.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
typedef double DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Value

Type for distance values.

Definition at line 113 of file ExactPredicateLpSeparableMetric.h.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
typedef Space::Vector DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Vector

Type for vectors.

Definition at line 106 of file ExactPredicateLpSeparableMetric.h.

Constructor & Destructor Documentation

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::ExactPredicateLpSeparableMetric ( )

Constructor.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::~ExactPredicateLpSeparableMetric ( )

Destructor.

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::ExactPredicateLpSeparableMetric ( const Self other)
inline

Copy constructor.

Parameters
otherthe object to clone (not used).

Definition at line 133 of file ExactPredicateLpSeparableMetric.h.

134  {
135  boost::ignore_unused_variable_warning( other );
136  }

Member Function Documentation

template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
Abscissa DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::binarySearchHidden ( const Abscissa udim,
const Abscissa vdim,
const RawValue nu,
const RawValue nv,
const Abscissa lower,
const Abscissa upper 
) const

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, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::BOOST_CONCEPT_ASSERT ( (concepts::CSpace< TSpace >)  )
template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::BOOST_CONCEPT_ASSERT ( (concepts::CInteger< RawValue >)  )
template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
Closest DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::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, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
bool DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::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. For \( l_2\) metric (p=2), the method is in \( O(1)\).

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, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
bool DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.
template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
Value DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::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, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
Self& DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::operator= ( const Self other)
inline

Assignment.

Parameters
otherother the object to copy (not used).
Returns
a reference on 'this'.

Definition at line 143 of file ExactPredicateLpSeparableMetric.h.

144  {
145  boost::ignore_unused_variable_warning( other );
146  return *this;
147  }
template<typename TSpace, DGtal::uint32_t p, typename TRawValue = DGtal::int64_t>
RawValue DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::rawDistance ( const Point aP,
const Point aQ 
) const

Compute the raw distance between aP and aQ. (i.e. \( \sum_{i=1}^n |x_i-y_i |^p\)).

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

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

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