Abhigyan
Abhigyan

Reputation: 651

Finding out the change on the [x,y] plane using core motion and gyroscope

When I tilt the iphone on the xy plane how we can get how much it has been tilted? IPhone is being held as vertical upright position

vertical up right position

Upvotes: 1

Views: 306

Answers (1)

user755278
user755278

Reputation: 1634

CMMotionManager

CMMotionManager works with NSOperationQuee. CMMotionManager provides the startAccelerometerUpadatesToQueue:withHandler method to start Core Motion data collecting. And this method uses a threaded context by implementing an NSOperationQueue and an execution block that confomrs to the CMAccelerometerHandler format.

Core Motion data is always provided as radians. If you want degrees you will need to convert the data using the following formulas:

CGFloat DegreesToRadians(CGFloat degrees) { return degrees * M_PI / 180; };

CGFloat RadiansToDegrees(CGFloat radians) { return radians * 180 / M_PI; };

Upvotes: 2

Related Questions