adjustModRotation function

double adjustModRotation(
  1. double rotation
)

Adjusts the rotation angle to be within the range of 0 to 2π.

Takes a rotation angle in radians and returns the adjusted angle within the range of 0 to 2π.

Implementation

double adjustModRotation(double rotation) {
  double twoPi = 2 * pi;
  if (rotation < 0) {
    rotation = -(rotation.abs() % twoPi);
  } else {
    rotation = rotation % twoPi;
  }
  return rotation;
}