cgmath
cgmath copied to clipboard
Add `clamp` and `wraparound` methods
These methods are quite useful whenever you have to make sure that a value stays inside a specified range. Although there is f32::clamp and f64::clamp these are not stabilized yet so it would be nice to have them inside cgmath.
wraparound should have a signature like this:
fn wraparound<S>(x: S, min: S, max: S) -> S
See also https://stackoverflow.com/questions/4633177/c-how-to-wrap-a-float-to-the-interval-pi-pi#
Just wanted to point out fXX::clamp is stable since Rust version 1.50.0. It would be nice to have it for the common use case of clamping the pitch angle of a camera (uhm, my current use case).