[][src]Struct quick_maths::Vector

pub struct Vector<T = DefaultFloat, const N: usize>(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<T, 4usize>[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<T, 3usize>[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<T, N>[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<S, N> where
    F: FnMut(T) -> S, 
[src]

Applies this function to every vector value.

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

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

impl<T: Float + Zero, const N: usize> Vector<T, N>[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 zxtend<const M: usize>(&self) -> Vector<T, M>[src]

Zero-extend this vector to a larger vector. Must increase the size of the vector or keep it the same size.

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

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

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

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

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

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

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

pub fn new(a: T, b: T, c: T) -> Self[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]

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

Returns the homogeneous form of this vector.

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

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

X component of this vector

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

Y component of this vector

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

Z component of this vector

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

impl<T: Float, const N: usize> Vector<T, N>[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 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 abs_sub(&self, v: T) -> Self[src]

Element-wise abs_sub .

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

Element-wise signum .

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

pub fn is_sign_negative(&self) -> Vector<bool, N>[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 .

Trait Implementations

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

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

The resulting type after applying the + operator.

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

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

The resulting type after applying the + operator.

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

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

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

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

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

The resulting type after applying the & operator.

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

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

The resulting type after applying the & operator.

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

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

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

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

The resulting type after applying the | operator.

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

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

The resulting type after applying the | operator.

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

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

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

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

The resulting type after applying the ^ operator.

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

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

The resulting type after applying the ^ operator.

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

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

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

impl<T, const N: usize> BorrowMut<[T]> 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: Debug, const N: usize> Debug for Vector<T, N>[src]

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

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

The resulting type after applying the / operator.

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

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

The resulting type after applying the / operator.

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

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

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

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

type Output = T

The returned type after indexing.

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

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

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

The resulting type after applying the * operator.

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

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

The resulting type after applying the * operator.

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

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

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

type Output = Self

The resulting type after applying the - operator.

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

type Output = Self

The resulting type after applying the ! operator.

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

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

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

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

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

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

The resulting type after applying the % operator.

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

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

The resulting type after applying the % operator.

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

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

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

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

The resulting type after applying the - operator.

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

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

The resulting type after applying the - operator.

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

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

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

Auto Trait Implementations

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

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

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.