Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simple Maths
Message
From
10/11/2015 07:13:56
 
 
To
10/11/2015 07:08:37
Neil Mc Donald
Cencom Systems P/L
The Sun, Australia
General information
Forum:
Games
Category:
Trivia
Title:
Miscellaneous
Thread ID:
01627272
Message ID:
01627294
Views:
39
Hi,
See my reply to Lutz. I don't have to worry about that part of it - Android itself calculates the bearing based on WGS84

>Hi,
>Have a look at Greater Circle navigation https://en.wikipedia.org/wiki/Great-circle_navigation
>Keeping it simple, the shortest distance between two points on a sphere isn't accomplished by one compass heading, also you won't end up where you thought you would.
>
>
>>>>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
>>>
>>
>>I considered that one but thought there would be a way without converting both bearing and heading to 360deg values.
>>
>>My testing so far seems to show that this simplified versions would work:
>>
>>ArrowDirection = 360 + (Bearing - Orientation)
>>
>>In practice it actually makes more sense for me to convert the DeviceOrientation to a 360deg value earlier on so it just becomes:
>>
>>ArrowDirection = Bearing - Orientation
>>
>>In either case I don't think ArrowDirection will ever be > 360 so that removes another step.
>>
>>To be absolutely accurate I need to factor in the declination but that turns out to be simple - there's a built in android function:
GeomagneticField geoField = new GeomagneticField(
>>                        Double.valueOf(location.getLatitude()).floatValue(),
>>                        Double.valueOf(location.getLongitude()).floatValue(),
>>                        Double.valueOf(location.getAltitude()).floatValue(),
>>                        System.currentTimeMillis()
>>                );
>>float declination = geoField.getDeclination;
After that all I have to worry about is the Surface orientation - but I might just lock to the default and not worry about it (at least for now)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform