Trait cgmath::Point

source ·
pub trait Point: Copy + Clonewhere
    Self: Array<Element = Self::Scalar> + Add<Self::Vector, Output = Self> + Sub<Self, Output = Self::Vector> + Mul<Self::Scalar, Output = Self> + Div<Self::Scalar, Output = Self> + Rem<Self::Scalar, Output = Self>,{
    type Scalar: BaseNum;
    type Vector: Vector<Scalar = Self::Scalar>;

    // Required methods
    fn origin() -> Self;
    fn from_vec(v: Self::Vector) -> Self;
    fn to_vec(self) -> Self::Vector;
    fn dot(self, v: Self::Vector) -> Self::Scalar;
}
Expand description

Specifies the numeric operations for point types.

Required Associated Types§

source

type Scalar: BaseNum

The associated scalar.

Due to the equality constraints demanded by Self::Vector, this is effectively just an alias to Self::Vector::Scalar.

source

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

The associated displacement vector.

Required Methods§

source

fn origin() -> Self

Create a point at the origin.

source

fn from_vec(v: Self::Vector) -> Self

Create a point from a vector.

source

fn to_vec(self) -> Self::Vector

Convert a point to a vector.

source

fn dot(self, v: Self::Vector) -> Self::Scalar

This is a weird one, but its useful for plane calculations.

Implementors§

source§

impl<S: BaseNum> Point for Point2<S>

§

type Scalar = S

§

type Vector = Vector2<S>

source§

impl<S: BaseNum> Point for Point3<S>

§

type Scalar = S

§

type Vector = Vector3<S>