Trait spade::PointN
[−]
[src]
pub trait PointN where Self: Clone, Self: Debug, Self: 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; }
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.
Associated Types
Required Methods
fn dimensions() -> usize
The (fixed) number of dimensions of this point type.
fn from_value(value: Self::Scalar) -> Self
Creates a new point with all compoenents set to a certain value.
fn nth(&self, index: usize) -> &Self::Scalar
Returns the nth element of this point.
fn nth_mut(&mut self, index: usize) -> &mut Self::Scalar
Returns a mutable reference to the nth element of this point.
Implementors
impl<S: SpadeNum + Copy> PointN for [S; 2]
impl<S: SpadeNum + Copy> PointN for [S; 3]
impl<S: SpadeNum + Copy> PointN for [S; 4]
impl<S: SpadeNum + BaseNum> PointN for Point2<S>
impl<S: SpadeNum + BaseNum> PointN for Point3<S>
impl<S: SpadeNum + Scalar> PointN for nalgebra::geometry::point_alias::Point2<S>
impl<S: SpadeNum + Scalar> PointN for nalgebra::geometry::point_alias::Point3<S>
impl<S: SpadeNum + Scalar + Scalar> PointN for Point4<S>