[][src]Trait ball_tree::Point

pub trait Point: Sized + PartialEq {
    fn distance(&self, other: &Self) -> f64;
fn move_towards(&self, other: &Self, d: f64) -> Self; }

A Point is something that exists in some sort of metric space, and can thus calculate its distance to another Point, and can be moved a certain distance towards another Point.

Required methods

fn distance(&self, other: &Self) -> f64

Distances should be positive, finite f64s. It is undefined behavior to return a negative, infinite, or NaN result.

Distance should satisfy the triangle inequality. That is, a.distance(c) must be less or equal to than a.distance(b) + b.distance(c).

fn move_towards(&self, other: &Self, d: f64) -> Self

If d is 0, a point equal to the self should be returned. If d is equal to self.distance(other), a point equal to other should be returned. Intermediate distances should be linearly interpolated between the two points, so if d is equal to self.distance(other) / 2.0, the midpoint should be returned. It is undefined behavior to use a distance that is negative, NaN, or greater than self.distance(other).

Loading content...

Implementors

Loading content...