4

i have come across this code which uses the phones sensors to get the orientation of the device in degrees along the 3 axes... this value is calculated from a 4x4 matrix called rotation matrix.. so i was wondering what kind of data is stored in the rotation matrix ?

the code is similar to the one in this example Android: Problems calculating the Orientation of the Device

Community
  • 1
  • 1
user2462435
  • 79
  • 2
  • 5

1 Answers1

7

The Wikipedia article about rotation matrices is reasonable. Basically, the rotation matrix tells you how to map a point in one co-ordinate system to a point in a different co-ordinate system. In the context of Android sensors, the rotation matrix is telling you how to map a point from the co-ordinate system of the phone (where the phone itself lies in the x-y plane) to the real world North/East/"Gravity-direction" co-ordinate system.

Android uses either 3x3 or 4x4 rotation matrices. When 4x4, it's the Quaternion representation of a rotation. For the 3x3 case, in terms of the Euler Angles aximuth, pitch and roll, see my answer to 'Compute rotation matrix using the magnetic field' for how those angles are embedded in the rotation matrix (NB: the accepted answer to that question is wrong).

Community
  • 1
  • 1
Stochastically
  • 7,616
  • 5
  • 30
  • 58
  • 1
    I know this is old, but just to clarify a point that confused me about this answer: while you can calculate Euler Angles from a 3x3 rotation matrix, the values *in* the 3x3 matrix are not Euler Angles and can be used as a straight forward rotation matrix, if that's what you're going for. – Bob Liberatore Feb 07 '20 at 02:29