nalgebra/nalgebra-glm/src/ext/scalar_common.rs

23 lines
610 B
Rust
Raw Normal View History

2018-09-21 01:54:12 +08:00
use na;
2018-09-21 01:54:12 +08:00
use traits::Number;
2018-09-22 23:36:08 +08:00
/// Returns the maximum among three values.
pub fn max3_scalar<N: Number>(a: N, b: N, c: N) -> N {
2018-09-21 01:54:12 +08:00
na::sup(&na::sup(&a, &b), &c)
}
2018-09-22 23:36:08 +08:00
/// Returns the maximum among four values.
pub fn max4_scalar<N: Number>(a: N, b: N, c: N, d: N) -> N {
2018-09-21 01:54:12 +08:00
na::sup(&na::sup(&a, &b), &na::sup(&c, &d))
}
2018-09-22 23:36:08 +08:00
/// Returns the maximum among three values.
pub fn min3_scalar<N: Number>(a: N, b: N, c: N) -> N {
2018-09-21 01:54:12 +08:00
na::inf(&na::inf(&a, &b), &c)
}
2018-09-22 23:36:08 +08:00
/// Returns the maximum among four values.
pub fn min4_scalar<N: Number>(a: N, b: N, c: N, d: N) -> N {
2018-09-21 01:54:12 +08:00
na::inf(&na::inf(&a, &b), &na::inf(&c, &d))
}