Smoothing Accelerometer Data
Each time the accelerometer sends an update, the center of the view changes to reflect the orientation of the device. However, because the accelerometer’s updateInterval is constant and the device’s movement is variable, the center of the view jumps around instead of moving in calm, peaceful, smooth manner. To get smooth movement, you need “smoothed” data. To smooth accelerometer data, you apply a low-pass filter.
In HypnosisViewController.m, add the following lines of code to filter the accelerometer data:
- (void)accelerometer:(UIAccelerometer *)meter didAccelerate:(UIAcceleration *)accel { HypnosisView ...
Get iOS Programming: The Big Nerd Ranch Guide, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.