Trait cgmath::Vector

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

Show 24 methods // Required methods fn from_value(scalar: Self::Scalar) -> Self; fn add_s(self, scalar: Self::Scalar) -> Self; fn sub_s(self, scalar: Self::Scalar) -> Self; 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) -> Self; fn sub_v(self, v: Self) -> Self; fn mul_v(self, v: Self) -> Self; fn div_v(self, v: Self) -> Self; fn rem_v(self, v: Self) -> Self; fn add_self_s(&mut self, scalar: Self::Scalar); fn sub_self_s(&mut self, scalar: Self::Scalar); 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); fn sub_self_v(&mut self, v: Self); fn mul_self_v(&mut self, v: Self); fn div_self_v(&mut self, v: Self); fn rem_self_v(&mut self, v: Self); fn dot(self, other: Self) -> Self::Scalar; // Provided methods fn zero() -> Self { ... } fn one() -> 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 add_s(self, scalar: Self::Scalar) -> Self

Add a scalar to this vector, returning a new vector.

source

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

Subtract a scalar from this vector, returning a new vector.

source

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

Multiply this vector by a scalar, returning a new vector.

source

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

Divide this vector by a scalar, returning a new vector.

source

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

Take the remainder of this vector by a scalar, returning a new vector.

source

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

Add this vector to another, returning a new vector.

source

fn sub_v(self, v: Self) -> Self

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

source

fn mul_v(self, v: Self) -> Self

Multiply this vector by another, returning a new vector.

source

fn div_v(self, v: Self) -> Self

Divide this vector by another, returning a new vector.

source

fn rem_v(self, v: Self) -> Self

Take the remainder of this vector by another, returning a new scalar.

source

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

Add a scalar to this vector in-place.

source

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

Subtract a scalar from this vector, in-place.

source

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

Multiply this vector by a scalar, in-place.

source

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

Divide this vector by a scalar, in-place.

source

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

Take the remainder of this vector by a scalar, in-place.

source

fn add_self_v(&mut self, v: Self)

Add another vector to this one, in-place.

source

fn sub_self_v(&mut self, v: Self)

Subtract another vector from this one, in-place.

source

fn mul_self_v(&mut self, v: Self)

Multiply this matrix by another, in-place.

source

fn div_self_v(&mut self, v: Self)

Divide this matrix by anothor, in-place.

source

fn rem_self_v(&mut self, v: Self)

Take the remainder of this vector by another, in-place.

source

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

Vector dot product

Provided Methods§

source

fn zero() -> Self

The zero vector (with all components set to zero)

source

fn one() -> Self

The identity vector (with all components set to one)

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