Using a float instead of a double caused accumulation of error in the calculated distance, which in rare cases triggered an assert in get_shortest_direction().
69731b1d