Skip to content Skip to sidebar Skip to footer

Not Able To Fetch Correct Degree From Getorientation Method

I am trying to get the tilt angel from Android orientation. The values which i am getting from SensorManager.getOrientation(mRotationMatrix, mValuesOrientation) is not degrees..

Solution 1:

The getOrientation return the azimuth, pitch and roll in Radian.

mValuesOrientation[0] is the azimuth, rotation about the z-axis. mValuesOrientation[1] is the pitch, rotation about the x-axis. mValuesOrientation[2] is the roll, rotation about the y-axis.

If your phone is lying flat on a table, the pitch and roll should be almost 0, but not the azimuth. It is only 0 if your phone longer size, the y axis, is pointing exactly toward magnetic North.

You can use pitch or roll (depending on the device orientation) to calculate the inclination of the phone, ie the angle between the surface of the screen and the world xy plane or you can use the inclination of my answer at How to measure the tilt of the phone in XY plane using accelerometer in Android

You should also read my answer at Convert magnetic field X, Y, Z values from device into global reference frame to get a better understanding of the rotation matrix.

Post a Comment for "Not Able To Fetch Correct Degree From Getorientation Method"