OK I don't think this question has been asked and its time either I get an answer quicker or I will add the answer once I have it as I must be close.
Let me explain:
Considering iOS device pitch and roll (forget yaw) we have the angles being as this
* r+
* ------------
* | |
* p- ° |p+
* | |
* ------------
* r-
So based on the body reference frame.
We know that when either pitch or roll is 0 the other is the max inclination of the device. But when the device has inclination in both roll and pitch then we need to go Quaternion and the following answer will get us the screen normal. https://stackoverflow.com/a/10836923/2332101
The normal vector with the vertical reference vector will give us the max inclination.
Therefore, to get the normal vector projected on the horizontal plane with the heading direction provided in CLHeading, the angle between (call it x axis, as it is the iOS body frame coord) and the x of the CLHeading should give us the correct magnetic heading (forget true heading).
That is in this example:
*
* ------------
* | |
* ° |-> (magnetic heading)
* | |
* -----|------
* v (max inclination example where p = 0)
So in the above example we know it is CLHeading.magneticHeading + 90° but I do not want to go down that route as I have already been. I want to do it mathematically using all the clever API's provided.
IT is that simple, but I have tried tons of choices without success.
Please help me find out where I am thinking the wrong way!