[−][src]Trait acap::distance::Proximity
A space with some notion of distance between points.
There are no restrictions on the distances returned by spaces that implement only Proximity
.
In particular, they may be asymmetric or even negative. If a space meets the restrictions of
the Metric
trait, it should be implemented as well. Spaces that satisfy those rules, at
least approximately, often allow for more accurate and efficient searches.
Proximity<T>
is generic, to allow comparisons between objects of related but distinct types.
For example:
// A GPS coordinate struct Gps { lat: f64, long: f64, } // For computing distances between GPS coordinates impl Proximity for Gps { type Distance = HaversineDistance; fn distance(&self, other: &Self) -> Self::Distance { haversine_distance(self, other) } } // A point of interest with a known location, name, ... struct PointOfInterest { location: Gps, name: String, // ... } // Compute the distance between a GPS coordinate and a point of interest, // by delegating to the Proximity impl for Gps impl Proximity<PointOfInterest> for Gps { type Distance = <Gps as Proximity>::Distance; fn distance(&self, other: &PointOfInterest) -> Self::Distance { self.distance(&other.location) } }
With those implementations available, you could use a NearestNeighbors<Gps, PointOfInterest>
instance to find the closest point(s) of interest to any GPS location.
Associated Types
Loading content...Required methods
fn distance(&self, other: &T) -> Self::Distance
Calculate the distance between this point and another one.
Implementations on Foreign Types
impl<'k, 'v, K: Proximity<V>, V> Proximity<&'v V> for &'k K
[src]
Blanket Proximity
implementation for references.
Implementors
impl<T> Proximity<Angular<T>> for Angular<T> where
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
[src]
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
impl<T> Proximity<Angular<T>> for T where
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
[src]
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
type Distance = AngularDistance<T::Value>
fn distance(&self, other: &Angular<T>) -> Self::Distance
[src]
impl<T> Proximity<Cosine<T>> for Cosine<T> where
T: Coordinates,
T::Value: Real,
[src]
T: Coordinates,
T::Value: Real,
impl<T> Proximity<Cosine<T>> for T where
T: Coordinates,
T::Value: Real,
[src]
T: Coordinates,
T::Value: Real,
impl<T> Proximity<PrenormAngular<T>> for PrenormAngular<T> where
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
[src]
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
impl<T> Proximity<PrenormAngular<T>> for T where
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
[src]
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
type Distance = AngularDistance<T::Value>
fn distance(&self, other: &PrenormAngular<T>) -> Self::Distance
[src]
impl<T> Proximity<PrenormCosine<T>> for PrenormCosine<T> where
T: Coordinates,
T::Value: Real,
[src]
T: Coordinates,
T::Value: Real,
impl<T> Proximity<PrenormCosine<T>> for T where
T: Coordinates,
T::Value: Real,
[src]
T: Coordinates,
T::Value: Real,
impl<T> Proximity<Euclidean<T>> for Euclidean<T> where
T: Coordinates,
EuclideanDistance<T::Value>: Distance,
[src]
T: Coordinates,
EuclideanDistance<T::Value>: Distance,
The Euclidean distance function.
impl<T> Proximity<Euclidean<T>> for T where
T: Coordinates,
EuclideanDistance<T::Value>: Distance,
[src]
T: Coordinates,
EuclideanDistance<T::Value>: Distance,
type Distance = EuclideanDistance<T::Value>
fn distance(&self, other: &Euclidean<T>) -> Self::Distance
[src]
impl<T> Proximity<T> for Angular<T> where
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
[src]
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
impl<T> Proximity<T> for Cosine<T> where
T: Coordinates,
T::Value: Real,
[src]
T: Coordinates,
T::Value: Real,
impl<T> Proximity<T> for PrenormAngular<T> where
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
[src]
T: Coordinates,
T::Value: Real,
AngularDistance<T::Value>: Distance,
impl<T> Proximity<T> for PrenormCosine<T> where
T: Coordinates,
T::Value: Real,
[src]
T: Coordinates,
T::Value: Real,
impl<T> Proximity<T> for Euclidean<T> where
T: Coordinates,
EuclideanDistance<T::Value>: Distance,
[src]
T: Coordinates,
EuclideanDistance<T::Value>: Distance,
impl<T: Coordinates> Proximity<Chebyshev<T>> for Chebyshev<T>
[src]
The Chebyshev distance function.
impl<T: Coordinates> Proximity<Chebyshev<T>> for T
[src]
impl<T: Coordinates> Proximity<Taxicab<T>> for Taxicab<T>
[src]
The taxicab distance function.
impl<T: Coordinates> Proximity<Taxicab<T>> for T
[src]
impl<T: Coordinates> Proximity<T> for Chebyshev<T>
[src]
impl<T: Coordinates> Proximity<T> for Taxicab<T>
[src]
impl<T: PrimInt> Proximity<Hamming<T>> for Hamming<T>
[src]
The hamming distance function.