NVec

Enum NVec 

Source
pub enum NVec<N: NVecNum> {
    Vec2(N, N),
    Vec3(N, N, N),
    Vec4(N, N, N, N),
}
Expand description

WLambda supports Integer and Float vectors in two, three, and four dimensions. See also VVal::nvec and functions like VVal::ivec2, VVal::fvec2, …

Variants§

§

Vec2(N, N)

§

Vec3(N, N, N)

§

Vec4(N, N, N, N)

Implementations§

Source§

impl<N: NVecNum> NVec<N>

Source

pub fn x(&self) -> VVal

The x component of the number vector as VVal.

Source

pub fn x_raw(&self) -> N

The x component of the number vector as faw integer/float type.

Source

pub fn y(&self) -> VVal

The y component of the number vector as VVal.

Source

pub fn y_raw(&self) -> N

The y component of the number vector as faw integer/float type.

Source

pub fn z(&self) -> Option<VVal>

The z component of the number vector as VVal.

Source

pub fn z_raw(&self) -> Option<N>

The z component of the number vector as faw integer/float type.

Source

pub fn w(&self) -> Option<VVal>

The w component of the number vector as VVal.

Source

pub fn w_raw(&self) -> Option<N>

The w component of the number vector as faw integer/float type.

Source

pub fn dims(&self) -> NVecDim

Returns the dimensionality of this number vector.

Source

pub fn into_tpl(self) -> (N, N, Option<N>, Option<N>)

Convert this numeric vector into a tuple of raw integer/float types. All vectors contain x and y components. The z and w components are optional.

Source

pub fn into_zero_tpl(self) -> (N, N, N, N)

A tuple of four elements representing the components of this vector. If a component wasn’t available, a 0 takes its place.

Source

pub fn into_vval_tpl(self) -> (VVal, VVal, Option<VVal>, Option<VVal>)

Convert this numeric vector into a tuple of VVal. All vectors contain x and y components. The z and w components are optional.

Source

pub fn from_tpl(tpl: (N, N, Option<N>, Option<N>)) -> Option<Self>

Convert a tuple of raw integer/float types into an NVec.

Source

pub fn from_vval_tpl<W: AsRef<VVal>>( (x, y, z, w): (W, W, Option<W>, Option<W>), ) -> Option<Self>

Convert a tuple of VVal into an NVec.

Source

pub fn s(&self) -> String

Returns a string representation of this numeric vector.

Source

pub fn vec2(self) -> Self

Converts this vector into one with three dimensions, discarding the unnecessary values.

Source

pub fn vec3(self) -> Self

Converts this vector into one with three dimensions, discarding the unnecessary values and filling in the missing values with 0s if necessary.

Source

pub fn vec4(self) -> Self

Converts this vector into one with four dimensions, filling in the missing values with 0s if necessary.

Source

pub fn mag2(&self) -> f64

Returns the squared magnitude of this vector like x^2 + y^2. See also NVec::mag.

Source

pub fn mag(&self) -> f64

Returns the magnitude of this vector also known as the mathematical length of the vector: sqrt(x^2 + y^2) for instance for a 2 dimensional vector.

Source

pub fn norm(self) -> Self

Convert this NVec into a normalized (unit length) vector.

Source

pub fn dot(self, o: NVec<N>) -> N

Calculates the dot product of two numerical vectors.

Source

pub fn cross(self, o: NVec<N>) -> Self

Calculates the cross product of two numerical vectors.

Source

pub fn lerp(self, o: NVec<N>, t: f64) -> Self

Linear interpolation from this vector to the given vector \a o. The parameter \a t should be between 0.0 and 1.0.

Source

pub fn vec2rad(self) -> f64

Turns the first two components of this vector into an angle in radians.

Source

pub fn rad2vec(f: f64) -> Self

Produces a Vec2 based on the radians provided to this function as a float.

Source

pub fn slerp(self, o: NVec<N>, t: f64) -> Self

The resulting NVec will almost always have a length of 1, except for in cases where o and self are collinear opposites. To work around this, the resulting vector may be normalized.

§Panics

Panics if input vectors aren’t unit vectors.

Trait Implementations§

Source§

impl<N: NVecNum> Add for NVec<N>

Source§

type Output = NVec<N>

The resulting type after applying the + operator.
Source§

fn add(self, o: NVec<N>) -> NVec<N>

Performs the + operation. Read more
Source§

impl<N: Clone + NVecNum> Clone for NVec<N>

Source§

fn clone(&self) -> NVec<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<N: Debug + NVecNum> Debug for NVec<N>

Source§

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

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

impl<N: NVecNum> Div<N> for NVec<N>

Source§

type Output = NVec<N>

The resulting type after applying the / operator.
Source§

fn div(self, o: N) -> NVec<N>

Performs the / operation. Read more
Source§

impl<N: NVecNum> Mul<N> for NVec<N>

Source§

type Output = NVec<N>

The resulting type after applying the * operator.
Source§

fn mul(self, o: N) -> NVec<N>

Performs the * operation. Read more
Source§

impl<N: NVecNum> Neg for NVec<N>

Source§

type Output = NVec<N>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<N: PartialEq + NVecNum> PartialEq for NVec<N>

Source§

fn eq(&self, other: &NVec<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<N: NVecNum> Sub for NVec<N>

Source§

type Output = NVec<N>

The resulting type after applying the - operator.
Source§

fn sub(self, o: NVec<N>) -> NVec<N>

Performs the - operation. Read more
Source§

impl<N: Copy + NVecNum> Copy for NVec<N>

Source§

impl<N: NVecNum> StructuralPartialEq for NVec<N>

Auto Trait Implementations§

§

impl<N> Freeze for NVec<N>
where N: Freeze,

§

impl<N> RefUnwindSafe for NVec<N>
where N: RefUnwindSafe,

§

impl<N> Send for NVec<N>
where N: Send,

§

impl<N> Sync for NVec<N>
where N: Sync,

§

impl<N> Unpin for NVec<N>
where N: Unpin,

§

impl<N> UnwindSafe for NVec<N>
where N: 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<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> 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.