Re: [android-developers] Please help me with calculating direction from point A to B

2010-09-22 Thread Pedro Teixeira

I'm really not understanding how to go with this...

I've been reading and reading.. I can find all kind of algorithms.. I  
can find a haversin algorithm that points me to the correct direction  
if my device is pointing north.. but the needle is static... so if i  
change the device orientation the measure is incorrect... and I know  
this happens because I'm not using device's sensor values like  
azimuth, pitch and roll.. oh god.. 2 weeks on this.. I'm just  
desperate now.


On Sep 18, 2010, at 10:29 AM, Kostya Vasilyev wrote:


Pedro,

If I understand you correctly, you are having difficulties with the  
device's orientation.


The bearing angle seems to be computed in the horizontal plane. If  
you wish to adjust for the device's orientation, you need to  
concatenate it with the bearing angle.


Google for quaternions.

This is a (relatively) simple math technique to work with rotations  
the same way you can work with vectors: add / subtract, interpolate.


-- Kostya

18.09.2010 0:56, Pedro Teixeira пишет:

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




--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
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


Pedro Teixeira

www.pedroteixeira.org

--
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


Re: [android-developers] Please help me with calculating direction from point A to B

2010-09-22 Thread Christian Buchner
this sounds trivial to me.

Just compensate the error that is introduced by not actually pointing the
device north by subtracting that error from your arrow's pointing angle. No
need to change any algorithm, just compensate for the dude, you're holding
it wrong

-- 
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

Re: [android-developers] Please help me with calculating direction from point A to B

2010-09-22 Thread Pedro Teixeira

I've tried it.

Adding and subtracting the value: event.values[0], which is actually  
my Azimuth in degrees returned by the sensor.


But the orientation is off! ..

The algorithm gives the Correct value, but it doesn't move because  
there's not sensor variables involved.. so if I subtract the error it  
points in the wrong direction



On Sep 22, 2010, at 10:08 AM, Christian Buchner wrote:


this sounds trivial to me.

Just compensate the error that is introduced by not actually  
pointing the device north by subtracting that error from your  
arrow's pointing angle. No need to change any algorithm, just  
compensate for the dude, you're holding it wrong




--
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


Pedro Teixeira

www.pedroteixeira.org

--
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

Re: [android-developers] Please help me with calculating direction from point A to B

2010-09-22 Thread Pedro Teixeira
Basicly, if my device is pointing the wrong direction. I can't see the  
value.. because the arrow is static. The arrow is always static if I  
don't use any of the sensor values.


On Sep 22, 2010, at 10:08 AM, Christian Buchner wrote:


this sounds trivial to me.

Just compensate the error that is introduced by not actually  
pointing the device north by subtracting that error from your  
arrow's pointing angle. No need to change any algorithm, just  
compensate for the dude, you're holding it wrong




--
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


Pedro Teixeira

www.pedroteixeira.org

--
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

Re: [android-developers] Please help me with calculating direction from point A to B

2010-09-22 Thread Kostya Vasilyev

 Pedro,

I think you should learn something about the way direction (and 
orientation) is specified in computer programming.


http://en.wikipedia.org/wiki/Yaw,_pitch,_and_roll

http://en.wikipedia.org/wiki/Euler_angles

http://en.wikipedia.org/wiki/Rotation_representation_(mathematics)#Rotation_matrix_.E2.86.94_Euler_angles

I believe that Android orientation sensors work this way.

Now about the compass

There are two ways you can think about this:

First, take the value you get from the algorithm and make it into a 
vector in 3D space (i.e. think of the arrow you're going to draw to 
indicate direction). Then:


One: Compute the device's orientation matrix using sensor data. Take the 
inverse of this matix, and multiply the arrow vector by this matrix.


Two: Compute the device's orientation matrix using sensor data. Rather 
than interpreting it as a rotation matrix, think of it as defining a 
plane in space (aligned with the device's screen).  Then project the 
arrow vector onto this plane, in the plane's coordinates.


You might want to start with compensating just for the vertical axis 
(the device's rotation from the true north direction), it might be enough.


-- Kostya

22.09.2010 13:02, Pedro Teixeira пишет:

I'm really not understanding how to go with this...

I've been reading and reading.. I can find all kind of algorithms.. I 
can find a haversin algorithm that points me to the correct direction 
if my device is pointing north.. but the needle is static... so if i 
change the device orientation the measure is incorrect... and I know 
this happens because I'm not using device's sensor values like 
azimuth, pitch and roll.. oh god.. 2 weeks on this.. I'm just 
desperate now.


On Sep 18, 2010, at 10:29 AM, Kostya Vasilyev wrote:


Pedro,

If I understand you correctly, you are having difficulties with the 
device's orientation.


The bearing angle seems to be computed in the horizontal plane. If 
you wish to adjust for the device's orientation, you need to 
concatenate it with the bearing angle.


Google for quaternions.

This is a (relatively) simple math technique to work with rotations 
the same way you can work with vectors: add / subtract, interpolate.


-- Kostya

18.09.2010 0:56, Pedro Teixeira пишет:

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




--
Kostya Vasilyev -- WiFi Manager + pretty widget -- 
http://kmansoft.wordpress.com


--
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


Pedro Teixeira

www.pedroteixeira.org




--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received 

Re: [android-developers] Please help me with calculating direction from point A to B

2010-09-18 Thread Pedro Teixeira

Well.. I'm guessing it's to hard or impossible then.. :/

On Sep 17, 2010, at 9:56 PM, Pedro Teixeira wrote:


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


Pedro Teixeira

www.pedroteixeira.org

--
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


Re: [android-developers] Please help me with calculating direction from point A to B

2010-09-18 Thread Kostya Vasilyev

 Pedro,

If I understand you correctly, you are having difficulties with the 
device's orientation.


The bearing angle seems to be computed in the horizontal plane. If you 
wish to adjust for the device's orientation, you need to concatenate it 
with the bearing angle.


Google for quaternions.

This is a (relatively) simple math technique to work with rotations the 
same way you can work with vectors: add / subtract, interpolate.


-- Kostya

18.09.2010 0:56, Pedro Teixeira пишет:

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




--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
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


[android-developers] Please help me with calculating direction from point A to B

2010-09-17 Thread Pedro Teixeira
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