[][src]Struct definitive::Vector

pub struct Vector<T = f32, const N: usize>(_);

A generic type representing an N dimensional vector

Methods

impl<T, const N: usize> Vector<T, { N }>[src]

pub fn new(components: [T; { N }]) -> Self[src]

Create a new vector out of some components

Note: Vector also implements From<[T, {N}]> which can be cleaner

pub fn resize_with<const M: usize>(
    self,
    fill: impl FnMut() -> T
) -> Vector<T, { M }>
[src]

Resize the vector to { M } length, either truncating or filling with fill

See also resize, resize_zero and resize_one for Vector<T, _>'s that have Default, Zero and One implementations, respectively

impl<T: Default, const N: usize> Vector<T, { N }>[src]

pub fn resize<const M: usize>(self) -> Vector<T, { M }>[src]

Resize the vector to { M } lenght, either truncating or filling with T::default

impl<T: One, const N: usize> Vector<T, { N }>[src]

pub fn resize_one<const M: usize>(self) -> Vector<T, { M }>[src]

Resize the vector to { M } lenght, either truncating or filling with T::one

impl<T: Zero, const N: usize> Vector<T, { N }>[src]

pub fn resize_zero<const M: usize>(self) -> Vector<T, { M }>[src]

Resize the vector to { M } lenght, either truncating or filling with T::one

impl<T: Mul<Output = T> + Add<Output = T> + Zero, const N: usize> Vector<T, { N }>[src]

pub fn dot(self, rhs: Self) -> T[src]

Calculate the dot product

A1 * B1 + A2 * B2 + ... + An * Bn

impl<T: Mul<Output = T> + Add<Output = T> + Clone + Zero, const N: usize> Vector<T, { N }>[src]

pub fn length2(&self) -> T[src]

Calculate the length of the vector and square it

A1^2 + A2^2 + ... + An^2

impl<T: Mul<Output = T> + Add<Output = T> + Clone + Zero + Sqrt, const N: usize> Vector<T, { N }>[src]

pub fn length(&self) -> T[src]

Calculate the length/magnitude of the vector

sqrt(A1^2 + A2^2 + ... + An^2)

impl<T: Mul<Output = T> + Div<Output = T> + Add<Output = T> + Clone + Zero + Sqrt, const N: usize> Vector<T, { N }>[src]

pub fn normalize(self) -> Self[src]

Normalize the vector, making its length one

Trait Implementations

impl<T: One, const N: usize> One for Vector<T, { N }>[src]

impl<T: Zero, const N: usize> Zero for Vector<T, { N }>[src]

impl<T, const N: usize> From<[T; N]> for Vector<T, { N }>[src]

impl<T: Clone, const N: usize> Clone for Vector<T, { N }>[src]

impl<T: Copy, const N: usize> Copy for Vector<T, { N }>[src]

impl<T: Eq, const N: usize> Eq for Vector<T, { N }>[src]

impl<T: Tr, const N: usize> PartialEq<Vector<T, N>> for Vector<T, { N }>[src]

impl<T: Debug, const N: usize> Debug for Vector<T, { N }>[src]

impl<T: Div<Output = T>, const N: usize> Div<Vector<T, N>> for Vector<T, { N }>[src]

type Output = Vector<T, { N }>

The resulting type after applying the / operator.

impl<T: Div<T, Output = T> + Clone, const N: usize> Div<T> for Vector<T, { N }>[src]

type Output = Vector<T, { N }>

The resulting type after applying the / operator.

impl<T: Rem<Output = T>, const N: usize> Rem<Vector<T, N>> for Vector<T, { N }>[src]

type Output = Vector<T, { N }>

The resulting type after applying the % operator.

impl<T: Rem<T, Output = T> + Clone, const N: usize> Rem<T> for Vector<T, { N }>[src]

type Output = Vector<T, { N }>

The resulting type after applying the % operator.

impl<T: Sub<Output = T>, const N: usize> Sub<Vector<T, N>> for Vector<T, { N }>[src]

type Output = Vector<T, { N }>

The resulting type after applying the - operator.

impl<T: Sub<T, Output = T> + Clone, const N: usize> Sub<T> for Vector<T, { N }>[src]

type Output = Vector<T, { N }>

The resulting type after applying the - operator.

impl<T: Add<Output = T>, const N: usize> Add<Vector<T, N>> for Vector<T, { N }>[src]

type Output = Vector<T, { N }>

The resulting type after applying the + operator.

impl<T: Add<T, Output = T> + Clone, const N: usize> Add<T> for Vector<T, { N }>[src]

type Output = Vector<T, { N }>

The resulting type after applying the + operator.

impl<T: Mul<Output = T>, const N: usize> Mul<Vector<T, N>> for Vector<T, { N }>[src]

type Output = Vector<T, { N }>

The resulting type after applying the * operator.

impl<T: Mul<T, Output = T> + Clone, const N: usize> Mul<T> for Vector<T, { N }>[src]

type Output = Vector<T, { N }>

The resulting type after applying the * operator.

impl<T: Neg<Output = T>, const N: usize> Neg for Vector<T, { N }>[src]

type Output = Vector<T, { N }>

The resulting type after applying the - operator.

impl<T: AddAssign, const N: usize> AddAssign<Vector<T, N>> for Vector<T, { N }>[src]

impl<T: AddAssign<T> + Clone, const N: usize> AddAssign<T> for Vector<T, { N }>[src]

impl<T: SubAssign, const N: usize> SubAssign<Vector<T, N>> for Vector<T, { N }>[src]

impl<T: SubAssign<T> + Clone, const N: usize> SubAssign<T> for Vector<T, { N }>[src]

impl<T: MulAssign, const N: usize> MulAssign<Vector<T, N>> for Vector<T, { N }>[src]

impl<T: MulAssign<T> + Clone, const N: usize> MulAssign<T> for Vector<T, { N }>[src]

impl<T: DivAssign, const N: usize> DivAssign<Vector<T, N>> for Vector<T, { N }>[src]

impl<T: DivAssign<T> + Clone, const N: usize> DivAssign<T> for Vector<T, { N }>[src]

impl<T: RemAssign, const N: usize> RemAssign<Vector<T, N>> for Vector<T, { N }>[src]

impl<T: RemAssign<T> + Clone, const N: usize> RemAssign<T> for Vector<T, { N }>[src]

impl<T, const N: usize> Deref for Vector<T, { N }>[src]

type Target = [T; { N }]

The resulting type after dereferencing.

impl<T, const N: usize> DerefMut for Vector<T, { N }>[src]

Auto Trait Implementations

impl<const N: usize, T> Send for Vector<T, N> where
    T: Send

impl<const N: usize, T> Sync for Vector<T, N> where
    T: Sync

impl<const N: usize, T> Unpin for Vector<T, N> where
    T: Unpin

impl<const N: usize, T> UnwindSafe for Vector<T, N> where
    T: UnwindSafe

impl<const N: usize, T> RefUnwindSafe for Vector<T, N> where
    T: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]