pub fn shift_into_range(
range: Interval,
t: f64,
period: Option<f64>,
) -> Option<f64>Expand description
t moved by whole periods into range when it can be; a parameter of
a non-periodic entity (period of None) only if it already lies in
range. The shift is the smallest one that brings t to or above
range.lo(), so the answer is the first translate at or after the
start, and None when that overshoots range.hi().
use arris_math::{Interval, shift_into_range};
let range = Interval::new(1.0, 2.0).unwrap();
assert_eq!(shift_into_range(range, 1.5 + 6.0, Some(3.0)), Some(1.5));
assert_eq!(shift_into_range(range, 0.5, Some(3.0)), None);
assert_eq!(shift_into_range(range, 1.5, None), Some(1.5));
assert_eq!(shift_into_range(range, 2.5, None), None);