[][src]Trait spade::PointN

pub trait PointN where
    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; }

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 of TwoDimensional or ThreeDimensional should be given if appropriate.

Associated Types

type Scalar: SpadeNum

The points's internal scalar type.

Loading content...

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 components 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.

Loading content...

Implementations on Foreign Types

impl<S: SpadeNum + Copy> PointN for [S; 2][src]

type Scalar = S

impl<S: SpadeNum + Copy> PointN for [S; 3][src]

type Scalar = S

impl<S: SpadeNum + Copy> PointN for [S; 4][src]

type Scalar = S

impl<S: SpadeNum + BaseNum> PointN for Point2<S>[src]

type Scalar = S

impl<S: SpadeNum + BaseNum> PointN for Point3<S>[src]

type Scalar = S

impl<S: SpadeNum + Scalar> PointN for Point2<S>[src]

type Scalar = S

impl<S: SpadeNum + Scalar> PointN for Point3<S>[src]

type Scalar = S

impl<S: SpadeNum + Scalar> PointN for Point4<S>[src]

type Scalar = S

Loading content...

Implementors

Loading content...