nearestAngle = function( baseDeg, deg ) {
            while ( deg > baseDeg + 180 ) {
                deg -= 360;
            }

            while ( deg < baseDeg - 180 ) {
                deg += 360;
            }

            return deg;
        }
Calculate a degree which in range (-180, 180] of baseDeg