Function glm::builtin::smoothstep
[−]
[src]
pub fn smoothstep<F: BaseFloat, T: GenFloat<F>>(edge0: T, edge1: T, x: T) -> T
Returns 0.0
if x ≤ edge0
and 1.0
if x ≥ edge1
and performs
smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1
.
This is useful in cases where you would want a threshold function with a smooth transition.
Results are undefined if edge0 ≥ edge1
.
Example
use glm::{ smoothstep, dvec2 }; assert_eq!(smoothstep(0f32, 1., -1.), 0.); let e0 = dvec2(0., -100.); let e1 = dvec2(1., 100.); let v = dvec2(1., 50.); assert_eq!(smoothstep(e0, e1, v), dvec2(1., 0.84375));