Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|cite|improve this question
There is a discontinuity of the longitude at the poles and along the dateline, so why should you expect such a mapping from quaternions either? Using quaternions to represent 3D-rotations does get rid of discontinuities of other kind. IIRC, most notably those related to gimbal locks. – Jyrki Lahtonen May 23 '12 at 12:13
Yes exactly, quaternion rotations are used to get rid of the gimbal locks, i.e you can have a surjective mapping from quaternions to those 3 euler angles, but not back (therefore not bijective). That is not my point, however. I thought maybe one could find a (only surjective) mapping to a single angle, just like you can map the quaternion to euler angles. such a surjective mapping exists to the real numbers: just add all 3 euler angles together for example. This is not very meaningful, however. – Philip Daubmeier May 23 '12 at 12:36
Also, the jump from -pi to pi is legit, as it is an angle (therefore I dont regard this as a singularity). The jump from any angle to 0 is what I am worried about. – Philip Daubmeier May 23 '12 at 12:37
up vote 2 down vote accepted

There do exist surjective continuous mappings $\mathbb H \to (-\pi,\pi]$, but these are not what you want (one example is to take a surjective map $\mathbb R\to(-\pi,\pi]$ like $x\to\pi(\frac2{1+x^2}-1)$ and compose it with any $\mathbb R$-linear projection $\mathbb H\to\mathbb R$). I think at the very least you want the map to be surjective when restricted to the unit quaternions, and already this is not possible. The reason is that the unit quaternions form a compact set while the interval $(-\pi,\pi]$ is not compact, and it is a theorem that the image of a compact set by a continuous map is always compact.

If you glue together the endpoints of $(-\pi,\pi]$ to form a circle (which is compact), there do exist continuous surjective maps. However these are probably still not what you want, because no doubt you want there to be some loop in the unit quaternions that maps to a complete tour around the circle. This is not possible because you can always continuously contract the loop within the unit quaternions to a point, and the image under your mapping would contract the tour around the circle continuously to a point, and again this is impossible.

These two impossibilities are related to the discontinuities of the longitude along respectively the date line and at the poles that Jyrki Lahtonen mentioned. These kind of obstructions are studied in homology- and homotopy theory.

share|cite|improve this answer
Sorry for the late response. Thanks for your answer! That just confirms my informal intuition. Just to be clear: from a homotopy point of view one could 'stitch holes' into both poles of the sphere and stretch it to a cylinder and map this to the compact (glued ends) circle again. This means the only real problem are the poles, and I cant get around this? – Philip Daubmeier May 24 '12 at 8:53
Well, it's a bit harder actually. The trouble can be isolated in the poles for an ordinary $2$-sphere (the one that lives in $3$-dimensional space). However the unit quaternions are a $3$-sphere in $4$-dimensional space; if you just cut out two points, all loops will still be contractible (the technical term is: the space remains simply connected). To get any obstruction against contracting loops on a $3$-sphere, it is clear you need to cut out at least entire curves (but I don't know just what will do). – Marc van Leeuwen May 24 '12 at 9:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.