2010-06-08 4 views

답변

2

나는 아이폰의 가속도계에 대해 this post가 샘플 코드를 포함한 대부분의 질문에 대답 할 것이라고 생각한다. 그래서 솔루션에 대한 정말 자세한 게시물을 여기 읽을 수 있기 때문에

+0

오을 pitch = acceleration.x, roll = acceleration.y. 그리고 acceleration.z 구성 요소는 장치가 거꾸로 된 것인지를 알려줍니다. 이 사람은 어떻게 든 "360도 자유 카메라"를 만드는 데 도움이 될 것입니다. 고마워. – Geri

0

gotoandplay.freeblog.hu에서 당신은 라디안을 계산하는 CMMotionManager 통해 장치 회전에 액세스 할 수 있습니다 원시 데이터 (가속도계, 자이로 등)를 기반으로합니다. 당신이 센서 업데이트를 사용하십시오 :


if (motionMng.deviceMotionAvailable && !motionMng.deviceMotionActive) { 
    motionMng.deviceMotionUpdateInterval = 1.0/50.0; 
    [motionMng startDeviceMotionUpdates]; 
} 

이후 회전 Access (액세스) - attitude 개체를 쿼리하여 - pitch (x)를, roll (Y)와 yaw (Z) : 그래서 간단하게,


CMDeviceMotion *motion = [motionMng deviceMotion]; 

if (motion != NULL) { 

    float pitch = motion.attitude.pitch; 
    float roll = motion.attitude.roll; 
    float yaw = motion.attitude.yaw; 

    NSLog(@"ROTATION: x:%f y:%f z:%f", pitch, roll, yaw); 
}