adjustModRotation function
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;
// Proper modulo that handles negative numbers correctly
rotation = rotation % twoPi;
if (rotation < 0) {
rotation += twoPi;
}
return rotation;
}