參考網(wǎng)址:https://developer.android.google.cn/reference/android/hardware/SensorEvent.html#values
Sensor.TYPE_ROTATION_VECTOR
https://developer.android.com/guide/topics/sensors/sensors_overview.html
https://developer.android.com/guide/topics
關于歐拉旋轉的萬向鎖非常的一個解釋独柑。萬向鎖會導致少一個自由度
相關教程 最為詳細(https://blog.csdn.net/cy_weiyi/article/details/46123785)
相關視頻 https://v.youku.com/v_show/id_XNzkyOTIyMTI=.html
Sensor Coordinate System
In general, the sensor framework uses a standard 3-axis coordinate system to express data values. For most sensors, the coordinate system is defined relative to the device's screen when the device is held in its default orientation (see figure 1). When a device is held in its default orientation, the X axis is horizontal and points to the right, the Y axis is vertical and points up, and the Z axis points toward the outside of the screen face. In this system, coordinates behind the screen have negative Z values. This coordinate system is used by the following sensors:
1. 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>.
這個旋轉矢量將設備的方向表示為一個角度和坐標軸酌摇,設備圍繞<x,y,z> 旋轉θ角度。
The three elements of the rotation vector are <xsin(θ/2), ysin(θ/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), xsin(θ/2), ysin(θ/2), z*sin(θ/2)>.
旋轉矢量的三個元素等于一個四元數(shù)的后三位艾帐。
Elements of the rotation vector are unitless. The x,y, and z axis are defined in the same way as the acceleration sensor.
旋轉向量中的元素是沒有單位的嗦玖,x,y,z軸定義為與加速度計傳感器一樣的澜掩。
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 magnetic north.
Z points towards the sky and is perpendicular to the ground.
values[0]: xsin(θ/2)
values[1]: ysin(θ/2)
values[2]: z*sin(θ/2)
values[3]: cos(θ/2)
values[4]: estimated heading Accuracy (in radians) (-1 if unavailable)
values[3], originally optional, will always be present from SDK Level 18 onwards. values[4] is a new value that has been added in SDK Level 18.
TYPE_GAME_ROTATION_VECTOR
A constant describing an uncalibrated rotation vector sensor type.
type_game_rotation_vector 是沒有經(jīng)過校正的設備四元素贯涎,
Identical to TYPE_ROTATION_VECTOR except that it doesn't use the geomagnetic field. Therefore the Y axis doesn't point north, but instead to some other reference, that reference is allowed to drift by the same order of magnitude as the gyroscope drift around the Z axis. 這個方向沒有使用地磁場谴麦,轉向了其他參考蠢沿。
In the ideal case, a phone rotated and returning to the same real-world orientation should report the same game rotation vector (without using the earth's geomagnetic field). However, the orientation may drift somewhat over time.
See SensorEvent.values for more details.
Sensor.TYPE_ORIENTATION
Sensor.TYPE_ORIENTATION:All values are angles in degrees.
-
values[0]: Azimuth, angle between the magnetic north direction and the y-axis, around the z-axis (0 to 359). 0=North, 90=East, 180=South, 270=West
values[1]: Pitch, rotation around x-axis (-180 to 180), with positive values when the z-axis moves toward the y-axis.
values[2]: Roll, rotation around the y-axis (-90 to 90) increasing as the device moves clockwise.
Note: This definition is different from yaw, pitch and roll used in aviation where the X axis is along the long side of the plane (tail to nose).