I want to enable a virtual horizon for my application using a gyroscope like this
I found a lot of documentation on the gyroscope, and I think I use digging, but I donβt know how to calibrate using gravity.
Can someone help me?
thanks.
I solved the problem with this:
- (void)updateImage: (NSNumber *)rotNum { self.image.transform = CGAffineTransformMakeRotation([rotNum floatValue]); } // call the above function to rotate the image in reference to the horizon [motionManager startDeviceMotionUpdatesToQueue: gyroQueue withHandler: ^(CMDeviceMotion *motion, NSError *error) { [self performSelectorOnMainThread: @selector(updateImage:) withObject: [NSNumber numberWithDouble: atan2(motion.gravity.x, motion.gravity.y)-M_PI] waitUntilDone: NO]; }];
Source: https://habr.com/ru/post/915028/More articles:Was the PDO instruction used correctly? - phpget all html as string from HTMLDocument - javaHow to provide height with Delphi - ms-accessStyling a GWT Button with CSS - gwtDelete absolute position generated by GWT - cssCalibration code for iphone accelerometer and gyroscope - objective-cJade layout cannot be found in subdirectory - node.jsHow to get visible window sizes JScrollPane - javaAmazon C # Product Advertising API - c #Incomplete data processing (sparse data) in kNN - algorithmAll Articles