Function glm::builtin::clamp [] [src]

pub fn clamp<S: BaseNum, T: GenNum<S>>(x: T, min_val: T, max_val: T) -> T

Returns min (max (x, min_val), max_val).

Example

use glm::{ clamp, vec3 };

assert_eq!(clamp(3.14_f32, 0., 1.), 1.);
let v = vec3(-1., 0., 100.);
let min = vec3(0., 0., 0.);
let max = vec3(1., 1., 1.);
assert_eq!(clamp(v, min, max), vec3(0., 0., 1.));