iOS 4核心横向运动姿态

发布于 2024-10-18 11:58:33 字数 360 浏览 2 评论 0原文

我一直在尝试根据从 CMMotionManager 返回的 CMAttitude 旋转视图,特别是俯仰 = x 和滚动 = y。我用参考态度来设定我的视野。 这对于纵向模式非常有效,但是当我尝试在横向视图中执行此操作时,它就出错了。 由于手机现在逆时针旋转 90 度,我希望 coremotion 能够知道景观已就位并保持俯仰和滚动有用。相反,我仍然让轴指向原来的方向。 为了尝试补偿,我简单地改变了 roll=x 上的符号并切换了 padding=y 。 这似乎一直有效,直到我将设备放在我面前并将其旋转 180 度。视野上下颠倒。

我的敏锐感觉告诉我,我需要对俯仰滚转和偏航进行适当的变换,以重新调整态度,

我希望一些天才或天才可以帮助我。数学显然不是我的强项。

I've been trying to rotate my view based on the CMAttitude returned from CMMotionManager specifically the pitch=x and roll=y. I'm using a reference attitude to set my horizon.
This works great for portrait mode but the minute i try to do it for a landscape view it goes wrong.
As the phone is now rotated 90 ccw I was hoping that coremotion would know landscape was in place and keep the pitch and roll useful. Instead I still have the axis pointing their original way.
To try and compensate I simply changed the sign on roll=x and switched pitch=y.
This appeared to work till I held the device in front of me and the turned around 180 degrees. The view spun upside down and inverted.

My spidy sense is telling me I need to apply a proper transformation on the pitch roll and yaw to reorientate the attitude

I'm hoping some geniuses or genii can help me. Maths is obviously not a strong point of mine.

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

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

发布评论

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

评论(1

好久不见√ 2024-10-25 11:58:33

你是对的,改变俯仰和横滚会导致严重的麻烦。最简单的方法似乎是采用新的参考态度,如 CoreMotionTeapot 示例中所示。当检测到方向变化时,您必须先获取当前姿态,然后将其与之前的参考姿态相乘,并将其设置为新的参考姿态。

Your are right, changing pitch and roll will lead into serious trouble. The simplest way seems to work with a new reference attitude like in CoreMotionTeapot sample. Just when the orientation change is detected, you have to grab the current attitude before multiplying it with your former reference attitude and set it as new reference attitude.

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