我正在测试 Core Motion 并使用陀螺仪。现在我得到了我不理解的价值观。我的假设是,对于每个 x、y 和 z,我会得到一个介于 0-360 之间的值,这将是一个完整的旋转,但事实并非如此。
[self.motionManager startGyroUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMGyroData *gyroData, NSError *error) {
NSString *x = [NSString stringWithFormat:@"%.02f",gyroData.rotationRate.x];
NSLog(@"X: %@", x);
NSString *y = [NSString stringWithFormat:@"%.02f",gyroData.rotationRate.y];
NSLog(@"Y: %@", y);
NSString *z = [NSString stringWithFormat:@"%.02f",gyroData.rotationRate.z];
NSLog(@"Z: %@", z);
frequency = gyroData.rotationRate.y*500;
float rate = gyroData.rotationRate.z;
if (fabs(rate) > .2) {
float direction = rate > 0 ? 1 : -1;
rotation += (direction * M_PI/90.0)*1000;
NSLog(@"Rotation: %f", rotation);
}
}];
是否可以获得更多人类可读的旋转值?我的假设是我应该得到 0-360 之间的值是错误的吗?