Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compass Headings
Message
General information
Forum:
Games
Category:
Trivia
Miscellaneous
Thread ID:
01643702
Message ID:
01643717
Views:
47
>>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)
>
>A quick suggestion (VFP code):
>
SIGN(ABS(a1 - a2) - 180)
>
>-1 = counter-clockwise
>1 = clockwise
>0 = either
>Update: I just realized it doesn't work if angles in the 3rd and 4th quadrant. Sorry, Sat night here...

Thanks for the try :-}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform