Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1003271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:57:18+00:00 2026-05-16T07:57:18+00:00

I’m working on an app that needs to detect a rotation gesture from the

  • 0

I’m working on an app that needs to detect a rotation gesture from the iPhone. I have written code that polls CMMotionManager for rotation data, but for some reason these values are constantly changing even though the phone is stationary on the table. I’m not sure what I am doing wrong here. I have consulted the Apple docs and it seems like I am doing what they suggest, and the thing does run without crashing, but the numbers that come out make no sense. Here is what I am doing:

    -(void)startDetectingMotion {

 if (!motionQueue){
  motionQueue = [[NSOperationQueue mainQueue] retain];
 }

 if (motionManager.isDeviceMotionAvailable) {

  CMDeviceMotionHandler motionHandler = ^ (CMDeviceMotion *motion, NSError *error) {
  [self processMotion:motion withError:error];
 };


 [motionManager startDeviceMotionUpdatesToQueue:motionQueue withHandler:motionHandler];

 }
 else {
  NSLog(@"motion not available");
 }

}

…..

-(void)processMotion:(CMDeviceMotion *)motion withError:(NSError *)error {

 CMRotationRate rotation = motion.rotationRate;
 if(rotation.y > 2 || rotation.y < -2) {
  NSLog(@"CM Motion X rotation:%f, Y rotation:%f, Z Rotation:%f", rotation.x, rotation.y, rotation.y);
  ....

  [self stopDetectingMotion];

 }
}

The point of trapping for y > 2 or < 2 is to look for rapid rotation of the iphone on a horizontal plane, which is what I am looking for.

The output looks like this:

2010-08-15 16:15:43.475 PokerFoldTest[539:307] CM Motion X rotation:11.415660, Y rotation:7.865920, Z Rotation:7.865920

2010-08-15 16:04:33.843 PokerFoldTest[539:307] CM Motion X rotation:8.925084, Y rotation:8.414384, Z Rotation:8.414384

2010-08-15 16:11:14.314 PokerFoldTest[539:307] CM Motion X rotation:10.245130, Y rotation:-8.243847, Z Rotation:-8.243847

2010-08-15 16:11:16.136 PokerFoldTest[539:307] CM Motion X rotation:10.212860, Y rotation:-4.303616, Z Rotation:-4.303616

2010-08-15 16:11:18.242 PokerFoldTest[539:307] CM Motion X rotation:9.988654, Y rotation:-7.074587, Z Rotation:-7.074587

2010-08-15 16:11:19.678 PokerFoldTest[539:307] CM Motion X rotation:16.092894, Y rotation:-10.562743, Z Rotation:-10.562743

2010-08-15 16:15:41.662 PokerFoldTest[539:307] CM Motion X rotation:12.854285, Y rotation:7.247667, Z Rotation:7.247667

As these numbers are supposed to be radians/sec rotation, they are suggesting that when the phone is stationary on the table it is spinning wildly. What the hell? Any chance my phone has a bad gyro?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:57:19+00:00Added an answer on May 16, 2026 at 7:57 am
    • Check that motion is not nil (and that error is nil). You get garbage data if you call struct-returning method on nil.
    • You’re only printing the extreme values (it looks like you get one of these every few seconds, whereas the update rate should be much higher). If you print all the updates, you might have a better idea of what’s going on.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.