Created
July 26, 2011 19:56
-
-
Save jeksys/1107826 to your computer and use it in GitHub Desktop.
Accelerometer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration{ | |
static float prevX=0, prevY=0; | |
float accelX = acceleration.x * kFilterFactor + (1- kFilterFactor)*prevX; | |
float accelY = acceleration.y * kFilterFactor + (1- kFilterFactor)*prevY; | |
prevX = accelX; | |
prevY = accelY; | |
pitch = accelX; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment