DGtal
1.5.beta
|
Aim: implements separable l_p metrics with exact predicates. More...
#include <DGtal/geometry/volumes/distance/ExactPredicateLpSeparableMetric.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 TRawValue | RawValue |
Type for internal distance values. More... | |
typedef double | Value |
Type for distance values. More... | |
typedef ExactPredicateLpSeparableMetric< TSpace, p, RawValue > | Self |
Self type. More... | |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CInteger< RawValue >)) | |
ExactPredicateLpSeparableMetric () | |
~ExactPredicateLpSeparableMetric () | |
ExactPredicateLpSeparableMetric (const Self &other) | |
Self & | operator= (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 |
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.
TSpace | the model of CSpace on which the metric is defined. |
p | the exponent of the metric (static DGtal::uint32_t) |
TRawValue | model of CSignedInteger used to store power p sums (default: DGtal::int64_t) |
Definition at line 87 of file ExactPredicateLpSeparableMetric.h.
typedef Point::Coordinate DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Abscissa |
Type for points.
Definition at line 98 of file ExactPredicateLpSeparableMetric.h.
typedef Space::Point DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Point |
Type for points.
Definition at line 96 of file ExactPredicateLpSeparableMetric.h.
typedef TRawValue DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::RawValue |
Type for internal distance values.
Definition at line 103 of file ExactPredicateLpSeparableMetric.h.
typedef ExactPredicateLpSeparableMetric<TSpace,p,RawValue> DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Self |
Self type.
Definition at line 110 of file ExactPredicateLpSeparableMetric.h.
typedef TSpace DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Space |
Copy the space type.
Definition at line 92 of file ExactPredicateLpSeparableMetric.h.
typedef double DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Value |
Type for distance values.
Definition at line 107 of file ExactPredicateLpSeparableMetric.h.
typedef Space::Vector DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::Vector |
Type for vectors.
Definition at line 100 of file ExactPredicateLpSeparableMetric.h.
DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::ExactPredicateLpSeparableMetric | ( | ) |
Constructor.
DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::~ExactPredicateLpSeparableMetric | ( | ) |
Destructor.
|
inline |
Copy constructor.
other | the object to clone (not used). |
Definition at line 127 of file ExactPredicateLpSeparableMetric.h.
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.
udim | coordinate of u along dimension dim |
vdim | coordinate of v along dimension dim |
nu | partial distance of u (sum of |xj-x_i|^p) discarding the term along the dimension dim |
nv | partial distance of v (sum of |xj-x_i|^p) discarding the term along the dimension dim |
lower | interval lower bound |
upper | interval upper bound |
Referenced by testBinarySearch().
DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::BOOST_CONCEPT_ASSERT | ( | (concepts::CInteger< RawValue >) | ) |
DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::BOOST_CONCEPT_ASSERT | ( | (concepts::CSpace< TSpace >) | ) |
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.
origin | the origin |
first | the first point |
second | the second point |
Referenced by testMetrics().
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)\).
u | a site |
v | a site |
w | a site |
startingPoint | starting point of the segment |
endPoint | end point of the segment |
dim | direction of the straight line |
Referenced by testMetrics(), testSpecialCasesL2(), and testSpecialCasesLp().
bool DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Value DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::operator() | ( | const Point & | aP, |
const Point & | aQ | ||
) | const |
Compute the distance between aP and aQ.
aP | a first point. |
aQ | a second point. |
|
inline |
Assignment.
other | other the object to copy (not used). |
Definition at line 137 of file ExactPredicateLpSeparableMetric.h.
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\)).
aP | a first point. |
aQ | a second point. |
void DGtal::ExactPredicateLpSeparableMetric< TSpace, p, TRawValue >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |