5

在 iOS5 中,Compass 原始数据读取的更新频率CLHeading急剧下降。这使得我的增强现实应用程序无法使用,因为它依赖于对原始指南针数据的接近实时读取。

因此,我现在正尝试切换到 CoreMotion。这提供了更频繁更新的磁力计数据:

cmManager = [[CMMotionManager alloc] init];    
[cmManager startMagnetometerUpdates];

magneticField然后我可以在游戏期间随时访问数据:

CMMagneticField magneticField = cmManager.magnetometerData.magneticField;

我遇到的问题如下: 中的数据与x/y/z 数据CMMagneticField的单位不同。CLHeading

我想将CMMagneticFieldx/y/z 数据转换为与 CLHeading / CLHeadingComponentValue 相同的单位——以便能够使用我现有的 AR 代码。

这里有一些读数:

7.3     /  17.64 /  -39.58          CLHeadingComponentValue X/Y/Z
-103.12 /  88.51 /  -20.05          CMMagneticField 

-10.81  /  -34.9 /  -18.6          CLHeadingComponentValue X/Y/Z
-121.00 /   33.29 /  3.1           CMMagneticField    

-20.8  /  -38.0 /   -4.0          CLHeadingComponentValue X/Y/Z
-132.9 /   32.2 /  14.4           CMMagneticField
4

1 回答 1

0

与此相关的文档中唯一的参考是报告的 CLHeadingComponentValue 被标准化为 -128 到 +128 的范围。但对我来说,似乎应用了其他类型的校准。

于 2012-02-07T11:48:49.473 回答