Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Compass Headings
Message
De
20/11/2016 04:59:33
 
 
À
19/11/2016 12:42:03
Information générale
Forum:
Games
Catégorie:
Question
Divers
Thread ID:
01643702
Message ID:
01643718
Vues:
58
>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
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform