2014-06-25 67 views
1

我需要找到垂直持有的Android设备(如:Heading)的标题(以东或东的度数表示)。我访问了从地磁传感器返回的sensor.event [2]值,发现它们在1到35之间变化,因为我完全围绕垂直轴旋转设备。我怎样才能将这个值转换为标题?一个非常简短的解释或链接将不胜感激。查找设备的标题

回答

0

查看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获取更多信息