[][src]Struct quick_maths::Vector

pub struct Vector<const N: usize, T = DefaultFloat>(pub [T; N]);

Vector over floats and a const-size. Often used through Vec2, Vec3, and Vec4 instead of the raw struct.

Implementations

impl<T: Float> Vector<4_usize, T>[src]

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

pub fn is_unit(&self) -> bool[src]

pub fn scale(&self, factor: T) -> Self[src]

Encodes a scaling factor into the quaternion

pub fn rot(along: &Vec3<T>) -> Self[src]

Returns a quaternion which is a rotation in the 3 dimensions given

pub fn quat_mul(self, o: Self) -> Self[src]

impl<T: Float> Vector<3_usize, T>[src]

pub fn to_quat(&self) -> Quat<T>[src]

pub fn apply_quat(&self, q: &Quat<T>) -> Self[src]

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

pub fn of(v: T) -> Self[src]

Creates a vector of the value v (every element = v).

pub fn apply_fn<F, S>(self, f: F) -> Vector<N, S> where
    F: FnMut(T) -> S, 
[src]

Applies this function to every vector value.

pub fn cast<S: From<T>>(self) -> Vector<N, S>[src]

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

X component of this vector, panics if out of range

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

Y component of this vector, panics if out of range

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

Z component of this vector, panics if out of range

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

W componenent of this vector, panics if out of range

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

pub fn with<F>(f: F) -> Self where
    F: FnMut(usize) -> T, 
[src]

pub fn iter(&self) -> impl Iterator<Item = &T>[src]

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>[src]

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

pub fn extend<const M: usize>(&self, v: T) -> Vector<M, T>[src]

Extend this vector to a larger vector. Must increase the size of the vector or keep it the same size.

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

pub fn linspace(a: T, b: T) -> Self[src]

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

Takes the dot product of two vectors

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

Computes the sqr_magnitude of the vector

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

Takes the magnitude of the vector

pub fn norm(&self) -> Self[src]

Returns a unit vector in the same direction as self. Consider division instead of calling this method if you need efficiency.

pub fn cos_similarity(&self, o: &Self) -> T[src]

pub fn reflect(&self, across: &Self) -> Self[src]

pub fn refract(&self, norm: &Self, eta: T) -> Option<Self>[src]

pub fn from_str_radix(
    strs: [&str; N],
    radix: u32
) -> Result<Self, T::FromStrRadixErr>
[src]

Computes a vector from a list of strings.

pub fn lerp(&self, v: &Self, alpha: T) -> Self[src]

Linearly interpolates from self to v according to alpha, where 0 => self, and 1 => v.

pub fn max_component(&self) -> usize[src]

Computes the max component of this vector

pub fn min_component(&self) -> usize[src]

Computes the minimum component of this vector

pub fn clamp(&mut self, min: T, max: T)[src]

Clamps self between min and max

pub fn dist(&self, o: &Self) -> T[src]

pub fn reduce<const M: usize>(&self) -> Vector<M, T>[src]

Shrink this vector to a lower dimension Must lower or keep the same size.

pub fn sift(&self, o: &Self) -> (Self, Self)[src]

Takes the minimal and maximal elements from self and o and returns those vectors

pub fn project_onto(&self, onto: &Self) -> Self[src]

pub fn col_vector(self) -> Matrix<N, 1, T>[src]

pub fn row_vector(self) -> Matrix<1, N, T>[src]

pub fn bisector(&self, o: &Self) -> Self[src]

Computes the bisector of two vectors = (a,b) => |a|*b + |b|*a;

pub fn convolve<const M: usize>(&self, o: &Vector<M, T>) -> Self[src]

Convolves self with other, returning a vector of the same size

pub fn scatter_fn<S: Copy, const M: usize>(
    &self,
    idx: &Vector<N, usize>,
    base: S,
    acc: impl Fn(S, T) -> S
) -> Vector<M, S>
[src]

impl<const N: usize> Vector<N, bool>[src]

pub fn any(&self) -> bool[src]

pub fn all(&self) -> bool[src]

impl<T> Vector<3_usize, T>[src]

pub const fn new(a: T, b: T, c: T) -> Self[src]

impl<T: Float> Vector<3_usize, T>[src]

pub fn cross(&self, o: &Self) -> Self[src]

Takes the cross product of self with other

pub fn sided(&self, o: &Self, normal: &Self) -> bool[src]

Whether or not self is aligned on the right or left hand side of normal w.r.t o.

pub fn homogeneous(&self) -> Vec4<T>[src]

Returns the homogeneous form of this vector.

pub fn homogenize(&self) -> Vec2<T>[src]

impl<T> Vector<2_usize, T>[src]

pub const fn new(a: T, b: T) -> Self[src]

impl<T: Copy> Vector<2_usize, T>[src]

pub fn flip(&self) -> Self[src]

impl<T: Float> Vector<2_usize, T>[src]

pub fn rot(&self, theta: T) -> Self[src]

Rotates this vector around the origin by theta (in radians)

pub fn signed_angle(&self, dst: &Self) -> T[src]

pub fn perp(&self) -> Self[src]

pub fn homogeneous(&self) -> Vec3<T>[src]

impl<T> Vector<4_usize, T>[src]

pub const fn new(a: T, b: T, c: T, w: T) -> Self[src]

impl<T: Float> Vector<4_usize, T>[src]

pub fn homogenize(&self) -> Vec3<T>[src]

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

pub fn cos(&self) -> Self[src]

Element-wise cos .

pub fn sin(&self) -> Self[src]

Element-wise sin .

pub fn tan(&self) -> Self[src]

Element-wise tan .

pub fn acos(&self) -> Self[src]

Element-wise acos .

pub fn asin(&self) -> Self[src]

Element-wise asin .

pub fn atan(&self) -> Self[src]

Element-wise atan .

pub fn acosh(&self) -> Self[src]

Element-wise acosh .

pub fn asinh(&self) -> Self[src]

Element-wise asinh .

pub fn atanh(&self) -> Self[src]

Element-wise atanh .

pub fn sin_cos(&self) -> (Self, Self)[src]

pub fn atan2(&self, v: T) -> Self[src]

Element-wise atan2 .

pub fn hypot(&self, v: T) -> Self[src]

Element-wise hypot .

pub fn ceil(&self) -> Self[src]

Element-wise ceil .

pub fn floor(&self) -> Self[src]

Element-wise floor .

pub fn round(&self) -> Self[src]

Element-wise round .

pub fn fract(&self) -> Self[src]

Element-wise fract .

pub fn trunc(&self) -> Self[src]

Element-wise trunc .

pub fn abs(&self) -> Self[src]

Element-wise abs .

pub fn signum(&self) -> Self[src]

Element-wise signum .

pub fn abs_sub(&self, v: T) -> Self[src]

Element-wise abs_sub .

pub fn is_sign_positive(&self) -> Vector<N, bool>[src]

pub fn is_sign_negative(&self) -> Vector<N, bool>[src]

pub fn recip(&self) -> Self[src]

Element-wise recip .

pub fn log2(&self) -> Self[src]

Element-wise log2 .

pub fn log10(&self) -> Self[src]

Element-wise log10 .

pub fn ln(&self) -> Self[src]

Element-wise ln .

pub fn ln_1p(&self) -> Self[src]

Element-wise ln_1p .

pub fn exp(&self) -> Self[src]

Element-wise exp .

pub fn exp2(&self) -> Self[src]

Element-wise exp2 .

pub fn exp_m1(&self) -> Self[src]

Element-wise exp_m1 .

pub fn sqrt(&self) -> Self[src]

Element-wise sqrt .

pub fn cbrt(&self) -> Self[src]

Element-wise cbrt .

pub fn powf(&self, v: T) -> Self[src]

Element-wise powf .

pub fn powi(&self, v: i32) -> Self[src]

pub fn log(&self, v: T) -> Self[src]

Element-wise log .

pub fn max(&self, v: T) -> Self[src]

Element-wise max .

pub fn min(&self, v: T) -> Self[src]

Element-wise min .

pub fn to_degrees(&self) -> Self[src]

Element-wise to_degrees .

pub fn to_radians(&self) -> Self[src]

Element-wise to_radians .

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

pub fn dyn_tensor(self) -> DynTensor<1, T>[src]

Trait Implementations

impl<T: Add + Copy, const N: usize> Add<T> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the + operator.

impl<T: Add + Copy, const N: usize> Add<Vector<N, T>> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the + operator.

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

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

impl<T, const N: usize> AsRef<[T]> for Vector<N, T>[src]

impl<T: BitAnd + Copy, const N: usize> BitAnd<T> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the & operator.

impl<T: BitAnd + Copy, const N: usize> BitAnd<Vector<N, T>> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the & operator.

impl<T: BitAndAssign + Copy, const N: usize> BitAndAssign<T> for Vector<N, T>[src]

impl<T: BitAndAssign + Copy, const N: usize> BitAndAssign<Vector<N, T>> for Vector<N, T>[src]

impl<T: BitOr + Copy, const N: usize> BitOr<T> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the | operator.

impl<T: BitOr + Copy, const N: usize> BitOr<Vector<N, T>> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the | operator.

impl<T: BitOrAssign + Copy, const N: usize> BitOrAssign<T> for Vector<N, T>[src]

impl<T: BitOrAssign + Copy, const N: usize> BitOrAssign<Vector<N, T>> for Vector<N, T>[src]

impl<T: BitXor + Copy, const N: usize> BitXor<T> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the ^ operator.

impl<T: BitXor + Copy, const N: usize> BitXor<Vector<N, T>> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the ^ operator.

impl<T: BitXorAssign + Copy, const N: usize> BitXorAssign<T> for Vector<N, T>[src]

impl<T: BitXorAssign + Copy, const N: usize> BitXorAssign<Vector<N, T>> for Vector<N, T>[src]

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

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

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

impl<T: Div + Copy, const N: usize> Div<T> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the / operator.

impl<T: Div + Copy, const N: usize> Div<Vector<N, T>> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the / operator.

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

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

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

impl<R: SliceIndex<[T]>, T, const N: usize> Index<R> for Vector<N, T>[src]

type Output = R::Output

The returned type after indexing.

impl<R: SliceIndex<[T]>, T, const N: usize> IndexMut<R> for Vector<N, T>[src]

impl<T: Mul + Copy, const N: usize> Mul<T> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the * operator.

impl<T: Mul + Copy, const N: usize> Mul<Vector<N, T>> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the * operator.

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

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

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

type Output = Self

The resulting type after applying the - operator.

impl<T: Not<Output = T> + Copy, const N: usize> Not for Vector<N, T>[src]

type Output = Self

The resulting type after applying the ! operator.

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

impl<const N: usize, T: Ord> Ord for Vector<N, T>[src]

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

impl<const N: usize, T: PartialOrd> PartialOrd<Vector<N, T>> for Vector<N, T>[src]

impl<T: Rem + Copy, const N: usize> Rem<T> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the % operator.

impl<T: Rem + Copy, const N: usize> Rem<Vector<N, T>> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the % operator.

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

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

impl<const N: usize, T> StructuralEq for Vector<N, T>[src]

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

impl<T: Sub + Copy, const N: usize> Sub<T> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the - operator.

impl<T: Sub + Copy, const N: usize> Sub<Vector<N, T>> for Vector<N, T>[src]

type Output = Vector<N, T::Output>

The resulting type after applying the - operator.

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

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

impl<T: Zero + Copy, const N: usize> Zero for Vector<N, T>[src]

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

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

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

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

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

impl<T, Rhs> NumAssignOps<Rhs> for T where
    T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>, 
[src]

impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
    T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>, 
[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.