Skip to main content

VecN

Trait VecN 

Source
pub trait VecN<T: Number>:
    Base<T>
    + Dot<T>
    + Index<usize, Output = T>
    + IndexMut<usize>
    + Add<T, Output = Self>
    + Sub<T, Output = Self>
    + Mul<T, Output = Self>
    + Div<T, Output = Self> {
Show 20 methods // Required methods fn len() -> usize; fn all(a: Self) -> bool; fn any(a: Self) -> bool; fn unit_x() -> Self; fn unit_y() -> Self; fn unit_z() -> Self; fn unit_w() -> Self; fn red() -> Self; fn green() -> Self; fn blue() -> Self; fn cyan() -> Self; fn magenta() -> Self; fn yellow() -> Self; fn black() -> Self; fn white() -> Self; fn as_slice(&self) -> &[T]; fn as_mut_slice(&mut self) -> &mut [T]; fn as_u8_slice(&self) -> &[u8] ; fn max_scalar(a: Self) -> T; fn min_scalar(a: Self) -> T;
}
Expand description

generic vec trait to allow sized vectors to be treated generically

Required Methods§

Source

fn len() -> usize

returns the count of elements in the vector type

Source

fn all(a: Self) -> bool

returns true if all elements in vector a are non-zero

Source

fn any(a: Self) -> bool

returns true if any element of the vector a is non-zero

Source

fn unit_x() -> Self

returns a vector initialised as a unit vector in the x-axis [1, 0, 0, 0]

Source

fn unit_y() -> Self

returns a vector initialised as a unit vector in the y-axis [0, 1, 0, 0]

Source

fn unit_z() -> Self

returns a vector initialised as a unit vector in the z-axis [0, 0, 1, 0] value will be truncated to 0 for vectors < 3 dimension

Source

fn unit_w() -> Self

returns a vector initialised as a unit vector in the w-axis [0, 0, 0, 1] value will be truncated to 0 for vectors < 4 dimension

Source

fn red() -> Self

returns a vector initialised to red [1, 0, 0, 1]

Source

fn green() -> Self

returns a vector initialised to green [0, 1, 0, 1]

Source

fn blue() -> Self

returns a vector initialised to blue [0, 0, 1, 1] value will be truncated to 0 for vectors < 3 dimension

Source

fn cyan() -> Self

returns a vector initialised to cyan [0, 1, 1, 1] value will be truncated to green for vectors < 3 dimension

Source

fn magenta() -> Self

returns a vector initialised to magenta [1, 0, 1, 1] value will be truncated to red for vectors < 3 dimension

Source

fn yellow() -> Self

returns a vector initialised to yellow [1, 1, 0, 0]

Source

fn black() -> Self

returns a vector initialised to black (zero’s)

Source

fn white() -> Self

returns a vector initialised to white (ones’s)

Source

fn as_slice(&self) -> &[T]

returns a slice T of the vector

Source

fn as_mut_slice(&mut self) -> &mut [T]

returns a mutable slice T of the vector

Source

fn as_u8_slice(&self) -> &[u8]

returns a slice of bytes for the vector

Source

fn max_scalar(a: Self) -> T

returns the largest scalar value component contained in the vector a

Source

fn min_scalar(a: Self) -> T

returns the smallest scalar value component contained in the vector a

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.

Implementors§

Source§

impl<T> VecN<T> for Vec2<T>
where T: Number,

Source§

impl<T> VecN<T> for Vec3<T>
where T: Number,

Source§

impl<T> VecN<T> for Vec4<T>
where T: Number,