使用 UIAccleration 获取旋转级别
iPhone 版 FroggyJump 等游戏可以计算 iPhone 的旋转。我对加速度值感到困惑。如何计算旋转级别?我想我需要考虑 iPhone 何时不完全直立。
谢谢。
我还想将新的 Core Motion 框架与 iPhone 4 的“Device Motion”结合使用,以获得更高的精度。我想我必须对其他设备使用低通滤波器。
这是偏航。
Games like FroggyJump for iPhone figure out the rotation of the iphone. I'm getting confused with the acceleration values. How do I calculate the level of rotation? I suppose I need to consider when the iphone isn't perfectly upright.
Thank you.
I'm also wanting to use the new Core Motion framework with the "Device Motion" for iPhone 4 for extra precision. I guess I'll have to use that low pass filter for the other devices.
It's the yaw.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
快速体验了“Froggy Jump”之后,我认为它很可能直接使用加速度计的 x 值作为青蛙的左/右加速度。如果它是静止的,您可以将加速度计视为给您相对于局部轴向上指向空间的矢量。对于像球滚动或其他因倾斜而加速的物体,您需要直接使用这些值。
对于任何涉及实际了解角度的事情,您可能最好选择要检测旋转的轴,然后对其他两个轴的加速度计值使用 C 函数 atan2f。仅使用加速度计,在某些情况下您无法检测旋转 - 例如,如果设备平放在桌子上,则加速度计无法检测偏航。一般规则是仅用加速度计无法检测到围绕重力矢量的旋转。
Having given Froggy Jump a quick go, I think it's likely directly using the accelerometer's x value as the left/right acceleration on the frog. If it is stationary, you can think of an accelerometer as giving you the vector that points upward into space, relative to the local axes. For something like a ball rolling or anything else accelerating due to tilt, you want to use the values directly.
For anything that involves actually knowing angles, you're probably best picking the axis around which you want to detect rotation then using the C function atan2f on the accelerometer values for the other two axes. With just an accelerometer, there are some scenarios in which you can't detect rotation — for example, if the device is flat on a table then an accelerometer can't detect yaw. The general rule is that rotations around the gravity vector can't be detected with an accelerometer alone.