Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simple Maths
Message
From
10/11/2015 13:44:51
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
General information
Forum:
Games
Category:
Trivia
Title:
Miscellaneous
Thread ID:
01627272
Message ID:
01627314
Views:
38
>>>>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 ?
>>>
>>>son in law, not me:
>>>
>>>angle_of_arrow = atan2(target_y-ownpos_y,target_x-ownpos_x)-atan2(Magnetothing_y,Magnetothing_x) (+90°*n?)
>>>
>>>last term is possible offset.
>>>
>>>update:
>>>
>>>atan2(Magnetothing_y,Magnetothing_x) returns an angle. Skip it
>>>Just norm to angle of the magnetometer to 0-360 by adding 180.
>>>
>>>possibly you need to play with sign of the number but in general
>>
>>
>>Update 2
>>
>>This is true for a target in close range, where you can approx earth as a plane. I f you go farther it becomes a bit more tricky. Do you like to point a straight line (digging), great circle or what?
>
>Hi,
>Given two locations Android's BearingTo() function already returns the bearing as the bearing based on shortest path using WGS84.
>The solution turned out to be simple - see my reply to Al

I can not realy follow it.

As long as this is the great circle it's the shortest distance. If it's just heading - this will not work

But to test is simple
Select a destination same latitude as you are but 90° east. If your calculation ends up just east it's not the shortest path. Should more north in it.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform