Search code examples
objective-ciosaccelerometeraugmented-realitygyroscope

How should I calculate 3 axis of "world coordinates" from device motion?


I am having trouble converting the device motion data into world coordinates.

I have been looking into rotation/projection matrixes and quaternion but CMAttitude (roll, pitch, yaw) is where is have had most success using gravity.y & gravity.z to find the device orientation around the same axis as pitch.

The end result i am looking for is a augmented/virtual reality feel as the user looks for 2D game objects around a center point.


Solution

  • I wouldn't use Euler angles (roll, pitch, yaw). It pretty much screws up the stability of your app, see here why: Strange behavior with android orientation sensor.

    I would use rotation matrices. These tell you how to go from device coordinates to world coordinates and the other way around. You might find these useful: