Trait cgmath::Point

source ·
pub trait Point: Copy + Clonewhere
    Self: Array<Element = Self::Scalar>,{
    type Scalar: BaseNum;
    type Vector: Vector<Scalar = Self::Scalar>;

Show 15 methods // Required methods fn origin() -> Self; fn from_vec(v: Self::Vector) -> Self; fn to_vec(self) -> Self::Vector; fn mul_s(self, scalar: Self::Scalar) -> Self; fn div_s(self, scalar: Self::Scalar) -> Self; fn rem_s(self, scalar: Self::Scalar) -> Self; fn add_v(self, v: Self::Vector) -> Self; fn sub_p(self, p: Self) -> Self::Vector; fn mul_self_s(&mut self, scalar: Self::Scalar); fn div_self_s(&mut self, scalar: Self::Scalar); fn rem_self_s(&mut self, scalar: Self::Scalar); fn add_self_v(&mut self, v: Self::Vector); fn dot(self, v: Self::Vector) -> Self::Scalar; fn min(self, p: Self) -> Self; fn max(self, p: Self) -> Self;
}
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 mul_s(self, scalar: Self::Scalar) -> Self

Multiply each component by a scalar, returning the new point.

source

fn div_s(self, scalar: Self::Scalar) -> Self

Divide each component by a scalar, returning the new point.

source

fn rem_s(self, scalar: Self::Scalar) -> Self

Subtract a scalar from each component, returning the new point.

source

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

Add a vector to this point, returning the new point.

source

fn sub_p(self, p: Self) -> Self::Vector

Subtract another point from this one, returning a new vector.

source

fn mul_self_s(&mut self, scalar: Self::Scalar)

Multiply each component by a scalar, in-place.

source

fn div_self_s(&mut self, scalar: Self::Scalar)

Divide each component by a scalar, in-place.

source

fn rem_self_s(&mut self, scalar: Self::Scalar)

Take the remainder of each component by a scalar, in-place.

source

fn add_self_v(&mut self, v: Self::Vector)

Add a vector to this point, in-place.

source

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

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

source

fn min(self, p: Self) -> Self

source

fn max(self, p: Self) -> Self

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>