DGtal 1.4.0
|
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. | |
typedef Space::Point | Point |
Type for points. | |
typedef Point::Coordinate | Abscissa |
Type for points. | |
typedef Space::Vector | Vector |
Type for vectors. | |
typedef TValue | Value |
Type for distance values. | |
typedef TValue | RawValue |
Type for raw distance values. | |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CEuclideanRing< TValue >)) | |
InexactPredicateLpSeparableMetric (const double anExponent) | |
~InexactPredicateLpSeparableMetric () | |
InexactPredicateLpSeparableMetric (const InexactPredicateLpSeparableMetric &other) | |
InexactPredicateLpSeparableMetric & | operator= (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. | |
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.
TSpace | the model of CSpace on which the metric is defined. |
TValue | value type of the distance computation (e.g. float or double –defaut–). Model of CEuclideanRing. |
Definition at line 81 of file InexactPredicateLpSeparableMetric.h.
typedef Point::Coordinate DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::Abscissa |
Type for points.
Definition at line 95 of file InexactPredicateLpSeparableMetric.h.
typedef Space::Point DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::Point |
Type for points.
Definition at line 93 of file InexactPredicateLpSeparableMetric.h.
typedef TValue DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::RawValue |
Type for raw distance values.
Definition at line 101 of file InexactPredicateLpSeparableMetric.h.
typedef TSpace DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::Space |
Copy the space type.
Definition at line 87 of file InexactPredicateLpSeparableMetric.h.
typedef TValue DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::Value |
Type for distance values.
Definition at line 99 of file InexactPredicateLpSeparableMetric.h.
typedef Space::Vector DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::Vector |
Type for vectors.
Definition at line 97 of file InexactPredicateLpSeparableMetric.h.
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::InexactPredicateLpSeparableMetric | ( | const double | anExponent | ) |
Constructor.
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::~InexactPredicateLpSeparableMetric | ( | ) |
Destructor.
|
inline |
Copy constructor.
other | the object to clone. |
Definition at line 118 of file InexactPredicateLpSeparableMetric.h.
References DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::myExponent.
|
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.
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 |
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::BOOST_CONCEPT_ASSERT | ( | (concepts::CEuclideanRing< TValue >) | ) |
DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::BOOST_CONCEPT_ASSERT | ( | (concepts::CSpace< TSpace >) | ) |
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.
origin | the origin |
first | the first point |
second | the second point |
|
private |
Compute the Lp distance without the computation of the power 1/p. I.e. only \( \sum |p_i- q_i|^p\) is given.
aP | a first point |
aQ | a second point |
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.
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 testInexactMetrics().
bool DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Value DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::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 | the object to copy. |
Definition at line 128 of file InexactPredicateLpSeparableMetric.h.
References DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::myExponent.
RawValue DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::rawDistance | ( | const Point & | aP, |
const Point & | aQ ) const |
Compute the raw distance between aP and aQ.
aP | a first point. |
aQ | a second point. |
void DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
|
private |
Exponent value.
Definition at line 260 of file InexactPredicateLpSeparableMetric.h.
Referenced by DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::InexactPredicateLpSeparableMetric(), and DGtal::InexactPredicateLpSeparableMetric< TSpace, TValue >::operator=().