Hi everyone...

I'm back with the same issue for the last couple of days… I'm trying
to create a compass for my application BUT the difference is that,
instead of having a line always pointing to north, I want this line to
point for a specific point. I've been trying dozens of algorithms and
nothing works..
I've finally found one that points me exactlly to the point I want..
BUT it doesn't move if I change the position of the device which is my
objective.. basicly, what I want is that no matter the direction I'm
using my device.. the line always point me to the point
(picLatitude,picLongitude)…

I understood that for the line to move, I can't use static variables…
I need to use the values offered by the onSensorChanged(SensorEvent
event).

This are the data I have available:

event.values[0]: azimuth, rotation around the Z axis (device in
relation to north, 0º)
event.values[1]: pitch, rotation around the X axis
event.values[2]: roll, rotation around the Y axis
mLatitude: device current latitude gottern from GPS (variable)
mLongitude: device current longitude gotten from GPS (variable)
picLatitude: static picture latitude established previously
picLongitude: static picture longitude established previously
distance: distance in Km from device to the picture calculated
previously

And this the formula that works correct, and gives me the correct
angle.. ( BUT IT DOESN'T USE ANY OF THE SENSOR DATA SO THE LINE
COMPASS DOESNT MOVE):

double dLong = picLongitude - mLongitude;
double y =  (Math.sin(dLong) * Math.cos(picLatitude));
double x =  (Math.cos(mLatitude) * Math.sin(picLatitude) -
Math.sin(mLatitude)*Math.cos(picLatitude)*Math.cos(dLong));
double angleDegreesWrongRange = Math.abs(Math.toDegrees(Math.atan2(y,
x)));
float angleDegrees = (float) ((angleDegreesWrongRange+360) % 360);

myCompass.updateDirection(angleDegrees);

I got this "bearing" formula from this website:
http://www.movable-type.co.uk/scripts/latlong.html


Can someone please help me with this?
I've try adding, subtracting… the azimuth.. I've tried with the
others.. seriously at this point I'm just demoralized..

Thank you in advance

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to