【问题标题】:IOS - angle between ipad and pitch-roll-layerIOS - ipad和pitch-roll-layer之间的角度
【发布时间】:2012-01-02 09:21:07
【问题描述】:

我在 IOS 中使用 core motion 来计算 ipad 和 pitch-roll-layer 之间的角度,但我不知道如何从 yaw-、pitch-和 roll 计算 ipad-layer 和 pitch-roll-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

【问题讨论】:

    标签: ios ipad angle pitch


    【解决方案1】:

    不清楚任务。您可以从 CoreMotion 获得当前的设备姿态 (CMMotionManager.deviceMotion.attitude),然后将其用作参考点(零),以便获得滚动、俯仰和偏航的增量角度 (CMAttitude multiplyByInverseOfAttitude:)。

    @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];
    }
    

    【讨论】:

    猜你喜欢
    • 2013-12-25
    • 1970-01-01
    • 2013-06-02
    • 2019-06-19
    • 1970-01-01
    • 1970-01-01
    • 2021-05-10
    • 1970-01-01
    • 2016-09-27
    相关资源
    最近更新 更多