VecN

Trait VecN 

Source
pub trait VecN: Sized {
    type Scalar: Scalar;

    const N: usize;
    const ZERO: Self;
Show 24 methods // Required methods fn dim(&self, dim: usize) -> Self::Scalar; fn dim_mut(&mut self, dim: usize) -> &mut Self::Scalar; // Provided methods fn set_dim(&mut self, dim: usize, val: Self::Scalar) { ... } fn add_assign(&mut self, other: Self) { ... } fn add(self, other: Self) -> Self { ... } fn sub_assign(&mut self, other: Self) { ... } fn sub(self, other: Self) -> Self { ... } fn mul_assign(&mut self, by: Self::Scalar) { ... } fn mul(self, by: Self::Scalar) -> Self { ... } fn div_assign(&mut self, by: Self::Scalar) { ... } fn div(self, by: Self::Scalar) -> Self { ... } fn mul2_assign(&mut self, other: Self) { ... } fn mul2(self, other: Self) -> Self { ... } fn div2_assign(&mut self, other: Self) { ... } fn div2(self, other: Self) -> Self { ... } fn neg_assign(&mut self) where Self::Scalar: Neg<Output = Self::Scalar> + Debug { ... } fn neg(self) -> Self where Self::Scalar: Neg<Output = Self::Scalar> + Debug { ... } fn squared_mag(&self) -> Self::Scalar { ... } fn squared_dist(self, other: Self) -> Self::Scalar { ... } fn min_dim(&self) -> Self::Scalar { ... } fn max_dim(&self) -> Self::Scalar { ... } fn dot(self, other: Self) -> Self::Scalar { ... } fn lerp_assign(&mut self, other: Self, t: Self::Scalar) { ... } fn lerp(self, other: Self, t: Self::Scalar) -> Self { ... }
}
Expand description

Trait for basic vector math operations

Required Associated Constants§

Source

const N: usize

The dimensionality of the vector

Source

const ZERO: Self

The zero value

Required Associated Types§

Source

type Scalar: Scalar

The scalar type

Required Methods§

Source

fn dim(&self, dim: usize) -> Self::Scalar

Get the value of a dimension

Source

fn dim_mut(&mut self, dim: usize) -> &mut Self::Scalar

Get a mutable reference to the value of a dimension

Provided Methods§

Source

fn set_dim(&mut self, dim: usize, val: Self::Scalar)

Set the value of a dimension

Source

fn add_assign(&mut self, other: Self)

Add to the vector in place

Source

fn add(self, other: Self) -> Self

Add the vector to another

Source

fn sub_assign(&mut self, other: Self)

Subtract from the vector in place

Source

fn sub(self, other: Self) -> Self

Subtract a vector from the one

Source

fn mul_assign(&mut self, by: Self::Scalar)

Multiply the vector in place

Source

fn mul(self, by: Self::Scalar) -> Self

Multiply the vector by a scalar value

Source

fn div_assign(&mut self, by: Self::Scalar)

Divide the vector in place

Source

fn div(self, by: Self::Scalar) -> Self

Divide the vector by a scalar value

Source

fn mul2_assign(&mut self, other: Self)

Element-wise multiply the vector by another in place

Source

fn mul2(self, other: Self) -> Self

Element-wise multiply the vector by another

Source

fn div2_assign(&mut self, other: Self)

Element-wise divide the vector by another in place

Source

fn div2(self, other: Self) -> Self

Element-wise divide the vector by another

Source

fn neg_assign(&mut self)
where Self::Scalar: Neg<Output = Self::Scalar> + Debug,

Negate the vector in place

Source

fn neg(self) -> Self
where Self::Scalar: Neg<Output = Self::Scalar> + Debug,

Negate the vector

Source

fn squared_mag(&self) -> Self::Scalar

Get the squared magnitude of the vector

Source

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

Get the squared distance between this vector and another

Source

fn min_dim(&self) -> Self::Scalar

Get the minimum dimension

Source

fn max_dim(&self) -> Self::Scalar

Get the maximum dimension

Source

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

Dot the vector with another

Source

fn lerp_assign(&mut self, other: Self, t: Self::Scalar)

Linearly interpolate the vector with another in place

Source

fn lerp(self, other: Self, t: Self::Scalar) -> Self

Linearly interpolate the vector with another

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.

Implementations on Foreign Types§

Source§

impl<T, const N: usize> VecN for [T; N]
where T: Scalar,

Source§

const N: usize = N

Source§

const ZERO: Self

Source§

type Scalar = T

Source§

fn dim(&self, dim: usize) -> Self::Scalar

Source§

fn dim_mut(&mut self, dim: usize) -> &mut Self::Scalar

Implementors§