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