Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple Maths
Message
De
09/11/2015 17:34:04
 
 
À
09/11/2015 15:06:09
Information générale
Forum:
Games
Catégorie:
Question
Titre:
Divers
Thread ID:
01627272
Message ID:
01627279
Vues:
55
>On an Android device you can obtain:
>
>(a) From the magnetometer: The device orientation (i.e orientation relative to N).
>(b) From the GPS : Bearing from current location to a specified other location.
>
>Both of the values are returned as the number of degrees E. of North.
>So they are in the range of +0- +180 or -1 to -179 (-180 might be possible - haven't checked)
>
>I want to put an arrow on the screen pointing from the current location to the specified location (in the range of 0-360)
>What is the most efficient algorithm ?
>
>Actually the magnetometer reading if for Magnetic N. and the bearing is True North but I can adjust for that later (same for the device window orientation)
>
>I can see a few implementations on the net but I've a feeling that they could be simplified..........
>
>Suggestions ?

I'd think it would just be addition/subtraction:

1. Convert both GPS bearing and magnetic device orientation (after any deviation corrections) to a range of 0 - 359 degrees, where 0deg is due north

2. Direction of arrow on device screen, in degrees:
ArrowDirection = (GPS Bearing) - (Device Orientation)

IF ArrowDirection < 0
  ArrowDirection = ArrowDirection + 360

ENDIF
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform