Function cavalier_contours::core::math::delta_angle
source · pub fn delta_angle<T>(angle1: T, angle2: T) -> Twhere
T: Real,
Expand description
Returns the smaller difference between two angles.
Result is negative if normalize_radians(angle2 - angle1) > PI
. See normalize_radians for
more information.
Examples
use std::f64::consts::PI;
assert!(delta_angle(5.0 * PI, 5.0 * PI).fuzzy_eq(0.0));
// note here the return is positive in both cases (since there is PI difference)
assert!(delta_angle(4.0 * PI, 5.0 * PI).fuzzy_eq(PI));
assert!(delta_angle(5.0 * PI, 4.0 * PI).fuzzy_eq(PI));
// these cases show when the order can change the sign
assert!(delta_angle(0.5 * PI, 0.25 * PI).fuzzy_eq(-0.25 * PI));
assert!(delta_angle(0.25 * PI, 0.5 * PI).fuzzy_eq(0.25 * PI));