Struct Vector

Source
pub struct Vector<E, const LEN: usize>(pub [E; LEN])
where
    E: MatEl;
Expand description

A vector structure.

Tuple Fields§

§0: [E; LEN]

Implementations§

Source§

impl<E: MatEl + NdFloat, const LEN: usize> Vector<E, LEN>

Source

pub fn normalize(self) -> Self

Normalizes the vector

Source

pub fn mag(&self) -> E

Compute the length of the vector

Source

pub fn mag2(&self) -> E

Computer the squared length of the vector

Source

pub fn min(self, rhs: Self) -> Self

Compute a vector, whose elements are minimum of both vectors: r[ i ] = a[ i ].min( b [ i ] )

Source

pub fn max(self, rhs: Self) -> Self

Compute a vector, whose elements are maximum of both vectors: r[ i ] = a[ i ].max( b [ i ] )

Source

pub fn distance(&self, rhs: &Self) -> E

Computes length of the vector between two points in space

Source

pub fn distance_squared(&self, rhs: &Self) -> E

Computes squared length of the vector between two points in space

Source§

impl<E, const LEN: usize> Vector<E, LEN>
where E: MatEl,

Source

pub fn to_array(&self) -> [E; LEN]

Source§

impl<E: MatEl + NdFloat> Vector<E, 2>

Source

pub fn x(&self) -> E

Source

pub fn y(&self) -> E

Source§

impl Vector<f32, 2>

Source

pub const X: Self

Unit x vector

Source

pub const Y: Self

Unit y vector

Source

pub const MIN: Self

All elements are f32::MIN

Source

pub const MAX: Self

All elements are f32::MAX

Source

pub const ZERO: Self

All elemets are ZERO

Source

pub const fn new(x: f32, y: f32) -> Self

Create a new vector

Source

pub const fn splat(v: f32) -> Self

Creates a vector from a single value : [ v ; N ]

Source§

impl<E: MatEl + NdFloat> Vector<E, 3>

Source

pub fn x(&self) -> E

Source

pub fn y(&self) -> E

Source

pub fn z(&self) -> E

Source

pub fn cross(self, rhs: Self) -> Self

Source§

impl Vector<f32, 3>

Source

pub const X: Self

Unit x vector

Source

pub const Y: Self

Unit y vector

Source

pub const Z: Self

Unit z vector

Source

pub const MIN: Self

All elements are f32::MIN

Source

pub const MAX: Self

All elements are f32::MAX

Source

pub const ZERO: Self

All elemets are ZERO

Source

pub const fn new(x: f32, y: f32, z: f32) -> Self

Creates a new vector

Source

pub const fn splat(v: f32) -> Self

Creates a vector from a single value : [ v ; N ]

Source§

impl<E: MatEl + NdFloat> Vector<E, 4>

Source

pub fn x(&self) -> E

Source

pub fn y(&self) -> E

Source

pub fn z(&self) -> E

Source

pub fn w(&self) -> E

Source§

impl Vector<f32, 4>

Source

pub const X: Self

Unit x vector

Source

pub const Y: Self

Unit y vector

Source

pub const Z: Self

Unit z vector

Source

pub const W: Self

Unit w vector

Source

pub const MIN: Self

All elements are f32::MIN

Source

pub const MAX: Self

All elements are f32::MAX

Source

pub const ZERO: Self

All elemets are ZERO

Source

pub const fn new(x: f32, y: f32, z: f32, w: f32) -> Self

Creates a new vector

Source

pub const fn splat(v: f32) -> Self

Creates a vector from a single value : [ v ; N ]

Trait Implementations§

Source§

impl<E, const LEN: usize> Add for &Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

type Output = Vector<E, LEN>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<E, const LEN: usize> Add for Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

type Output = Vector<E, LEN>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<E, const LEN: usize> AddAssign for Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<E, const LEN: usize> Clone for Vector<E, LEN>
where E: MatEl + Clone,

Source§

fn clone(&self) -> Vector<E, LEN>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E, const N: usize> Collection for Vector<E, N>
where E: MatEl,

Source§

type Scalar = E

The scalar type contained in the collection.
Source§

impl<E, const N: usize> ConstLength for Vector<E, N>
where E: MatEl,

Source§

const LEN: usize = N

The length of the entity.
Source§

impl<E, const LEN: usize> Debug for Vector<E, LEN>
where E: MatEl + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: MatEl, const LEN: usize> Default for Vector<E, LEN>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<E, const LEN: usize> Div<E> for Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

type Output = Vector<E, LEN>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: E) -> Self::Output

Performs the / operation. Read more
Source§

impl<E, const LEN: usize> DivAssign<E> for Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

fn div_assign(&mut self, rhs: E)

Performs the /= operation. Read more
Source§

impl<E: MatEl, const N: usize> From<[E; N]> for Vector<E, N>

Source§

fn from(value: [E; N]) -> Self

Converts to this type from the input type.
Source§

impl<E, const N: usize> From<E> for Vector<E, N>
where E: MatEl,

Source§

fn from(value: E) -> Self

Converts to this type from the input type.
Source§

impl<E: MatEl, const N: usize> From<Vector<E, N>> for [E; N]

Source§

fn from(value: Vector<E, N>) -> Self

Converts to this type from the input type.
Source§

impl<E, const LEN: usize> Hash for Vector<E, LEN>
where E: MatEl + Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<E, const ROWS: usize, const COLS: usize, Descriptor> Mul<&Vector<E, COLS>> for &Mat<ROWS, COLS, E, Descriptor>
where Descriptor: Descriptor, E: MatEl + NdFloat, Mat<ROWS, COLS, E, Descriptor>: Indexable<Index = Ix2> + IndexingRef<Scalar = E>,

Source§

type Output = Vector<E, COLS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Vector<E, COLS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<E, const LEN: usize> Mul<E> for Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

type Output = Vector<E, LEN>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: E) -> Self::Output

Performs the * operation. Read more
Source§

impl<E, const ROWS: usize, const COLS: usize, Descriptor> Mul<Vector<E, COLS>> for Mat<ROWS, COLS, E, Descriptor>
where Descriptor: Descriptor, E: MatEl + NdFloat, Mat<ROWS, COLS, E, Descriptor>: Indexable<Index = Ix2> + IndexingRef<Scalar = E>,

Source§

type Output = Vector<E, COLS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector<E, COLS>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const LEN: usize> Mul<Vector<f32, LEN>> for f32

Source§

type Output = Vector<f32, LEN>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector<f32, LEN>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const LEN: usize> Mul<Vector<f64, LEN>> for f64

Source§

type Output = Vector<f64, LEN>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector<f64, LEN>) -> Self::Output

Performs the * operation. Read more
Source§

impl<E, const LEN: usize> Mul for Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

type Output = Vector<E, LEN>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<E, const LEN: usize> MulAssign<E> for Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

fn mul_assign(&mut self, rhs: E)

Performs the *= operation. Read more
Source§

impl<E, const ROWS: usize, const COLS: usize, Descriptor> MulAssign<Mat<ROWS, COLS, E, Descriptor>> for Vector<E, COLS>
where Descriptor: Descriptor, E: MatEl + NdFloat, Mat<ROWS, COLS, E, Descriptor>: Indexable<Index = Ix2> + IndexingRef<Scalar = E>,

Source§

fn mul_assign(&mut self, rhs: Mat<ROWS, COLS, E, Descriptor>)

Performs the *= operation. Read more
Source§

impl<E, const LEN: usize> PartialEq for Vector<E, LEN>
where E: MatEl + PartialEq,

Source§

fn eq(&self, other: &Vector<E, LEN>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<E, const LEN: usize> PartialOrd for Vector<E, LEN>
where E: MatEl + PartialOrd,

Source§

fn partial_cmp(&self, other: &Vector<E, LEN>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<E, const LEN: usize> Sub<E> for Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

type Output = Vector<E, LEN>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: E) -> Self::Output

Performs the - operation. Read more
Source§

impl<E, const LEN: usize> Sub for &Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

type Output = Vector<E, LEN>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<E, const LEN: usize> Sub for Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

type Output = Vector<E, LEN>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<E, const LEN: usize> SubAssign for Vector<E, LEN>
where E: MatEl + NdFloat,

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<E, const N: usize> TryFrom<&[E]> for Vector<E, N>
where E: MatEl,

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: &[E]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<E, const N: usize> VectorIter<E, N> for Vector<E, N>
where E: MatEl,

Source§

fn vector_iter<'a>(&'a self) -> impl VectorIteratorRef<'a, &'a E>
where E: 'a,

Source§

impl<E, const N: usize> VectorIterMut<E, N> for Vector<E, N>
where E: MatEl,

Source§

fn vector_iter_mut<'a>(&'a mut self) -> impl VectorIterator<'a, &'a mut E>
where E: 'a,

Source§

impl<E, const N: usize> VectorMut<E, N> for Vector<E, N>
where E: MatEl,

Source§

fn vector_mut(&mut self) -> &mut [E; N]

Returns a mutable reference to a fixed-size array from the collection. Read more
Source§

impl<E, const N: usize> VectorRef<E, N> for Vector<E, N>
where E: MatEl,

Source§

fn vector_ref(&self) -> &[E; N]

Returns a reference to a fixed-size array from the collection. Read more
Source§

impl<E, const LEN: usize> Copy for Vector<E, LEN>
where E: MatEl + Copy,

Source§

impl<E, const LEN: usize> StructuralPartialEq for Vector<E, LEN>
where E: MatEl,

Auto Trait Implementations§

§

impl<E, const LEN: usize> Freeze for Vector<E, LEN>
where E: Freeze,

§

impl<E, const LEN: usize> RefUnwindSafe for Vector<E, LEN>
where E: RefUnwindSafe,

§

impl<E, const LEN: usize> Send for Vector<E, LEN>
where E: Send,

§

impl<E, const LEN: usize> Sync for Vector<E, LEN>
where E: Sync,

§

impl<E, const LEN: usize> Unpin for Vector<E, LEN>
where E: Unpin,

§

impl<E, const LEN: usize> UnwindSafe for Vector<E, LEN>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneDyn for T
where T: Clone,

Source§

fn __clone_dyn(&self, _: DontCallMe) -> *mut ()

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<E, V, const N: usize> DimOffset<N> for V
where V: Debug + VectorRef<E, N> + Collection<Scalar = E, Scalar = E> + Collection + ?Sized, E: Mul<Output = E> + Add<Output = E> + PartialOrd + Copy + Default + From<u8>,

Source§

fn offset<V2>(&self, md_index: &V2) -> <V as Collection>::Scalar
where V2: VectorRef<E, N> + Collection<Scalar = <V as Collection>::Scalar> + Debug + ?Sized,

Converts a multidimensional index into a flat offset. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<All> From1<()> for All
where All: Default,

Source§

fn from1(_a: ()) -> All

Constructor with a single arguments.
Source§

impl<T, All> From1<(T,)> for All
where All: From1<T>,

Source§

fn from1(arg: (T,)) -> All

Constructor with a single arguments.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<All, F> Into1<F> for All
where F: From1<All>,

Source§

fn to(self) -> F

Converts this type into the (usually inferred) input type.
Source§

impl<T> IntoResult<T> for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToRef<T> for T
where T: ?Sized,

Source§

fn to_ref(&self) -> &T

Converts the implementing type to an immutable reference. Read more
Source§

impl<T> ToValue<T> for T

Source§

fn to_value(self) -> T

Obtains the value from the implementing type. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> MatEl for T
where T: Copy + Default,