I've been looking at all of this the last couple days.

I have an application that puts the three numeric values on the
display. The code is below and I _think_ it is working okay.

My test is to hold the phone against a wooden(!) door so I have a
nearly vertical, steady surface. Say I put the back of the phone
against the wall. I then rotate it through 360 degrees. The bearing
(compass reading -  (outR[0])) remains steady. The third value (value
[2]) rotates through 0 to 180, -180 to -1. If I put the end of the
phone against the door the second value (value[1]) rotates through 0
(right side pointing up) to 80 (laying flat, screen up) to 0 (left
side up) to -80 (-81) when upside down. {It goes 0 to 80 to 0 to -80
to -1, in short).

So basically the numbers look good for determing the position on a
sphere similar to that used in the Google SkyMap application. I
haven't looked at the scaling etc. The only conversion, as you see, is
from raidians to degrees. This is my first result that looked
approximetly correct so there maybe some fine adjustments needed on
conversions, etc and the code needs clean up.

I'm doing the calculation only after receiving an update from the
accelerometer, skipping the magnetic update. I figured doing it each
time was to fast.

Hope this helps. I now need to determine if the three results do
actually give the spherical position. I don't think it is given
directly but needs to be interpolated. Once I get it figured out I'll
put it on my blog.

A word of caution - being near a computer or monitor can distort the
magnetic field. As can being by a metal door. Make sure you are away
from these when testing.

Any comments appreciated.

Rud
http://mysticlakesoftware.blogspot.com/

            // make sure there are values from magnetic field,
accelerometer, and only calc after an accerlometer reading.
            //
            if (mags != null && accels != null && isA) {
                boolean b = SensorManager.getRotationMatrix(R, I,
accels, mags);

                // remap to "camera" mode - right side up, screen
facing me
                SensorManager.remapCoordinateSystem(R,
SensorManager.AXIS_X, SensorManager.AXIS_Z, outR);
                SensorManager.getOrientation(outR, values);
                int[] v = new int[3];

                v[0] = (int) (values[0] * 57.2957795);   // radians to
degrees
                v[1] = (int) (values[1] * 57.2957795);
                v[2] = (int) (values[2] * 57.2957795);

                isA = false;

                // update display
                Exp.mText01.setText("" + v[0]);
                Exp.mText02.setText("" + v[1]);
                Exp.mText03.setText("" + v[2]);
            }

On Jul 10, 4:53 am, RS <rajeshs...@gmail.com> wrote:
> Anybody using sensors and changing orientation > 90deg?
>
> On Jun 30, 4:31 pm, RS <rajeshs...@gmail.com> wrote:
>
>

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