- R
- is an array of 9 floats holding the rotation matrix R when this function returns. R can be null.
- I
- is an array of 9 floats holding the rotation matrix I when this function returns. I can be null.
- gravity
- is an array of 3 floats containing the gravity vector expressed in the device's coordinate. You can simply use the SensorEvent.Values returned by a Android.Hardware.SensorEvent of a Android.Hardware.Sensor of type Sensor.TYPE_ACCELEROMETER.
- geomagnetic
- is an array of 3 floats containing the geomagnetic vector expressed in the device's coordinate. You can simply use the SensorEvent.Values returned by a Android.Hardware.SensorEvent of a Android.Hardware.Sensor of type Sensor.TYPE_MAGNETIC_FIELD.
Documentation for this section has not yet been entered.
Computes the inclination matrix I as well as the rotation matrix R transforming a vector from the device coordinate system to the world's coordinate system which is defined as a direct orthonormal basis, where:
By definition:
[0 0 g] = R * gravity (g = magnitude of gravity)
[0 m 0] = I * R * geomagnetic (m = magnitude of geomagnetic field)
R is the identity matrix when the device is aligned with the world's coordinate system, that is, when the device's X axis points toward East, the Y axis points to the North Pole and the device is facing the sky.
I is a rotation matrix transforming the geomagnetic vector into the same coordinate space as gravity (the world's coordinate space). I is a simple rotation around the X axis. The inclination angle in radians can be computed with SensorManager.GetInclination(Single[]).
Each matrix is returned either as a 3x3 or 4x4 row-major matrix depending on the length of the passed array:
If the array length is 16:
java Example
/ M[ 0] M[ 1] M[ 2] M[ 3] \ | M[ 4] M[ 5] M[ 6] M[ 7] | | M[ 8] M[ 9] M[10] M[11] | \ M[12] M[13] M[14] M[15] /
Note that because OpenGL matrices are column-major matrices you must transpose the matrix before using it. However, since the matrix is a rotation matrix, its transpose is also its inverse, conveniently, it is often the inverse of the rotation that is needed for rendering; it can therefore be used with OpenGL ES directly.
Also note that the returned matrices always have this form:
java Example
/ M[ 0] M[ 1] M[ 2] 0 \ | M[ 4] M[ 5] M[ 6] 0 | | M[ 8] M[ 9] M[10] 0 | \ 0 0 0 1 /
If the array length is 9:
java Example
/ M[ 0] M[ 1] M[ 2] \ | M[ 3] M[ 4] M[ 5] | \ M[ 6] M[ 7] M[ 8] /
The inverse of each matrix can be computed easily by taking its transpose.
The matrices returned by this function are meaningful only when the device is not free-falling and it is not close to the magnetic north. If the device is accelerating, or placed into a strong magnetic field, the returned matrices may be inaccurate.