iPhone - CLHeading:如何将 trueHeading 转换为矢量

发布于 2024-10-21 18:01:12 字数 110 浏览 3 评论 0原文

我知道如何获取磁航向的坐标:heading.x、heading.y、heading.z 问题是我需要 trueHeading 的 (x, y, z) 向量。我怎样才能创建这个向量?

谢谢你!

I know how to get the coordinates of the magnetic heading: heading.x, heading.y, heading.z
The thing is that I'd need the (x, y, z)-vector of the trueHeading. How can I create this vector?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

标点 2024-10-28 18:01:12

编辑:我已经改变了我的答案很多......

基本上你需要以与磁偏角角度。

困难的部分是您需要在水平面上旋转矢量。为此,您需要知道手机的方向。

以下是您需要执行的操作:

  1. 获取磁北矢量。

  2. 从加速度计获取重力矢量。

  3. 现在计算/查找磁偏角(这取决于您在世界上的位置,并且它也会随时间缓慢变化)。

  4. 将磁北向量绕重力向量旋转 X 度(其中 -X = 磁偏角) )。这将是棘手的部分,您需要温习一些 3D 三角。

Edit: I have changed my answer quite a bit...

Basically you need to rotate the magnetic north vector in the opposite direction to the Magnetic Declination angle.

The hard part is that you need to rotate the vector on a horizontal plane. For that you need to know the orientation of the phone.

Here is what you need to do:

  1. Get the magnetic north vector.

  2. Get the gravity vector from the accelerometer.

  3. Now calculate / look up the Magnetic Declination (it depends where you are in the world and it also varies slowly with time).

  4. Rotate the magnetic north vector X degrees about the gravity vector (where -X = Magnetic Declination). This will be the tricky part, you will need to brush up on some 3d trig.

终难遇 2024-10-28 18:01:12

感谢您的编辑...有趣,这正是我当时所做的。我获取了磁北向量,并使用旋转矩阵围绕重力向量旋转它,并在磁航向和真实航向之间进行变化。

问题是在这种情况下我依赖于磁矢量。
在某些情况下,我注意到磁矢量变得绝对疯狂,并且传感器提供了奇怪的值。

所以我想要的是获得独立于磁向量的 trueHeading 向量。好吧,多么愚蠢的想法——真正的航向很可能已经依赖于磁航向了。

不过-谢谢你的回答:)

Thank's for the edit...funny, that's exactly what I did then. I took the magnetic north vector and rotated it with a rotation matrix around the gravity vector with the variation between the magneticHeading and the trueHeading.

The thing is that I'm dependent on the magnetic vector in this case.
In some situations I noticed that the magnetic vector was going absolutely crazy and the sensor delivered weird values.

So what I wanted is to get the vector of the trueHeading which is independent from the magnetic vector. Ok, what a silly thought - the true heading is most probably anyway dependent on the magnetic heading already.

However - thank's for the answer :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文