normalize static method

double normalize(
  1. double angle
)

Computes the normalized value of an angle, which is the equivalent angle in the range ( -Pi, Pi ].

@param angle the angle to normalize @return an equivalent angle in the range (-Pi, Pi]

Implementation

static double normalize(double angle) {
  while (angle > math.pi) angle -= PI_TIMES_2;
  while (angle <= -math.pi) angle += PI_TIMES_2;
  return angle;
}