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
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With