Vector

Struct Vector 

Source
pub struct Vector<T, const N: usize> { /* private fields */ }

Implementations§

Source§

impl<T, const N: usize> Vector<T, N>

Source

pub const fn new(data: [T; N]) -> Self

Source

pub fn pure(x: T) -> Self
where T: Clone,

Source

pub const fn const_pure(x: T) -> Self
where T: Copy,

Source

pub fn gen<F>(f: F) -> Self
where F: Fn(usize) -> T,

Source

pub fn dot(self, rhs: Vector<T, N>) -> T
where T: Mul<T, Output = T> + Sum,

Source

pub fn mag_sq(self) -> T
where T: Mul<T, Output = T> + Sum + Clone,

Source

pub fn mag(self) -> T
where T: Float + Sum,

Source

pub fn normalised(self) -> Self
where T: Float + Sum,

Source

pub fn map<F, U>(self, f: F) -> Vector<U, N>
where F: Fn(T) -> U,

Source

pub fn map_mut<F>(&mut self, f: F)
where F: Fn(&mut T),

Source

pub fn apply<F, U, V>(self, f: F, rhs: Vector<U, N>) -> Vector<V, N>
where F: Fn(T, U) -> V,

Source

pub fn apply_mut<F, U>(&mut self, f: F, rhs: Vector<U, N>)
where F: Fn(&mut T, U),

Source

pub fn into_iter(self) -> <Self as IntoIterator>::IntoIter

Source

pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter

Source

pub fn iter_mut(&mut self) -> <&mut Self as IntoIterator>::IntoIter

Source§

impl<T> Vector<T, 1>

Source

pub const fn new1(x: T) -> Self

Source

pub const fn x(&self) -> &T

Source§

impl<T> Vector<T, 2>

Source

pub const fn new2(x: T, y: T) -> Self

Source

pub const fn x(&self) -> &T

Source

pub const fn y(&self) -> &T

Source§

impl<T> Vector<T, 3>

Source

pub const fn new3(x: T, y: T, z: T) -> Self

Source

pub const fn x(&self) -> &T

Source

pub const fn y(&self) -> &T

Source

pub const fn z(&self) -> &T

Source

pub fn cross(self, rhs: Vector<T, 3>) -> Self
where T: Mul<T, Output = T> + Add<T, Output = T> + Sub<T, Output = T> + Neg<Output = T> + Clone,

Source§

impl<T> Vector<T, 4>

Source

pub const fn new4(x: T, y: T, z: T, w: T) -> Self

Source

pub const fn x(&self) -> &T

Source

pub const fn y(&self) -> &T

Source

pub const fn z(&self) -> &T

Source

pub const fn w(&self) -> &T

Trait Implementations§

Source§

impl<T, const N: usize> Add for Vector<T, N>
where T: Add<T, Output = T>,

Source§

type Output = Vector<T, N>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vector<T, N>) -> Self::Output

Performs the + operation. Read more
Source§

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

Source§

fn add_assign(&mut self, rhs: Vector<T, N>)

Performs the += operation. Read more
Source§

impl<T: Clone, const N: usize> Clone for Vector<T, N>

Source§

fn clone(&self) -> Vector<T, N>

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<T, const N: usize> ConstOne for Vector<T, N>
where T: ConstOne + Copy,

Source§

const ONE: Self

The multiplicative identity element of Self, 1.
Source§

impl<T, const N: usize> ConstZero for Vector<T, N>
where T: ConstZero + Copy,

Source§

const ZERO: Self

The additive identity element of Self, 0.
Source§

impl<T: Debug, const N: usize> Debug for Vector<T, N>

Source§

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

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

impl<T, const N: usize> Div<T> for Vector<T, N>
where T: Div<T, Output = T> + Clone,

Source§

type Output = Vector<T, N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<T, const N: usize> Div for Vector<T, N>
where T: Div<T, Output = T>,

Source§

type Output = Vector<T, N>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Vector<T, N>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T, const N: usize> DivAssign<T> for Vector<T, N>
where T: DivAssign<T> + Clone,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

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

Source§

fn div_assign(&mut self, rhs: Vector<T, N>)

Performs the /= operation. Read more
Source§

impl<T, const N: usize> From<Matrix<T, N, 1>> for Vector<T, N>

Source§

fn from(value: Matrix<T, N, 1>) -> Self

Converts to this type from the input type.
Source§

impl<T, const N: usize> From<Vector<T, N>> for Matrix<T, N, 1>

Source§

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

Converts to this type from the input type.
Source§

impl From<Vector<f64, 3>> for Colour

Source§

fn from(v: Vector<f64, 3>) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash, const N: usize> Hash for Vector<T, N>

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<T, const N: usize> Index<usize> for Vector<T, N>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, const N: usize> IndexMut<usize> for Vector<T, N>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, T, const N: usize> IntoIterator for &'a Vector<T, N>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T, const N: usize> IntoIterator for &'a mut Vector<T, N>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T, const N: usize> IntoIterator for Vector<T, N>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T, N>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T, const N: usize> Mul<T> for Vector<T, N>
where T: Mul<T, Output = T> + Clone,

Source§

type Output = Vector<T, N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T, const M: usize, const N: usize> Mul<Vector<T, N>> for Matrix<T, M, N>
where T: Clone + Mul<T, Output = T> + Sum,

Source§

type Output = Vector<T, M>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector<T, N>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T, const N: usize> Mul for Vector<T, N>
where T: Mul<T, Output = T>,

Source§

type Output = Vector<T, N>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector<T, N>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T, const N: usize> MulAssign<T> for Vector<T, N>
where T: MulAssign + Clone,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

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

Source§

fn mul_assign(&mut self, rhs: Vector<T, N>)

Performs the *= operation. Read more
Source§

impl<T, const N: usize> Neg for Vector<T, N>
where T: Neg<Output = T>,

Source§

type Output = Vector<T, N>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T, const N: usize> One for Vector<T, N>
where T: One + Clone,

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl<T: PartialEq, const N: usize> PartialEq for Vector<T, N>

Source§

fn eq(&self, other: &Vector<T, N>) -> 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<T, const N: usize> Sub for Vector<T, N>
where T: Sub<T, Output = T>,

Source§

type Output = Vector<T, N>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vector<T, N>) -> Self::Output

Performs the - operation. Read more
Source§

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

Source§

fn sub_assign(&mut self, rhs: Vector<T, N>)

Performs the -= operation. Read more
Source§

impl<T, const N: usize> Sum for Vector<T, N>
where T: Add<T, Output = T> + Zero + Clone,

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<T, const N: usize> Zero for Vector<T, N>
where T: Zero + Clone,

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl<T: Copy, const N: usize> Copy for Vector<T, N>

Source§

impl<T: Eq, const N: usize> Eq for Vector<T, N>

Source§

impl<T, const N: usize> StructuralPartialEq for Vector<T, N>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T, const N: usize> UnwindSafe for Vector<T, N>
where T: 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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V