[−]Function rusty_engine::prelude::glm::clamp_vec
pub fn clamp_vec<N, D>(
x: &Matrix<N, D, U1, <DefaultAllocator as Allocator<N, D, U1>>::Buffer>,
min_val: &Matrix<N, D, U1, <DefaultAllocator as Allocator<N, D, U1>>::Buffer>,
max_val: &Matrix<N, D, U1, <DefaultAllocator as Allocator<N, D, U1>>::Buffer>
) -> Matrix<N, D, U1, <DefaultAllocator as Allocator<N, D, U1>>::Buffer> where
D: Dimension,
N: Number,
DefaultAllocator: Alloc<N, D, U1>,
Returns min(max(x[i], min_val[i]), max_val[i])
for each component in x
using the components of min_val
and max_val
as bounds.
Examples:
let min_bounds = glm::vec2(1.0, 3.0); let max_bounds = glm::vec2(5.0, 6.0); assert_eq!(glm::vec2(1.0, 6.0), glm::clamp_vec(&glm::vec2(0.0, 7.0), &min_bounds, &max_bounds)); assert_eq!(glm::vec2(2.0, 6.0), glm::clamp_vec(&glm::vec2(2.0, 7.0), &min_bounds, &max_bounds)); assert_eq!(glm::vec2(1.0, 4.0), glm::clamp_vec(&glm::vec2(0.0, 4.0), &min_bounds, &max_bounds));