使用横滚、俯仰和偏航或四元数或旋转矩阵从 CMAttitude 计算高度和方位角

发布于 2024-11-03 06:15:12 字数 471 浏览 0 评论 0原文

我遇到一个问题。我想将 iPhone 的 CMAttitude 信息转换为海拔高度(0 到 90 度)和方位角(0 到 360 度)。我用谷歌搜索并找到了一些讨论它的线程,但没有一个线程给出了肯定的答案,而且大多数讨论四元数和欧拉角的文章都是太多的数学,无法塞进我的大脑!

是否有一些开源材料可以使这项任务变得容易?或者有人编写了代码来执行此转换?

编辑: 首先,抱歉这么抽象!

方位角是设备指向地球表面的方向。如北= 0 度,东北= 45 度,东= 90 度,南= 180 度等。范围在 0 度到 360 度之间:

在此处输入图像描述

高度是从地球平面到物体的角度在天空中: 在此处输入图像描述

谢谢,

Raj

I am struck with a problem. I want to convert the CMAttitude information of an iPhone to Altitude (0 to 90deg) and Azimuth (0 to 360 deg). I have googled around and hit some threads which discuss about it, but none of threads turn out with a positive answer and most of the articles discussing Quaternion and Euler angles are too much mathematics to stuff into my brain!

Is there some open source material which does this task easy? Or someone has written code to perform this conversion?

Edit:
First off, sorry for being so abstract!

Azimuth is the direction on the surface of the earth towards which the device is pointing. Like North = 0 deg, North East = 45deg, East = 90 deg, South = 180 deg and so on. Ranges between 0 deg to 360 deg:

enter image description here

Altitude is the angle made from the plane of the earth to an object in the sky:
enter image description here

Thanks,

Raj

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

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

发布评论

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

评论(1

后知后觉 2024-11-10 06:15:12

使用 CMDeviceMotion,您可以获得具有“滚动、俯仰和偏航”的 CMAttitude 对象 - 例如,假设手机处于纵向模式,“偏航”是“方位角”,“俯仰”是手机相对于地面的倾斜度,或天顶,“滚动”是关于指向屏幕的矢量,而不是您感兴趣的。

事情变得有点棘手,因为“方位角”是 3D 磁矢量的投影(指向磁北极)到平坦的“地”平面,该平面根据设备方向而变化,但鉴于对这些术语的理解,诸如 这个应该更容易理解。如果您只需要应用程序在一个方向上工作,事情就会变得简单得多。

PS“高度”几乎专门用于指给定参考(海平面、大地高度等)的海拔或高度。 “Zenith”或“pitch”是更好的选择,并且由于您使用的是 iOS,因此您应该坚持它们的坐标方案:(lat、lon、alt)、(pitch、yaw、roll)。

Using CMDeviceMotion, you can get a CMAttitude object with "roll, pitch and yaw" - where for example, given a phone held in portrait mode "yaw" is "azimuth", "pitch" is the tilt of the phone with respect to ground, or zenith, and "roll" is about the vector pointing through the screen and not what you're interested in.

Things get a bit tricky because "azimuth" is a projection of the 3D magnetic vector (pointing towards the magnetic north pole) on to the flat "ground" plane, which changes depending on device orientation, but given this understanding of the terms, threads like this one should be much more understandable. If you only need your application to work in one orientation things get much simpler.

P.S. "altitude" is almost exclusively used to refer to elevation or height about a given reference (sea level, geodetic height etc). "Zenith" or "pitch" are preferable, and since you're on iOS, you should stick to their coordinate scheme: (lat, lon, alt), (pitch, yaw, roll).

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