2014-06-25 64 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獲取更多信息