UI加速过滤
我在苹果指南中找到了以下代码:
- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
//Use a basic low-pass filter to only keep the gravity in the accelerometer values
accel[0] = acceleration.x * kFilteringFactor + accel[0] * (1.0 - kFilteringFactor);
accel[1] = acceleration.y * kFilteringFactor + accel[1] * (1.0 - kFilteringFactor);
accel[2] = acceleration.z * kFilteringFactor + accel[2] * (1.0 - kFilteringFactor);
}
它到底是做什么的? 这个低通滤波器是什么? 为什么我必须应用它?
先感谢您。
I found the following piece of code in apple guidelines:
- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
//Use a basic low-pass filter to only keep the gravity in the accelerometer values
accel[0] = acceleration.x * kFilteringFactor + accel[0] * (1.0 - kFilteringFactor);
accel[1] = acceleration.y * kFilteringFactor + accel[1] * (1.0 - kFilteringFactor);
accel[2] = acceleration.z * kFilteringFactor + accel[2] * (1.0 - kFilteringFactor);
}
What does it exactly do? What is this low-pass filter?
Why do I have to apply it?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要做什么取决于您需要该值的目的,但基本思想是减少手部动作等振动的影响。 如果您采用原始加速度值并将它们视为重力矢量,您会得到很多抖动。
What you need to do depends on what you need the value for, but the basic idea is to reduce the effect of vibrations from hand movements and such. If you take the raw acceleration values and treat them as a gravity vector, you’ll get a lot of jitter.