toNormalizedAngle method
This method normalizes the angle in radians to the range -π, π
.
If the angle is already within this range, it is returned unchanged.
Implementation
double toNormalizedAngle() {
if (this >= -pi && this <= pi) {
return this;
}
final normalized = this % tau;
return normalized > pi ? normalized - tau : normalized;
}