Melanie taps her fingers impatiently whilst eyeing up her whip coiled on the wall, then scribbles...
Code:
ValueA var Word
ValueB var Word
ValueC var Word
Result var Word
If ValueA < ValueB then Swap ValueA,ValueB
ValueC=ValueA-ValueB
If ValueC < 180 then
ValueC=ValueC/2
Result=ValueB+ValueC
else
ValueC=360-ValueC
ValueC=ValueC/2
Result=ValueA+ValueC
endif
If Result = > 360 then Result=Result-360
There is only one 'anomaly' which could be adjusted whichever way you choose (although there is no true definitive answer). If ValueA and ValueB are exactly 180 degrees apart, you have two potential answers both of which are correct... eg ValueA is Zero and ValueB is 180, you have two answers - one being 90 and the other being 270. My little ditty above always selects the higher - 270 in this case. But what the hell do you expect for 30 seconds work?
Bookmarks