emath::smart_aim

Function best_in_range_f64

Source
pub fn best_in_range_f64(min: f64, max: f64) -> f64
Expand description

Find the “simplest” number in a closed range [min, max], i.e. the one with the fewest decimal digits.

So in the range [0.83, 1.354] you will get 1.0, and for [0.37, 0.48] you will get 0.4. This is used when dragging sliders etc to get the values that users are most likely to desire. This assumes a decimal centric user.