iPhone - 了解iPhone旋转 [英] iPhone - understanding iPhone rotation

查看:149
本文介绍了iPhone - 了解iPhone旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图理解这一点,试图在墙上敲我的头。请参阅下一张图片。

I am banging my head on the wall trying to understand this. See the next picture.

假设我在桌子上放了一个iPhone。此时通过核心运动的旋转读数为0,0,0,用于偏航,滚转和俯仰(图片A)。

Suppose I have an iPhone resting on a table. At this time the rotation readings thru core motion are 0,0,0 for yaw, roll and pitch (picture A).

然后我将其滚动90度。现在它坐在桌子上,左侧是主页按钮。现在它读取0,0,0(图片B)。

Then I roll it 90 degrees. Now it is sitting on the table with its left side, home button on the right. Now it reads 0,0,0 (picture B).

现在我将它偏转180度。它现在坐在桌子右侧。左侧的主页按钮。它现在读取180,0,0(图片C)。

Now I yaw it 180 degrees. It is now sitting with its right side on the table. Home button on the left. It now reads 180,0,0 (picture C).

如果我现在滚动它就会出现问题。假设我将它滚动-45度。我应该读180,-45,0但我正在读180,-45,180 ???? (图片D)。

The problem comes if I roll it now. Suppose I roll it -45 degrees. I should be reading 180,-45,0 but instead I am reading 180,-45,180???? (picture D).

为什么?如果我从来没有改变它,为什么它给我一个音高值?如何通过其他角度的旋转来影响音高?谢谢。

Why is that? Why is it giving me a value for pitch if I never changed that? How can be pitch influenced by a rotation in other angles? thanks.

推荐答案

鉴于您可以使用增量移动,您可以使用四元数差异操作。假设你有一个先前的旋转作为四元数称为q1和当前的q2。然后,您可以计算它们之间的delta dQ,以便q2 = q1 * dQ有效。所有你需要做的是构建q1的逆(q1 ^( - 1)),然后得到:

Given the case that you can live with delta movements, you can use "quaternion difference" operation. Let's say you have a previous rotation as quaternion called q1 and the current one q2. Then you can calculate the delta dQ between them so that q2 = q1*dQ is valid. All you have to do is build the inverse of q1 (q1^(-1)) and then you get:

dQ = q1 ^( - 1)* q2

dQ = q1^(-1) * q2

如果deviceMotionInterval足够高,你总是有一个方便的小欧拉角,没有任何90°奇点或其他令人讨厌的东西。由于错误传播和虚拟空间缺乏反馈,此解决方案的可能缺点可能是轻微漂移。示例:如果您将iPhone放在显示立方体的工作台上然后进行一系列旋转,则当您将手机放回到起始位置时,您可能会发现立方体的角位移。

If deviceMotionInterval is high enough, you always have handy small Euler angles without any 90° singularities or other beasty stuff. The possible drawback of this solution might be a slight drift because of error propagation and the lack of feedback from your virtual space. Example: if you have your iPhone on a table showing a cube and then do a sequence of rotations, you might find a angular displacment of the cube when you put the phone back in starting position.

为了摆脱漂移效果,你只需要一种方法来表达你的最后一个物体的真实位置(q1)作为四元数,即屏幕上显示的应用中的坐标。如果您使用像Unity这样的工具,它可能只是读取对象的相应属性。如果您无法轻松访问它,您可以手动跟踪此位置。

To get rid of the drifting effect, you "only" need a way to express your last object's real position (q1) as a quaternion i.e. coordinates in your app as displayed on the screen. If you use tools like Unity it might be just reading the appropriate property of an the object. If you don't have easy access to it, you may have the possibility to track this position manually.

如果您想了解更多相关信息,请查看< a href =http://books.google.de/books?id=wCfWkc_E3GkC&printsec=frontcover&dq=fletcher+dunn+3d+math+primer&hl=de&ei=bKBuTeu8N4nFswaRwLj9Dg&sa=X&oi= book_result& ct = result& resnum = 1& ved = 0CDwQ6AEwAA #v = onepage& q& f = falserel =noreferrer>用于图形和游戏开发的3D数学入门,作者:Fletcher Dunn,Ian Parberry 页面168。

If you want to read more about this take a look at 3D math primer for graphics and game development, by Fletcher Dunn,Ian Parberry page 168.

这篇关于iPhone - 了解iPhone旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆