pub trait SpatialPoint<T: SpatialScalar> {
// Required methods
fn dimension(&self) -> usize;
fn coordinate(&self, index: usize) -> Option<T>;
fn from_coords(coords: &[T]) -> Self;
// Provided methods
fn as_slice(&self) -> Option<&[T]> { ... }
fn squared_distance_to(&self, other: &Self) -> T { ... }
fn distance_to(&self, other: &Self) -> T { ... }
fn manhattan_distance_to(&self, other: &Self) -> T { ... }
}Expand description
Trait for types that can represent a point in space
This trait abstracts over different point representations, allowing algorithms to work with vectors, arrays, and custom types.
Required Methods§
Sourcefn coordinate(&self, index: usize) -> Option<T>
fn coordinate(&self, index: usize) -> Option<T>
Get the coordinate at the given index
Sourcefn from_coords(coords: &[T]) -> Self
fn from_coords(coords: &[T]) -> Self
Create a point from coordinates
Provided Methods§
Sourcefn squared_distance_to(&self, other: &Self) -> T
fn squared_distance_to(&self, other: &Self) -> T
Calculate squared Euclidean distance to another point
Sourcefn distance_to(&self, other: &Self) -> T
fn distance_to(&self, other: &Self) -> T
Calculate Euclidean distance to another point
Sourcefn manhattan_distance_to(&self, other: &Self) -> T
fn manhattan_distance_to(&self, other: &Self) -> T
Calculate Manhattan distance to another point
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<T: SpatialScalar> SpatialPoint<T> for &[T]
Implementation of SpatialPoint for slices
impl<T: SpatialScalar> SpatialPoint<T> for &[T]
Implementation of SpatialPoint for slices
Source§impl<T: SpatialScalar> SpatialPoint<T> for Vec<T>
Implementation of SpatialPoint for Vec<T>
impl<T: SpatialScalar> SpatialPoint<T> for Vec<T>
Implementation of SpatialPoint for Vec<T>
Source§impl<T: SpatialScalar> SpatialPoint<T> for Array1<T>
Implementation of SpatialPoint for ndarray Array1
impl<T: SpatialScalar> SpatialPoint<T> for Array1<T>
Implementation of SpatialPoint for ndarray Array1
Source§impl<T: SpatialScalar> SpatialPoint<T> for ArrayView1<'_, T>
Implementation of SpatialPoint for ndarray ArrayView1
impl<T: SpatialScalar> SpatialPoint<T> for ArrayView1<'_, T>
Implementation of SpatialPoint for ndarray ArrayView1
Source§impl<T: SpatialScalar, const N: usize> SpatialPoint<T> for [T; N]
Implementation of SpatialPoint for arrays
impl<T: SpatialScalar, const N: usize> SpatialPoint<T> for [T; N]
Implementation of SpatialPoint for arrays