Trait Vector

Source
pub trait Vector<C>:
    Copy
    + Debug
    + Default
    + FromIterator<C>
    + Send
    + Sync
where 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) -> f32
where C: Into<f32>,

Compute the distance between two vectors

Source

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

Compute the magnitude of a vector

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<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