[−][src]Function pbrt::clamp
pub fn clamp<T>(val: T, low: T, high: T) -> T where
T: PartialOrd,
Clamp val
between low
and high
.
Examples
use pbrt::clamp; assert_eq!(clamp(-1., 0., 1.), 0.); assert_eq!(clamp(0.5, 0., 1.), 0.5); assert_eq!(clamp(2., 0., 1.), 1.0); assert_eq!(clamp(-1, 0, 2), 0); assert_eq!(clamp(1, 0, 2), 1); assert_eq!(clamp(3, 0, 2), 2);