UIAcceleration filtering

此生再无相见时 提交于 2019-12-22 01:20:50

问题


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.


回答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.



来源:https://stackoverflow.com/questions/1211589/uiacceleration-filtering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!