[android sensor] TYPE_ROTATION_VECTOR
- Mobile/android
- 2011. 12. 8.
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)
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] \If R.length == 16, the following matrix is returned:
| R[ 3] R[ 4] R[ 5] |
\ R[ 6] R[ 7] R[ 8] /
/ 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
R | an array of floats in which to store the rotation matrix |
---|---|
rotationVector | the rotation vector to convert |
'Mobile > android' 카테고리의 다른 글
[Android] JNI TIP, udev (0) | 2011.12.20 |
---|---|
[Android] DownloadManager 를 이용한 파일 다운로드하기 (3) | 2011.12.16 |
[NDK build] Android.mk Application.mk (0) | 2011.12.07 |
....3D engine(Irrlicht) on android (0) | 2011.11.13 |
Google Android Library (0) | 2011.11.10 |