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
sourceimpl<N: NVecNum> NVec<N>
impl<N: NVecNum> NVec<N>
sourcepub fn z_raw(&self) -> Option<N>
pub fn z_raw(&self) -> Option<N>
The z component of the number vector as faw integer/float type.
sourcepub fn w_raw(&self) -> Option<N>
pub fn w_raw(&self) -> Option<N>
The w component of the number vector as faw integer/float type.
sourcepub fn into_tpl(self) -> (N, N, Option<N>, Option<N>)
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.
sourcepub fn into_zero_tpl(self) -> (N, N, N, N)
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.
sourcepub fn into_vval_tpl(self) -> (VVal, VVal, Option<VVal>, Option<VVal>)
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.
sourcepub fn from_tpl(tpl: (N, N, Option<N>, Option<N>)) -> Option<Self>
pub fn from_tpl(tpl: (N, N, Option<N>, Option<N>)) -> Option<Self>
Convert a tuple of raw integer/float types into an NVec.
sourcepub fn from_vval_tpl<W: AsRef<VVal>>(
(x, y, z, w): (W, W, Option<W>, Option<W>)
) -> Option<Self>
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.
sourcepub fn vec2(self) -> Self
pub fn vec2(self) -> Self
Converts this vector into one with three dimensions, discarding the unnecessary values.
sourcepub fn vec3(self) -> Self
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.
sourcepub fn vec4(self) -> Self
pub fn vec4(self) -> Self
Converts this vector into one with four dimensions, filling in the missing values with 0s if necessary.
sourcepub fn mag2(&self) -> f64
pub fn mag2(&self) -> f64
Returns the squared magnitude of this vector like x^2 + y^2
.
See also NVec::mag.
sourcepub fn mag(&self) -> f64
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.
sourcepub fn lerp(self, o: NVec<N>, t: f64) -> Self
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.
sourcepub fn vec2rad(self) -> f64
pub fn vec2rad(self) -> f64
Turns the first two components of this vector into an angle in radians.
Trait Implementations
impl<N: Copy + NVecNum> Copy for NVec<N>
impl<N: NVecNum> StructuralPartialEq for NVec<N>
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more