angles.js
function(a, b) {

      var m = this['SCALE'];
      var h = m / 2;

      // One-Liner:
      //return Math.min(mod(a - b, m), mod(b - a, m));

      var diff = this['normalizeHalf'](a - b);

      if (diff > h)
        diff = diff - m;

      return Math.abs(diff);
    }
function(a, b) {

      var m = this['SCALE'];
      var h = m / 2;

      // One-Liner:
      //return Math.min(mod(a - b, m), mod(b - a, m));

      var diff = this['normalizeHalf'](a - b);

      if (diff > h)
        diff = diff - m;

      return Math.abs(diff);
    }
function ( a , b ) { var m = this [ 'SCALE' ] ; var h = m / 2 ; // One-Liner: //return Math.min(mod(a - b, m), mod(b - a, m)); var diff = this [ 'normalizeHalf' ] ( a - b ) ; if ( diff > h ) diff = diff - m ; return Math . abs ( diff ) ; }
Calculate the minimal distance between two angles

@param {number} a
@param {number} b
@returns {number}
Calculate the minimal distance between two angles