pub trait PointNwhere
Self: Clone + Debug + PartialEq,{
type Scalar: SpadeNum;
fn dimensions() -> usize;
fn from_value(value: Self::Scalar) -> Self;
fn nth(&self, index: usize) -> &Self::Scalar;
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar;
}
Expand description
Abstraction over a point with a fixed number of dimensions.
Spade will work with any point type implementing this trait, at the
moment points of the cgmath
and nalgebra
crates are supported.
Also, the trait is implemented for fixed arrays of length 2, 3 and 4, allowing
to use spade’s datastructures with fixed size arrays as point coordinates.
That means that the trait’s methods are also implemented for
these array types, thus be careful when importing PointN
.
Implement this if you want spade to support your own point types.
Also, an empty implementation TwoDimensional
or ThreeDimensional
should be given if appropriate.
Required Associated Types
Required Methods
sourcefn dimensions() -> usize
fn dimensions() -> usize
The (fixed) number of dimensions of this point type.
sourcefn from_value(value: Self::Scalar) -> Self
fn from_value(value: Self::Scalar) -> Self
Creates a new point with all components set to a certain value.