Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clamp and wraparound methods #487

Open
faulesocke opened this issue Jul 11, 2019 · 1 comment
Open

Add clamp and wraparound methods #487

faulesocke opened this issue Jul 11, 2019 · 1 comment

Comments

@faulesocke
Copy link

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#

@jmi2k
Copy link

jmi2k commented Sep 10, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants