DGtal
1.5.beta
|
Aim: implements l_p metrics. More...
#include <DGtal/geometry/volumes/distance/LpMetric.h>
Public Types | |
typedef TSpace | Space |
Copy the space type. More... | |
typedef Space::RealPoint | Point |
Type for points (RealPoint for this class) More... | |
typedef double | Value |
Type for distance values. More... | |
typedef double | RawValue |
Type for raw distance values. More... | |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >)) | |
LpMetric (const double anExponent) | |
~LpMetric () | |
LpMetric (const LpMetric &other) | |
LpMetric & | operator= (const LpMetric &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 |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Private Attributes | |
Value | myExponent |
Exponent value. More... | |
Aim: implements l_p metrics.
Description of template class 'LpMetric'
Given a parameter p, the class implements classical l_p metric as a model of CMetricSpace. Hence, given two points \( x=(x_0...x_{n-1})\), \( y=(y_0...y_{n-1})\), we define a metric as:
\( distance(x,y)= \left( \sum_{i=0}^{n-1} |x_i-y_i|^p\right)^{1/p}\)
This class performs all computations on C++ double converting the digital points to Space::RealPoint
The exponent p is specifed at the constructor.
TSpace | the model of CSpace on which the metric is defined. |
Definition at line 74 of file LpMetric.h.
typedef Space::RealPoint DGtal::LpMetric< TSpace >::Point |
Type for points (RealPoint for this class)
Definition at line 84 of file LpMetric.h.
typedef double DGtal::LpMetric< TSpace >::RawValue |
Type for raw distance values.
Definition at line 88 of file LpMetric.h.
typedef TSpace DGtal::LpMetric< TSpace >::Space |
Copy the space type.
Definition at line 80 of file LpMetric.h.
typedef double DGtal::LpMetric< TSpace >::Value |
Type for distance values.
Definition at line 86 of file LpMetric.h.
|
inline |
Constructor.
anExponent | the exponent (p) of the lp metric. |
Definition at line 95 of file LpMetric.h.
|
inline |
|
inline |
Copy constructor.
other | the object to clone. |
Definition at line 109 of file LpMetric.h.
References DGtal::LpMetric< TSpace >::myExponent.
DGtal::LpMetric< TSpace >::BOOST_CONCEPT_ASSERT | ( | (concepts::CSpace< TSpace >) | ) |
|
inline |
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 |
Definition at line 170 of file LpMetric.h.
References DGtal::ClosestBOTH, DGtal::ClosestFIRST, DGtal::ClosestSECOND, and DGtal::LpMetric< TSpace >::rawDistance().
Referenced by TEST_CASE().
|
inline |
Checks the validity/consistency of the object.
Definition at line 198 of file LpMetric.h.
|
inline |
Compute the distance between aP and aQ.
aP | a first point. |
aQ | a second point. |
Definition at line 137 of file LpMetric.h.
References DGtal::LpMetric< TSpace >::myExponent, and DGtal::LpMetric< TSpace >::rawDistance().
|
inline |
Assignment.
other | the object to copy. |
Definition at line 119 of file LpMetric.h.
References DGtal::LpMetric< TSpace >::myExponent.
|
inline |
Compute the raw distance between aP and aQ.
aP | a first point. |
aQ | a second point. |
Definition at line 150 of file LpMetric.h.
References DGtal::LpMetric< TSpace >::myExponent, and DGtal::PointVector< dim, TEuclideanRing, TContainer >::size().
Referenced by DGtal::LpMetric< TSpace >::closest(), DGtal::LpMetric< TSpace >::operator()(), and TEST_CASE().
|
inline |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Definition at line 189 of file LpMetric.h.
References DGtal::LpMetric< TSpace >::myExponent.
|
private |
Exponent value.
Definition at line 207 of file LpMetric.h.
Referenced by DGtal::LpMetric< TSpace >::LpMetric(), DGtal::LpMetric< TSpace >::operator()(), DGtal::LpMetric< TSpace >::operator=(), DGtal::LpMetric< TSpace >::rawDistance(), and DGtal::LpMetric< TSpace >::selfDisplay().