Android 查找设备的标题
我需要找到一个垂直放置的Android设备的朝向,以北面以东或以西的度数表示,如下所示:。我访问了传感器。从地磁传感器返回的事件[2]值发现,当我绕垂直轴完全旋转设备时,它们的变化范围为1到35。如何将此值转换为标题?非常简短的解释或链接将不胜感激。查看SensorManager.getOrientation它返回3个角度,围绕3个轴Android 查找设备的标题,android,android-sensors,magnetometer,Android,Android Sensors,Magnetometer,我需要找到一个垂直放置的Android设备的朝向,以北面以东或以西的度数表示,如下所示:。我访问了传感器。从地磁传感器返回的事件[2]值发现,当我绕垂直轴完全旋转设备时,它们的变化范围为1到35。如何将此值转换为标题?非常简短的解释或链接将不胜感激。查看SensorManager.getOrientation它返回3个角度,围绕3个轴 Computes the device's orientation based on the rotation matrix. When it returns,
Computes the device's orientation based on the rotation matrix.
When it returns, the array values is filled with the result:
values[0]: azimuth, rotation around the Z axis.
values[1]: pitch, rotation around the X axis.
values[2]: roll, rotation around the Y axis.
The reference coordinate-system used is different from the world coordinate-system defined for the rotation matrix:
X is defined as the vector product Y.Z (It is tangential to the ground at the device's current location and roughly points West).
Y is tangential to the ground at the device's current location and points towards the magnetic North Pole.
Z points towards the center of the Earth and is perpendicular to the ground.
您需要使用地磁和加速度传感器输入数据,以获得旋转矩阵。有关更多信息,请查看SensorManager