Trait maths_rs::vec::VecFloatOps

source ·
pub trait VecFloatOps<T: Float>: SignedVecN<T> + Magnitude<T> {
    // Required methods
    fn distance(a: Self, b: Self) -> T;
    fn dist(a: Self, b: Self) -> T;
    fn dist2(a: Self, b: Self) -> T;
    fn reflect(i: Self, n: Self) -> Self;
    fn refract(i: Self, n: Self, eta: T) -> Self;
    fn vlerp(e0: Self, e1: Self, t: Self) -> Self;
    fn vsmoothstep(e0: Self, e1: Self, t: Self) -> Self;
    fn powfn(a: Self, exp: Self) -> Self;
}
Expand description

operations to apply to n-dimensional vectors

Required Methods§

source

fn distance(a: Self, b: Self) -> T

returns scalar distance between 2 points (magnitude of the vector between the 2 points)

source

fn dist(a: Self, b: Self) -> T

returns scalar distance between 2 points (magnitude of the vector between the 2 points)

source

fn dist2(a: Self, b: Self) -> T

returns scalar squared distance between 2 points to avoid using sqrt

source

fn reflect(i: Self, n: Self) -> Self

returns a reflection vector using an incident ray and a surface normal

source

fn refract(i: Self, n: Self, eta: T) -> Self

returns a refraction vector using an entering ray, a surface normal, and a refraction index

source

fn vlerp(e0: Self, e1: Self, t: Self) -> Self

returns linear interpolation between e0 and e1, t specifies the ratio to interpolate between the values, with component-wise t

source

fn vsmoothstep(e0: Self, e1: Self, t: Self) -> Self

returns vector with component wise hermite interpolation between 0-1, with component-wise t

source

fn powfn(a: Self, exp: Self) -> Self

returns vector with component wise pow

Implementors§

source§

impl<T> VecFloatOps<T> for Vec2<T>where T: Float + FloatOps<T>,

source§

impl<T> VecFloatOps<T> for Vec3<T>where T: Float + FloatOps<T>,

source§

impl<T> VecFloatOps<T> for Vec4<T>where T: Float + FloatOps<T>,