ios – 如何使用deviceMotion姿态值(滚动,俯仰和偏航)来检测运动

ios – 如何使用deviceMotion姿态值(滚动,俯仰和偏航)来检测运动,第1张

概述我在我的应用程序中使用coreMotion来检测iOS设备的动作.我知道如何从coreMotion获取不同的传感器数据.我从deviceMotion获得如下滚动,俯仰和偏航数据: float pitch = (180/M_PI)*self.manager.deviceMotion.attitude.pitch]; float roll = (180/M_PI)*self.manager.dev 我在我的应用程序中使用coreMotion来检测iOS设备的动作.我知道如何从coreMotion获取不同的传感器数据.我从deviceMotion获得如下滚动,俯仰和偏航数据:

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姿态值(滚动,俯仰和偏航)来检测运动所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1075801.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存