wrap360 method

double wrap360()

Normalizes this double value in degrees to the range [0.0, 360.0[.

Examples:

  • 5.0 => 5.0
  • -5.0 => 355.0
  • 362.0 => 2.0

As a special case if this is double.nan then double.nan is returned.

Implementation

double wrap360() {
  if (this >= 0.0 && this < 360.0) {
    return this;
  }
  return this % 360.0;
}