0

IOS でコアモーションを使用して、ipad とピッチロールレイヤーの間の角度を計算しましたが、ヨー、ピッチ、およびロール値から ipad-layer とピッチロールレイヤーの間の角度を計算する方法がわかりませんでした。下の画像では、α-角度を計算したいと思います。私を助けてください!どうも

この下の計算は正しいですか?

α = 90 - atan2(sqrt(pow(acceleration.x,2)+pow(acceleration.y,2)),acceleration.z)

http://imageshack.us/photo/my-images/443/bild1nwcmm.png/

PS: 赤い線は私の ipad-layer です

4

1 に答える 1

0

タスクについては明確ではありません。CoreMotion から現在のデバイスの姿勢 (CMMotionManager.deviceMotion.attitude) を取得し、それを基準点 (ゼロ) として使用して、ロール、ピッチ、およびヨーのデルタ角度を取得できます (CMAttitudemultiplyByInverseOfAttitude:)。

@interface OrientationTracker : NSObject {
    CMMotionManager* motionManger;
    CMAttitude* referenceAttitude;
}

- (void)markZeroReference
{
    CMDeviceMotion* deviceMotion = self.motionManager.deviceMotion;
    self.referenceAttitude = [deviceMotion.attitude];
}

- (CMAttitude*)currentOrientation {
    return [self.motionManager.deviceMotion.attitude multiplyByInverseOfAttitude:self.referenceAttitude];
}
于 2012-01-02T10:38:20.663 に答える