code: public static float angularDistance (float a1, float a2) {
          float ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2);
          return Math.min(Math.abs(a1 - a2), Math.abs(ma1 - ma2));
      }
docs: Returns the (shortest) distance between two angles, assuming that both angles are in
  [-pi, +pi].