Trait cgmath::Vector

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

    // Required methods
    fn from_value(scalar: Self::Scalar) -> Self;
    fn dot(self, other: Self) -> Self::Scalar;

    // Provided method
    fn zero() -> Self { ... }
}
Expand description

A trait that specifies a range of numeric operations for vectors. Not all of these make sense from a linear algebra point of view, but are included for pragmatic reasons.

Required Associated Types§

source

type Scalar: BaseNum

The associated scalar.

Required Methods§

source

fn from_value(scalar: Self::Scalar) -> Self

Construct a vector from a single value, replicating it.

source

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

Vector dot product

Provided Methods§

source

fn zero() -> Self

The additive identity vector. Adding this vector with another has no effect.

Implementors§

source§

impl<S: BaseNum> Vector for Vector2<S>

§

type Scalar = S

source§

impl<S: BaseNum> Vector for Vector3<S>

§

type Scalar = S

source§

impl<S: BaseNum> Vector for Vector4<S>

§

type Scalar = S