このようなジャイロスコープを使用して、アプリに仮想地平線を含めることを検討しています
ジャイロに関する多くのドキュメントを見つけました。ヨーを使用していると思いますが、重力で調整する方法がわかりません。
誰か助けてくれませんか??
ありがとう。
私はこれで私の問題を解決しました:
- (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];
}];