I have a set of angles, and I want to find the angle which is the
midpoint of the range. This has proven much more difficult to find
than I expected, because of how angles "loop around" from 0 to 360 or
-180 to 180 -- if I take the mean average of the angles, I will not
necessarily get the angle between the two. For instance, if I have one
angle at 150, and another at -150, the mid angle I am looking for is
-180 or 180, but the mean average of the two would give 0, which is
not what I want.
At first I thought I could just make a conditional to handle the "loop
around" situations, but it seems every condition I solve creates a new
condition to thwart it. Is there a mathematical way to solve this
problem?


|