Another project
0

Configure Feed

Select the types of activity you want to include in your feed.

1use core::f64::consts::{PI, TAU}; 2 3#[must_use] 4pub(crate) fn wrap_delta(a: f64) -> f64 { 5 (a + PI).rem_euclid(TAU) - PI 6} 7 8#[must_use] 9pub(crate) fn contains(theta: f64, start: f64, sweep: f64, eps: f64) -> bool { 10 let delta = if sweep >= 0.0 { 11 (theta - start).rem_euclid(TAU) 12 } else { 13 (start - theta).rem_euclid(TAU) 14 }; 15 delta <= sweep.abs() + eps || delta >= TAU - eps 16} 17 18#[must_use] 19pub(crate) fn clamp(theta: f64, start: f64, sweep: f64, eps: f64) -> f64 { 20 if contains(theta, start, sweep, eps) { 21 return theta; 22 } 23 let end = start + sweep; 24 let to_start = wrap_delta(theta - start).abs(); 25 let to_end = wrap_delta(theta - end).abs(); 26 if to_start <= to_end { start } else { end } 27}