float pitch = (180/M_PI)*self.manager.deviceMotion.attitude.pitch]; float roll = (180/M_PI)*self.manager.deviceMotion.attitude.roll]; float yaw = (180/M_PI)*self.manager.deviceMotion.attitude.yaw];
如何使用这些数据来检测运动?我需要为此做些什么计算?
@R_404_6120@ 态度值需要启动设备运动更新:startDevicemotionUpdates
要在设备移动时监控姿态值,请使用在标签中显示的姿态值:
[self.cmmotionmanager startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMDeviceMotion *devMotion,NSError *error) {float pitch = (180/M_PI)*self.manager.devMotion.attitude.pitch];float roll = (180/M_PI)*self.manager.devMotion.attitude.roll];float yaw = (180/M_PI)*self.manager.devMotion.attitude.yaw];self.rollLabel.text = [Nsstring stringWithFormat:@"%f",roll];self.pitchLabel.text = [Nsstring stringWithFormat:@"%f",pitch];self.yawLabel.text = [Nsstring stringWithFormat:@"%f",yaw];}
最好不要使用滚动,俯仰和偏航(也称为欧拉角).使用四元数或旋转矩阵可获得更高的精度.欧拉角倾向于处于称为万向节锁定的情况,这导致不可靠的数据.
请检查此链接以了解如何使用四元数,并将该值转换为滚动,俯仰和偏航值:SO link
总结以上是内存溢出为你收集整理的ios – 如何使用deviceMotion姿态值(滚动,俯仰和偏航)来检测运动全部内容,希望文章能够帮你解决ios – 如何使用deviceMotion姿态值(滚动,俯仰和偏航)来检测运动所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)