Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compass Headings
Message
From
20/11/2016 09:33:58
 
 
To
20/11/2016 04:59:33
General information
Forum:
Games
Category:
Trivia
Miscellaneous
Thread ID:
01643702
Message ID:
01643722
Views:
27
>>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)
>
>Possibility one : move1 = the difference between oldPos and newPos gives a distance and a direction
>
>The other possibility (move2) is to take the opposite direction, where the distance is 360 - abs(move1)
>
>Take the move with the minimum absolute value

May be being thick but I don't see how that works. Can you demonstrate with these examples:

Old New

350 2 (Should be clockwise)
10 190 (Doesn't matter)
20 190 (Clockwise)
10 350 (Anti-clockwise)
90 70 (Anti-clockwise)
5 190 (Anti-clockwise)
2 350 (Anti-clockwise)

I don't care about the length of the arc - just in which direction to move.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform