def normalize_angle(angle, min_, max_):
    """Retreave excess cycles from an angle."""
    turn = max_ - min_
    if angle in (float('inf'), float('-inf'), float('nan'), None):
        return float('nan')
    while angle > max_:
        angle -= turn
    while angle < min_:
        angle += turn
    return angle
