Created
June 20, 2013 04:39
-
-
Save olenhad/5820344 to your computer and use it in GitHub Desktop.
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
/* | |
If a device has both an accelerometer and a gyroscope, Core Motion offers a device-motion service that processes raw motion data from both sensors. Device motion uses sensor fusion algorithms to refine the raw data and generate information for a device’s attitude, its unbiased rotation rate, the direction of gravity on a device, and the user-generated acceleration. An instance of the CMDeviceMotion class encapsulates all of this data. Additionally, you do not need to filter the acceleration data because device-motion separates gravity and user acceleration.[1] | |
[1] http://developer.apple.com/library/ios/#documentation/CoreMotion/Reference/CMDeviceMotion_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40009942 | |
*/ | |
[_manager startDeviceMotionUpdates]; | |
/* | |
the following is in a timer callback: | |
*/ | |
CMAcceleration deviceMotion = [[_manager deviceMotion] userAcceleration]; | |
double magnitude = sqrt( pow(deviceMotion.x,2) + pow(deviceMotion.y, 2) + pow(deviceMotion.z,2)); | |
if (magnitude < USER_ACCE_THRESHOLD) | |
// handle as we want | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment