Message
From
20/11/2016 12:01:54
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
General information
Forum:
Games
Category:
Trivia
Miscellaneous
Thread ID:
01643702
Message ID:
01643730
Views:
44
>General sort of question:
>
>I'm drawing a compass and need to determine the 'shortest' direction in which to rotate the compass (clockwise or anti-clockwise) between old and new bearings (in degrees).
>In most cases it is simple but when the old and new values span the 0 degree point those solutions don't work.....
>
>Anyone got a foolproof algorithm (language doesn't matter - just the logic)

Why not simply
dif=(angle2-angle1)%360
if dif>180
   dif=dif-360
endif

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View