DistanceMetric

Trait DistanceMetric 

Source
pub trait DistanceMetric<T: SpatialScalar, P: SpatialPoint<T>> {
    // Required methods
    fn distance(&self, p1: &P, p2: &P) -> T;
    fn name(&self) -> &'static str;

    // Provided methods
    fn squared_distance(&self, p1: &P, p2: &P) -> Option<T> { ... }
    fn is_metric(&self) -> bool { ... }
}
Expand description

Trait for distance metrics

Required Methods§

Source

fn distance(&self, p1: &P, p2: &P) -> T

Calculate distance between two points

Source

fn name(&self) -> &'static str

Get the name of this distance metric

Provided Methods§

Source

fn squared_distance(&self, p1: &P, p2: &P) -> Option<T>

Calculate squared distance (if applicable, for efficiency)

Source

fn is_metric(&self) -> bool

Check if this metric satisfies the triangle inequality

Implementors§