iPhone - 偏航、俯仰和滚动的核心运动范围

发布于 2024-10-17 18:25:56 字数 209 浏览 5 评论 0原文

我现在没有 iPhone 4,我正在尝试找到一个文档来显示偏航、俯仰和滚动的范围以及设备的相应位置。

我知道加速度计的变化范围是 -1 到 +1,但昨天在我的 iPhone 上进行的测试显示,横滚的变化范围是 -M_PI 到 +M_PI,但偏航和俯仰范围是其中的一半。这是正确的吗?

在哪里可以找到有关这些范围的文档?我在苹果模糊文档中没有看到它。

谢谢。

I don't have an iPhone 4 with me right now and I am trying to find a documentation that shows the ranges of yaw, pitch and roll and the correspondent positions of the device.

I know that the accelerometer varies from -1 to +1 but on my tests yesterday on my iPhone, showed me that the roll varies from -M_PI to +M_PI, but yaw and pitch ranges are half of that. Is this correct?

Where do I find documentation about these ranges? I don't see it on Apple vague docs.

Thanks.

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

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

发布评论

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

评论(2

逆蝶 2024-10-24 18:25:56

这不是一个完整的答案,但为了开始滚动:

我假设您正在谈论设备态度而不是原始陀螺仪数据。

有趣的是(我面前有一台 ipod touch 4 gen,显示这些值):

音调:看起来是 -(M_PI/2) -> 的范围。 +(M_PI/2) 尽管我的上限为 ~ +1.55 / -1.51

滚动:-M_PI -> +M_PI

偏航:-M_PI-> +M_PI

只是注意一下,至少在我的设备上,俯仰并不能区分倾斜“向前”与“向后”,只是给出设备相对于重力方向的角度。要确定屏幕是朝下还是朝上,您当然可以检查gravity.z。

如果您使用 CMDeviceMotion,它有一个名为“重力”的属性,只需获取“gravity.z”即可。如果设备的显示屏向上倾斜(远离重力),则该值为负;如果显示屏朝下(朝向重力),则该值为正。

请注意,CMDeviceMotion 使用的算法非常擅长将重力与用户加速度分开,但在某些类型的运动下在值变得正确之前可能会有一些滞后,我很乐意从有更好解决方案的人那里得到。

This is not a full answer, but in the interest of starting the ball rolling:

I'm assuming you are talking about the device attitude rather than the raw gyro data.

Anecdotally (I have an ipod touch 4 gen sitting in front of me displaying these values):

pitch: looks to be a range of -(M_PI/2) -> +(M_PI/2) although mine caps at ~ +1.55 / -1.51

roll: -M_PI -> +M_PI

yaw: -M_PI -> +M_PI

Just a note, at least on my device pitch doesn't differentiate tilt "forward" vs "backward", just gives the angle of the device relative to the direction of gravity. To figure out if the screen is pointed down or up, you can of course check gravity.z.

If you're using CMDeviceMotion there is a property called gravity on it, just grab gravity.z. It will be negative if the device's display is tilting upward (away from gravity) and positive if the display is facing down (toward gravity)

Note that the algorithms used by CMDeviceMotion are pretty good at separating gravity from user acceleration but under certain kinds of motion there may be some lag before the values become correct, I would love to here from someone with a better solution.

绅士风度i 2024-10-24 18:25:56

我最近在一个统计手机翻转次数的 iOS 应用程序中遇到了同样的问题。 Apple 已拒绝它,因此我将其发布在 GitHub 上,可能对您有用:

Flip Your Phone! - https://github.com/apascual/flip-your-phone

我从来没有想过使用重力 Z 变量的解决方案,我很快就会尝试我回来时会带来一些更新。

I have recently faced the same problem for an iOS app that counts the number of flips that the phone does. Apple has rejected it so I have published it on GitHub, may be useful for you:

Flip Your Phone! - https://github.com/apascual/flip-your-phone

I never thought on the solution using the gravity Z variable, I will try it soon and I come back with some updates.

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