Hi,
I have a problem with the translation of the accelerometer results
from the phone to the world orientation.
The Z results seem OK  but the X and Y  get wrong values.

It was tested in horizontal phone move.
Attached is the code.

                public void onSensorChanged(SensorEvent event) {
                synchronized (this) {

//                      Log.d("MotionTest", "sensor: " + sensor + ", x: " + 
values[0] +
", y: " + values[1] + ", z: " + values[2]);
                        int type = event.sensor.getType();
                        if(type == Sensor.TYPE_ACCELEROMETER) {
                                acceleValues = event.values.clone();
                        } else if (type == Sensor.TYPE_MAGNETIC_FIELD) {
                                magnetValues = event.values.clone();
                        } else if (type == Sensor.TYPE_ORIENTATION) {
                                orientValues = event.values.clone();
                        }

                SensorManager.getRotationMatrix(mR, mI,
acceleValues ,magnetValues);
//              SensorManager.getOrientation(mR, orientValues);

        
acceleEarthValues[0]=mR[0]*acceleValues[0]+mR[1]*acceleValues[1]+mR[2]*acceleValues[2];
        
acceleEarthValues[1]=mR[3]*acceleValues[0]+mR[4]*acceleValues[1]+mR[5]*acceleValues[2];
        
acceleEarthValues[2]=mR[6]*acceleValues[0]+mR[7]*acceleValues[1]+mR[8]*acceleValues[2];


            }

                drawData();

        }

The mR and mI are defined as:

            private float[] mR = new float[9];
            private float[] mI = new float[9];

Please advice
Thanks
Ofer


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

Reply via email to