struct DGtal::concepts::CMetricSpace< T >
Aim: defines the concept of metric spaces.
Description of concept 'CMetricSpace'
Models of metric spaces must satsify metric space conditions as described in Metric Spaces, Digital Metric Spaces and Related Concepts. For short, models must have a Point inner type and a distance Value type.
In addition, CMetricSpace models should implement a distance function (operator ()) on points satisfying the metric conditions:
- d(x,y) >= 0
- d(x,y) == 0 <=> x==y
- d(x,y) == d(y,x) (symmetry)
- d(x,y) <= d(x,z) + d(z,y) (triangle inequality)
Two additional methods must be implemented:
- rawDistance(x,y) method provides internal distance representation between two points. For example, a convenient way to have an exact representation of hte Euclidean metric is to consider its square which can be represented error free on a CInteger type for example. In this case, the rawDistance method returns the square of the Euclidean distance between the two points in an exact way as soon as the internal RawValue type is error free and can represents sum of squares of Point::Coordiante values.
- closest(a,x,y) decides which point between x and y is closest to a. This method is required for performance purposes.
Associated types :
- Space: type of space on which the metric is defined (model of CSpace).
- Point: type of points associated with the underlying metric space.
- Value: the value type of the metric (model of CQuantity).
- RawValue: the value type for the rawDistance method (model of CQuantity).
- X : A type that is a model of CMetricSpace
- x, y : object of type X
Valid expressions and semantics
|Name ||Expression ||Type requirements ||Return type ||Precondition ||Semantics ||Post condition ||Complexity |
|distance computation ||x(aPoint,anotherPoint) ||aPoint and anotherPoint of type Point ||a value of type Value ||compute the distance between two points ||- |
|raw distance computation ||x.rawDistance(aPoint,anotherPoint) ||aPoint and anotherPoint of type Point ||a value of type RawValue ||compute the raw representation of the distance between two points ||- |
|closest point test ||closest(aOrigin, aP, aQ) ||aOrigin, aP,aQ of type aPoint ||a value of type Closest ||decide between aP and aQ which one is closer to the origin. This functions returns either DGtal::ClosestFIRST if aP is closer, DGtal::ClosestSECOND if aQ is closer and DGtal::ClosestBOTH if both are equidistant.||- |
- Template Parameters
Definition at line 124 of file CMetricSpace.h.