如何从 iPhone 指南针获取分钟和秒?
我有一个使用 iPhone 指南针的应用程序。 我使用 CLLocationDirection 磁头值。 它仅以度为单位,例如 234.543,例如,当我转动 iPhone 时,它会更改为 235.543 236.543 237 .543 238.543 等等。 分值 (.543) 不会改变。我希望获得比度数更高的精度,我的意思是,当我转动 iPhone 或获取分钟/秒值时,我希望点值 (.543) 也发生变化。 有人知道我怎样才能更精确地得到这个值吗? 谢谢!
I have an app that uses de iPhone's compass.
I use the CLLocationDirection magneticHeading value.
It is given only in degrees like 234.543, and when I turn the iPhone, for example, it changes to 235.543 236.543 237.543 238.543 and so on.
The point value (.543) doesn't change. I would like obtain more accuracy than degrees, I mean, I want the point value (.543) changes too when I turn the iPhone, or obtain the minutes/seconds value.
Anyone knows how can I have more precision in this value?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不熟悉iPhone API,但熟悉嵌入式系统的传感器。如果它是磁罗盘传感器,您可能会从传感器获得分辨率为 1 度的方向。 (考虑到来自地球的磁场相对较小,它可以如此准确,这是令人惊讶的)
尝试查看MagneticHeading和trueHeading(根据 API 文档)。我敢打赌,磁偏差的计算结果比 1 度增量更精确,这就是您看到 0.543 的原因;如果您向东或向西行驶 100 公里,您可能会看到不同的数字。
I'm not familiar with the iPhone API, but I am familiar with sensors for embedded systems. If it's a magnetic compass sensor, you're probably getting orientation from the sensor with 1 degree resolution. (which is amazing that it can be that accurate, given the relatively small magnetic fields from the Earth)
Try looking at both the magneticHeading and the trueHeading (per the API docs). I'll bet the magnetic deviation is calculated more precisely than in 1 degree increments, and that's why you're seeing the .543; you might see a different number if you travel 100km east or west.