Getting magnetic north from a xyz magnetometer (iPhone 3.0)

徘徊边缘 提交于 2019-12-02 18:33:12
cube

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

(these are from http://www.magneticsensors.com/datasheets/an203.pdf)

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

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.

Hope it helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!