normalizeBearing function

double normalizeBearing(
  1. double bearing
)

Convert a bearing to be within the 0 to +360 degrees range. Compass bearing is in the rangen 0° ... 360°

Implementation

double normalizeBearing(final double bearing) => (bearing + 360) % 360;