def normalize_bearing(b):
    """ normalizes bearing into [0...360) range, so -1 becomes 359 and 721 will return 1 """
    while b < 0:
        b = b + 360.0
    while b >= 360.0:
        b = b - 360.0
    return b