【问题标题】:Find heading for a device查找设备的航向
【发布时间】:2014-06-25 04:36:40
【问题描述】:

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

【问题讨论】:

    标签: android android-sensors magnetometer


    【解决方案1】:

    查看 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 了解更多信息

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-11
      • 1970-01-01
      • 1970-01-01
      • 2013-12-02
      相关资源
      最近更新 更多