Skip to main content

angular_difference

Function angular_difference 

Source
pub fn angular_difference(a: f64, b: f64) -> f64
Expand description

Computes the shortest signed angular difference a - b in degrees.

Handles wraparound at ±180°. The result is in the range (-180°, 180°].

§Example

use celestial_core::utils::angular_difference;

// Simple case
assert_eq!(angular_difference(90.0, 45.0), 45.0);

// Across the 0°/360° boundary: 10° is 20° ahead of 350°
assert!((angular_difference(10.0, 350.0) - 20.0).abs() < 1e-12);