从xyz磁力计(iPhone 3.0)获得磁北 [英] Getting magnetic north from a xyz magnetometer (iPhone 3.0)

查看:549
本文介绍了从xyz磁力计(iPhone 3.0)获得磁北的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上正在重新发布iphone开发板上的一个问题。我没有问过它,但是在试图找到答案时我发现了它。还没有人在那里做出回应,所以我想我会尝试在这里发帖。

I'm actually reposting a question from the iphone development boards. I didn't ask it, but I found it when trying to find its answer. Nobody had yet responded there, so I thought I'd try posting it here.

有没有人知道关于从CLHeading的原始xyz值计算磁航向的算法的任何细节?我相信必须有一个适用于不同磁力计的一般方法。

Does anybody know any specifics about the algorithm of computing the magnetic heading from the raw xyz values of CLHeading? I am sure there must be a general approach to this that works for different magnetometers as well.

推荐答案

如果你不想要使用 trueHeading 值,并假设罗盘完全水平,标题可以这样计算:

If you don't want to use the trueHeading value, and assuming that the compass lies perfectly horizontal, the heading can be computed this way:


  • (y> 0)heading = 90 - atan2(x,y)* 180 / pi

  • (y< 0)heading = 270 - atan2(x ,y)* 180 / pi

  • (y = 0,x< 0)heading = 180.0

  • (y = 0,x> 0) heading = 0.0

  • (y>0) heading = 90 - atan2(x,y)*180 / pi
  • (y<0) heading = 270 - atan2(x,y)*180 / pi
  • (y=0, x<0) heading = 180.0
  • (y=0, x>0) heading = 0.0

(这些来自 http://www.magneticsensors.com/datasheets/an203.pdf

...加上标题必须更正磁偏差磁偏角

... plus the heading must be corrected for Magnetic deviation and Magnetic declination

如果罗盘不是水平的,你应该只使用水平分量(你不能忽略z轴),将(x,y,z)矢量投影到一个平面上。平行于地球表面,然后根据投影的x和y计算航向。

in case the compass is not horizontal, you should use only the horizontal component (you can not ignore the z axis) by projecting the (x, y, z) vector to a plane that is parallel to the earth surface and then compute the heading from this projected x and y.

希望它有所帮助。

这篇关于从xyz磁力计(iPhone 3.0)获得磁北的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆