Skip to content

Instantly share code, notes, and snippets.

@zapsleep
Created July 29, 2013 12:07
Show Gist options
  • Save zapsleep/6103881 to your computer and use it in GitHub Desktop.
Save zapsleep/6103881 to your computer and use it in GitHub Desktop.
Transition of gyroscope data to contentOffset CGPoint
#pragma mark - Gyroscope to offset
- (CGPoint)contentOffsetWithRotationRate:(CMRotationRate)rotationRate {
double xOffset = (fabs(rotationRate.y) > DV_ROTATION_THRESHOLD)?rotationRate.y*DV_ROTATION_MULTIPLIER:0.f;
double yOffset = (fabs(rotationRate.x) > DV_ROTATION_THRESHOLD)?rotationRate.x*DV_ROTATION_MULTIPLIER:0.f;
CGPoint newOffset = CGPointMake(self.contentOffset.x + xOffset,
self.contentOffset.y + yOffset);
return newOffset;
}
- (void)displayLinkHandler {
[self setContentOffset:[self contentOffsetWithRotationRate:self.motionManager.deviceMotion.rotationRate]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment