Given the two bearings, how do I find the smallest angle between them?
So, for example, if 1 heading is 340 degrees and the second is 10 degrees, the smallest angle will be 30 degrees.
I attached a photo to show what I mean. I tried to subtract one from the other, but this did not work because of the wrapper around the circle effect. I also tried using negative degrees (180-359 - from -180 to 0), but this was messed up when trying to calculate the angle between a positive and negative number.
I am sure there should be an easier way to have many if .
Thank you for your help. Adam
BTW. This is a navigation issue, so the circle radius is unknown.

Adam davies
source share