加速度计检测左右运动

发布于 2024-08-18 14:00:31 字数 133 浏览 3 评论 0原文

有人可以给我一个例子来说明如何检测 iPhone 是否向左移动或向右移动。就像摇晃的长版本一样,我希望我的应用程序能够知道用户的手臂是向右还是向左。想象一下你的手像雨刷器一样,末端有手机,

有什么想法吗?

谢谢,山姆:P

can someone please give me an example of how you detect if the iphone is moving left or moving right. like a long version of a shake i want my app to be able to know if the users arm is going right or left. imagine your hand like a window wiper with the phone at the end

any ideas?

Thanks, Sam :P

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

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

发布评论

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

评论(1

转身以后 2024-08-25 14:00:31

这就是 Acceleration.x 值。想象一下 3 条线穿过你的 iPhone:
1) 一条垂直于 iPhone 屏幕并穿过它的线,即 Z。
2)一条与屏幕平行的水平线,即X(您正在寻找的)。
3) 一条与屏幕垂直且平行的线,即 Y。

因此,向左或向右移动 iPhone 将会在 X 图中产生变化。向上或向下移动 iPhone 将会在 Y 图中产生变化。向前或向后移动 iPhone 将会在 Z 图中产生变化。

希望这可以帮助您掌握加速度计的概念,
〜纳塔纳夫拉。

That would be the acceleration.x value. Imagine 3 lines going through your iPhone:
1) a line perpendicular to your iPhone screen and going through it, that would be Z.
2) a horizontal and parallel line to your screen, that would be X (what you're looking for).
3) a vertical and parallel line to your screen, that would be Y.

So, moving the iPhone left or right will generate changes in the X graph. Moving the iPhone up or down will generate changes in the Y graph. Moving your iPhone forward or backward will generate changes in the Z graph.

Hope this helps you grasp the accelerometer's concept,
~ Natanavra.

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