首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CMAttitudeReferenceFrameXTrueNorthZVertical不指向北方

CMAttitudeReferenceFrameXTrueNorthZVertical不指向北方
EN

Stack Overflow用户
提问于 2016-03-10 22:50:09
回答 1查看 241关注 0票数 2

我使用这个代码来定义设备的位置。侧滚和俯仰值看起来很好(当设备放在桌面上时,它们是0 ),但当偏航为0时,指南针指向西方。怎么了?

代码语言:javascript
复制
        [self.motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXTrueNorthZVertical toQueue:[NSOperationQueue currentQueue]
                                                   withHandler: ^(CMDeviceMotion *motion, NSError *error){
                                                       [self performSelectorOnMainThread:@selector(handleDeviceMotion:) withObject:motion waitUntilDone:YES];
                                                   }];
    }
}

- (void)handleDeviceMotion:(CMDeviceMotion*)motion {
   CMAttitude *attitude = motion.attitude;
   double yaw = attitude.yaw * 180 / M_PI;
   double pitch = attitude.pitch * 180 / M_PI;
   double roll = attitude.roll * 180 / M_PI;
   self.xLabel.text = [NSString stringWithFormat:@"%7.4f", yaw];
   self.yLabel.text = [NSString stringWithFormat:@"%7.4f", pitch];
   self.zLabel.text = [NSString stringWithFormat:@"%7.4f", roll];
   [self sendDeviceAttitudeLogWithYaw:yaw pitch:pitch roll:roll];
}
EN

回答 1

Stack Overflow用户

发布于 2016-03-10 23:30:18

当偏航为0时,手机必须指向北,不是吗?

你说的“电话”是什么意思?问题是,手机的哪一部分。让我们来读一下文档:

CMAttitudeReferenceFrameXTrueNorthZVertical

描述Z轴垂直且X轴指向正北的参考系。

X轴位于设备的右侧。因此,当设备的右侧为北时,您应该预期偏航为0。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35919772

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档