Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Compass Headings
Message
De
21/11/2016 04:40:43
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
21/11/2016 03:18:44
Information générale
Forum:
Games
Catégorie:
Question
Divers
Thread ID:
01643702
Message ID:
01643741
Vues:
26
>>>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
Great. Although I'd need to add a 'diff = 0 - diff' for my purposes (ie reverse the sign).
>
>FWIW, after mulling over Al and Gregory's suggestions I woke up this morning with the same idea - but you beat me to it!

This chance to think like a mathematician again (screw special cases, this can't be complicated, read the specs and ignore inelegant solutions) was a real refreshment.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform