문제

코어 동작에서 상대적인 회전을 얻는 방법이 있습니까?

내가 필요한 것은 다음과 같습니다 : 하나의 축에서 회전하고 방향 (+ 표지= 반 시계 반대 방향, - 시계 방향으로, - 시계 방향으로, 시계 방향, 시계 방향, - 시계 방향, 오른쪽 규칙에 따라).

나는 재산을 회전시키는 것을 발견했지만, 나는 이것이 나를 초당 라디안을주는 것처럼 내가 그것에서 어떻게 밖으로 추출하는지 확신합니다.

나는 마지막 날에 모든 종류의 물건을 행했지만 아무것도 안정된 가치를주는 것은 아무것도 제공하지 않습니다.NStimer를 사용하여 코어 모션 데이터의 시간 샘플을 수행하고 두 샘플 간의 차이를 계산하여 마지막 샘플 이후 얼마나 회전했을 것입니다. 그러나 때까지는 13600도와 같은 미친 숫자를 제공합니다.iPhone이 테이블에서 쉬고있을 때도

이것이 어떻게 수행 될 수 있는지에 대한 생각은 무엇입니까?

감사합니다

도움이 되었습니까?

해결책

There is indeed. You can get what you're looking for by drilling down into the properties of CMMotionManager, through CMDeviceMotion and finally to CMAttitude. The attitude of the device is defined as:

the orientation of a body relative to a given frame of reference.

In the case of DeviceMotion's CMAttitude, that frame of reference is established by the framework when starting device motion updates. From that point in time on, the attitude of the device is reported relative to that reference frame (not relative to the previous frame).

The CMAttitude class provides some handy built in functionality to convert a CMAttitude to a form that is actually useful for something, like Euler Angles, a rotation matrix, or a quaternion. You sound like you're looking for the Euler Angle representation (Pitch, Yaw, Roll).

다른 팁

The answer provided above isn't quite accurate, though it's probably sufficient to answer this question. Core Motion tries to determine the device's absolute attitude at all times, meaning that the definition of the axes can vary depending on the device's orientation. For example, if the device is face-up, then pitch up/down is a rotation about the y-axis, but if the device is in landscape orientation, then pitch is a rotation about the z-axis (perpendicular to the plane of the screen). This is somewhat helpful if your application will only be used in one orientation, or you want a delta like the question asked for, but makes it excessively complicated if you want to know absolute orientation.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top