Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 查找设备的标题_Android_Android Sensors_Magnetometer - Fatal编程技术网

Android 查找设备的标题

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,

我需要找到一个垂直放置的Android设备的朝向,以北面以东或以西的度数表示,如下所示:。我访问了传感器。从地磁传感器返回的事件[2]值发现,当我绕垂直轴完全旋转设备时,它们的变化范围为1到35。如何将此值转换为标题?非常简短的解释或链接将不胜感激。

查看SensorManager.getOrientation它返回3个角度,围绕3个轴

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