This might be hard to explain the geometry so I will be careful in spelling it out. This is visible in the standard compas app and fr开发者_如何学Com the data in CLLocationManager.
1) When holding the phone in portrait orientation, consider the pitch angle to be 0°
2) When pointing the camera up into the sky (such as taking a picture of a cloud) the pitch angle goes from 0° -> 90° where 90 degrees is straight up.
3) when the phone is tilted upward (> 0 degrees and rotating on the "X" magnetometer axis) and when the phone is at about (but not exactly) 45 degrees, the compass heading rotates 180 degrees. So while the camera is still point "N", the compass will report "S".
4) for the next (roughly) 90 degrees, the compass heading is rotated 180 degrees.
This rotation of the heading is destructive for me and it does not align perfectly with the accelerometers. Is there a good tutorial (I did not find one off the bat) on using the the RAW data (X, Y, Z) from the CLHeading data to calculate heading data?
The end result is I want the heading of the compass to always match the heading of the camera.
You can't rely on solely the compass heading. See this answer for what you're looking for, and in particular the CMAttitude object's yaw property to compensate for the pitch angle you're talking about: Compensating compass lag with the gyroscope on iPhone 4
精彩评论