Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
spatial::euclidian< Ct, DistanceType, Diff > Class Template Reference

Defines a metric working on the Euclidian space where distances are expressed in one of C++'s floating point types. More...

#include <metric.hpp>

Inherits Diff.

Inherited by spatial::details::Compress< euclidian< Ct, DistanceType, Diff >, typename spatial::container_traits< const Ct >::key_type > [private], and spatial::details::Compress< euclidian< Ct, DistanceType, Diff >, typename spatial::container_traits< Ct >::key_type > [private].

Public Types

typedef details::rebind_builtin_difference< Diff, DistanceType >::type difference_type
 The type used to compute the difference between 2 keys along the same dimension. More...
 
typedef DistanceType distance_type
 The distance type being used for distance calculations. More...
 

Public Member Functions

 euclidian (const difference_type &diff=Diff())
 The constructors allows you to specify a custom difference type. More...
 
template<typename AnyDistanceType >
 euclidian (const euclidian< Ct, AnyDistanceType, Diff > &other)
 Copy the metric from another metric with any DistanceType. More...
 
distance_type distance_to_key (dimension_type rank, const key_type &origin, const key_type &key) const
 Compute the distance between the point of origin and the key. More...
 
distance_type distance_to_plane (dimension_type, dimension_type dim, const key_type &origin, const key_type &key) const
 The distance between the point of origin and the closest point to the plane orthogonal to the axis of dimension dim and crossing key. More...
 
difference_type difference () const
 Returns the difference functor used in this type. More...
 

Private Types

typedef enable_if< import::is_floating_point< DistanceType > >::type check_concept_distance_type_is_floating_point
 
typedef container_traits< Ct >::key_type key_type
 The key_type of the container being used for calculations. More...
 

Detailed Description

template<typename Ct, typename DistanceType, typename Diff>
class spatial::euclidian< Ct, DistanceType, Diff >

Defines a metric working on the Euclidian space where distances are expressed in one of C++'s floating point types.

Concept:
This object is a model of Metric
Attention
This metric works on floating types only. It will fail to compile if given non-floating types as a parameter for the distance.

euclidian uses square root calculation in the distance. It will return proper distances therefore but will be slower than quadrance. When defining SPATIAL_SAFER_ARITHMETICS however, euclidian uses the hypot algorithm which has much less chance to overflow or underflow than quadrance. However is it also much slower.

Definition at line 42 of file metric.hpp.

Member Typedef Documentation

template<typename Ct, typename DistanceType, typename Diff>
typedef enable_if<import::is_floating_point<DistanceType> >::type spatial::euclidian< Ct, DistanceType, Diff >::check_concept_distance_type_is_floating_point
private

Definition at line 46 of file metric.hpp.

template<typename Ct, typename DistanceType, typename Diff>
typedef details::rebind_builtin_difference<Diff, DistanceType>::type spatial::euclidian< Ct, DistanceType, Diff >::difference_type

The type used to compute the difference between 2 keys along the same dimension.

Definition at line 54 of file metric.hpp.

template<typename Ct, typename DistanceType, typename Diff>
typedef DistanceType spatial::euclidian< Ct, DistanceType, Diff >::distance_type

The distance type being used for distance calculations.

Definition at line 66 of file metric.hpp.

template<typename Ct, typename DistanceType, typename Diff>
typedef container_traits<Ct>::key_type spatial::euclidian< Ct, DistanceType, Diff >::key_type
private

The key_type of the container being used for calculations.

Definition at line 60 of file metric.hpp.

Constructor & Destructor Documentation

template<typename Ct, typename DistanceType, typename Diff>
spatial::euclidian< Ct, DistanceType, Diff >::euclidian ( const difference_type diff = Diff())
explicit

The constructors allows you to specify a custom difference type.

Definition at line 69 of file metric.hpp.

template<typename Ct, typename DistanceType, typename Diff>
template<typename AnyDistanceType >
spatial::euclidian< Ct, DistanceType, Diff >::euclidian ( const euclidian< Ct, AnyDistanceType, Diff > &  other)

Copy the metric from another metric with any DistanceType.

Definition at line 73 of file metric.hpp.

Member Function Documentation

template<typename Ct, typename DistanceType, typename Diff>
difference_type spatial::euclidian< Ct, DistanceType, Diff >::difference ( ) const

Returns the difference functor used in this type.

Definition at line 111 of file metric.hpp.

template<typename Ct, typename DistanceType, typename Diff>
distance_type spatial::euclidian< Ct, DistanceType, Diff >::distance_to_key ( dimension_type  rank,
const key_type origin,
const key_type key 
) const

Compute the distance between the point of origin and the key.

Returns
The resulting distance.

Definition at line 81 of file metric.hpp.

template<typename Ct, typename DistanceType, typename Diff>
distance_type spatial::euclidian< Ct, DistanceType, Diff >::distance_to_plane ( dimension_type  ,
dimension_type  dim,
const key_type origin,
const key_type key 
) const

The distance between the point of origin and the closest point to the plane orthogonal to the axis of dimension dim and crossing key.

Given any 2 points 'origin' and 'key', the result of distance_to_plane must always be less or equal to the result of distance_to_key.

Returns
The resulting distance.

Definition at line 100 of file metric.hpp.


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