public static double normalizeAngle (double a) {
        while (a < -Math.PI) {
            a += TWO_PI;
        }
        while (a >= Math.PI) {
            a -= TWO_PI;
        }
        return a;
    }
public static double normalizeAngle ( double a ) { while ( a < - Math . PI ) { a += TWO_PI ; } while ( a >= Math . PI ) { a -= TWO_PI ; } return a ; }
Returns an angle in the range [-pi, pi).