[android sensor] TYPE_ROTATION_VECTOR

[android sensor] TYPE_ROTATION_VECTOR 에 대해서 정리하도록 한다. 
 

URL  : http://developer.android.com/reference/android/hardware/SensorEvent.html 

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/os/RotationVectorDemo.html
 

을 시작으로 정리한다.
 

Sensor.TYPE_ROTATION_VECTOR:


The rotation vector represents the orientation of the device as a combination of an angle and an axis, in which the device has rotated through an angle θ around an axis <x, y, z>.

The three elements of the rotation vector are <x*sin(θ/2), y*sin(θ/2), z*sin(θ/2)>, such that the magnitude of the rotation vector is equal to sin(θ/2), and the direction of the rotation vector is equal to the direction of the axis of rotation.

The three elements of the rotation vector are equal to the last three components of a unit quaternion <cos(θ/2), x*sin(θ/2), y*sin(θ/2), z*sin(θ/2)>.

Elements of the rotation vector are unitless. The x,y, and z axis are defined in the same way as the acceleration sensor.

The reference coordinate system is defined as a direct orthonormal basis, where:


X is defined as the vector product Y.Z
(It is tangential to the ground at the device's current location and roughly points East).
 

Y is tangential to the ground at the device's current location and points towards the magnetic North Pole.
 

Z points towards the sky and is perpendicular(직각) to the ground.

 

    values[0]: x*sin(θ/2)

    values[1]: y*sin(θ/2)

    values[2]: z*sin(θ/2)

    values[3]: cos(θ/2) (optional: only if value.length = 4)




    public static void getRotationMatrixFromVector (float[] R, float[] rotationVector)

    Since: API Level 9

    Helper function to convert a rotation vector to a rotation matrix. Given a rotation vector (presumably from a ROTATION_VECTOR sensor), returns a 9 or 16 element rotation matrix in the array R. R must have length 9 or 16. If R.length == 9, the following matrix is returned:

       /  R[ 0]   R[ 1]   R[ 2]   \
       
    |  R[ 3]   R[ 4]   R[ 5]   |
       
    \  R[ 6]   R[ 7]   R[ 8]   /
    If R.length == 16, the following matrix is returned:
       /  R[ 0]   R[ 1]   R[ 2]   0  \
       
    |  R[ 4]   R[ 5]   R[ 6]   0  |
       
    |  R[ 8]   R[ 9]   R[10]   0  |
       
    \  0       0       0       1  /

    Parameters
    Ran array of floats in which to store the rotation matrix
    rotationVectorthe rotation vector to convert



댓글

Designed by JB FACTORY