I have given an attitude quaternion that describes the rotation of a device. This roation is relative to the magnetic north, so the quaternion includes implicit information about the heading of the device. Now I want to extract this information out of the quaternion, but I cant find a way to do this without having singularities, if the device is held in certain positions.
My goal is to get a mapping from the attitude to the heading angle, such that small changes in the input quaternion result in only small differences in the resulting heading angle.
All previous tries ended up to have singularities where small changes of attitude result in a huge jump (worst case even a jump from $0$ to $\pi$).
So my guess is, that there does not exist a surjective mapping $f\colon\, \mathbb H \to (-\pi,\pi]$ (a projection from 4D to a 1D space), that satifies this restriction of not having discontinuous points. I just can not mathematically prove it.
Is there a prove to this assumption, or maybe a disprove by example? I am stuck here...
Thanks in advance for any help!