Hi!

I've been trying to map the accelerometer values to earth coordinates
using the rotation matrix.

I would expected to have in the Z axis the Gravity value always, but
the remapped coordinates when I move the phone shows the Gravity value
in the X and in the Y coordinate also.

Does anyone has an example of this kind of mapping?

I have been trying with this code:

You have in accels and mags the values of the accelerations and
magnetic field.

                final int matrix_size = 16;

                float [ ] R2 = new float [ matrix_size ];
                float [ ] outR = new float [ matrix_size ];

                float [ ] I = new float [ matrix_size ];

                float [ ] I2 = new float [ 4 ];

                SensorManager.getRotationMatrix ( R2, I, accels, mags );

//              SensorManager.remapCoordinateSystem ( R2, SensorManager.AXIS_X,
//                              SensorManager.AXIS_Z, outR );
//              outR = R2;
//              SensorManager.getOrientation ( outR, I2 );
//              Log.d (TAG, "inclineation values: " + I2 [ 0 ] + " " + I2 [ 1 ] 
+
" " + I2 [ 2 ]);

                float [ ] v = new float [ 4 ];

                float [ ] v2 = new float [ 4 ];
                v2 [ 0 ] = accels [ 0 ];
                v2 [ 1 ] = accels [ 1 ];
                v2 [ 2 ] = accels [ 2 ];
                v2 [ 3 ] = 0.0f;

                Matrix.multiplyMV ( v, 0, outR, 0, v2, 0 );

                Log.d (TAG, "Rotated values: " + v[0] + " " + v[1 ] + " " + v 
[2]);

Any ideas of what am I doing wrong?

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