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 の値を取得する必要があるという私の仮定は間違っていますか?