Skip to main content

heading_difference

Function heading_difference 

Source
pub fn heading_difference(heading1: f64, heading2: f64) -> f64
Expand description

Calculate the difference between two headings on a bidirectional track.

Railway tracks can be traveled in either direction, so a heading and its opposite (180° apart) are considered equivalent. Returns a value in [0, 90] where 0 = perfectly aligned (same or opposite direction) and 90 = perpendicular.

§Arguments

  • heading1 - First heading in degrees (0-360)
  • heading2 - Second heading in degrees (0-360)

§Returns

Angular difference in degrees (0-90)