angleDelta function

double angleDelta(
  1. double a,
  2. double b
)

Shortest signed angular distance, wrapped to (-π, π].

Implementation

double angleDelta(double a, double b) =>
    math.atan2(math.sin(a - b), math.cos(a - b));