Using CMDeviceMotion, you can get a CMAttitude object using “roll, pitch and yaw” - where, for example, if the phone is in portrait mode, “yaw” is “azimuth”, “step” is tilting the phone using respect for the earth or zenith, and the "roll" is a vector that indicates through the screen, and not what interests you.
Everything becomes a little more complicated, because the "azimuth" is the projection of a three-dimensional magnetic vector (directed towards the magnetic north pole) onto a flat "earth" plane, which changes depending on the orientation of the device, but with this understanding in mind, terms such as this should be much clearer. If you only need your application to work in one orientation, everything becomes much easier.
PS "altitude" is almost exclusively used to indicate altitude or altitude relative to this reference (sea level, geodetic altitude, etc.). “Zenith” or “step” is preferable, and since you are on iOS, you must adhere to their coordinate scheme: (lat, lon, alt), (pitch, yaw, roll).
source share