有没有关于如何在 iPhone OS 中使用加速度计的好例子?

发布于 2024-07-18 16:44:24 字数 54 浏览 4 评论 0 原文

我认为地球重力存在一些问题,所以我想知道是否有任何例子可以说明加速度计通过减去这些问题来工作。

I think that there are some issues with the earth Gravity, so I wonder if there are any examples where the accelerometers work by subtracting these.

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

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

发布评论

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

评论(2

左耳近心 2024-07-25 16:44:24

(太糟糕了,您无法向地球提交错误来解决其重力问题!)

UIAcceleration 类参考

正如该文档所述,值 1.0 大约代表 +1g。 因此,如果您将 iPhone 以纵向方向笔直向上,您应该会大致看到 <0, -1, 0>。 当您旋转手机时,加速度矢量 sqrt(x*x+y*y+z*z) 的大小应保持在 1 左右。

(It's too bad you can't file a bug with planet Earth to fix its Gravity issue!)

There are several examples listed under "Related sample code" in the UIAcceleration Class Reference.

As that doc states, a value of 1.0 represents roughly +1g. So if you point the iPhone straight up in portrait orientation, you should see roughly <0, -1, 0>. As you rotate the phone around, the magnitude of the acceleration vector sqrt(x*x+y*y+z*z) should stay around 1.

梓梦 2024-07-25 16:44:24

Apple 的 AccelerometerGraph 演示包含实现高通滤波器的示例代码 - 有效地滤除重力的影响。 获取它并进行修改以满足您的需求非常简单。

Apple's AccelerometerGraph demo includes sample code that implements a high-pass filter-- effectively filtering out the effect of gravity. It's pretty simple to just grab it and modify to suit your needs.

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