Skip to main content

Point

Trait Point 

Source
pub trait Point: Copy {
    type Scalar: Scalar;
    type Vector: Vector<Scalar = Self::Scalar>;

    // Required methods
    fn displacement(self, other: Self) -> Self::Vector;
    fn translate(self, v: Self::Vector) -> Self;

    // Provided method
    fn distance(self, other: Self) -> Self::Scalar { ... }
}
Expand description

A position in an affine space, parameterized by its scalar and vector types.

Points represent positions. They cannot be added, but a displacement from one point to another yields a Vector, and translating a point by a Vector yields another point.

Required Associated Types§

Source

type Scalar: Scalar

Scalar type for distances and coordinates.

Source

type Vector: Vector<Scalar = Self::Scalar>

Vector type for displacements and derivatives.

Required Methods§

Source

fn displacement(self, other: Self) -> Self::Vector

Displacement from self to other (i.e. other - self).

Source

fn translate(self, v: Self::Vector) -> Self

Translate this point by a vector, returning a new point.

Provided Methods§

Source

fn distance(self, other: Self) -> Self::Scalar

Euclidean distance between two points.

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.

Implementors§