diff static method

double diff(
  1. double ang1,
  2. double ang2
)

Computes the unoriented smallest difference between two angles. The angles are assumed to be normalized to the range -Pi, Pi. The result will be in the range 0, Pi.

@param ang1 the angle of one vector (in -Pi, Pi ) @param ang2 the angle of the other vector (in range -Pi, Pi ) @return the angle (in radians) between the two vectors (in range 0, Pi )

Implementation

static double diff(double ang1, double ang2) {
  double delAngle;

  if (ang1 < ang2) {
    delAngle = ang2 - ang1;
  } else {
    delAngle = ang1 - ang2;
  }

  if (delAngle > math.pi) {
    delAngle = (2 * math.pi) - delAngle;
  }

  return delAngle;
}