Given two degrees in a circle of 360 degrees. Lets call them Source and Destination.
For example, a source can be 120 degrees and a destination 30 degrees.
Is there an elegant solution to the question of which direction of movement from source to destination is shorter, i.e. is it shorter clockwise (increase in degrees) or counterclockwise (decrease in degrees)?
For example, with the powers given above, then the solution would be: Go counterclockwise. On the other hand, with a source of both 350 and Destination as 20, then the solution would be: Go clockwise.
source
share