Trait micromath::vector::Vector

source ·
pub trait Vector<C>: Copy + Debug + Default + FromIterator<C> + Send + Syncwhere
    C: Component,{
    const AXES: usize;

    // Required methods
    fn get(self, index: usize) -> Option<C>;
    fn dot(self, rhs: Self) -> C;

    // Provided methods
    fn from_slice(slice: &[C]) -> Self { ... }
    fn iter(&self) -> Iter<'_, Self, C>  { ... }
    fn distance(self, rhs: Self) -> f32
       where C: Into<f32> { ... }
    fn magnitude(self) -> f32
       where C: Into<f32> { ... }
}
Available on crate feature vector only.
Expand description

Algebraic vector generic over a given Component type.

Required Associated Constants§

source

const AXES: usize

Number of axes

Required Methods§

source

fn get(self, index: usize) -> Option<C>

Get the component value for a particular index

source

fn dot(self, rhs: Self) -> C

Compute the dot product of two vectors

Provided Methods§

source

fn from_slice(slice: &[C]) -> Self

Instantiate a vector from a slice of components.

Panics if the slice is not the right size.

source

fn iter(&self) -> Iter<'_, Self, C>

Iterate over the components of this vector

source

fn distance(self, rhs: Self) -> f32where C: Into<f32>,

Compute the distance between two vectors

source

fn magnitude(self) -> f32where C: Into<f32>,

Compute the magnitude of a vector

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<C> Vector<C> for Vector2d<C>where C: Component,

source§

const AXES: usize = 2usize

source§

impl<C> Vector<C> for Vector3d<C>where C: Component,

source§

const AXES: usize = 3usize