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§
Implementations§
Source§impl<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.