UIAcceleration filtering

Posted by Ilya on Stack Overflow See other posts from Stack Overflow or by Ilya
Published on 2009-07-31T09:34:54Z Indexed on 2010/05/11 3:44 UTC
Read the original article Hit count: 199

Hi,

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.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa-touch