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'm trying to rotate a 4 dimensional point (w,x,y,z). So far I've been rotating around planes (wx,xy,yz,zw,wy, and xy), but the order in which I do these rotations changes the results and can sometimes result in gimbal lock.

I understand that quaternions are the solution to this problem in 3 dimensions, but can quaternions also do rotations in 4 dimensions and if so, how?

share|cite|improve this question
Quaternions presumably won't help, but I don't quite understand the problem that you're having. Can you explain it a little better? – Jim Belk Jun 11 '11 at 23:50
From what I understand about quaternion rotations in 3d space, the major benefit is that the entire rotation is done as one step, whereas if you apply a rotation around the x axis, y axis, and then z axis, the order in which these operations are done matters (i.e. rotating x,y, and then z is different from rotating x,z,and y.) I'd like to have a cleaner rotation for 4d space wherein I rotate all axes (or is it planes?) simultaneously. – Greg Jun 11 '11 at 23:58
In what way are these rotations specified? Are you given an axis plane and an angle? Also, do you know about rotation matrices? – Jim Belk Jun 12 '11 at 0:12
@Jim As Greg mentions gimbal lock, the problem he is facing is probably related to the fact that the inverse mapping from $SO(4)$ to his parameter space (presumably something like the sixth cartesian power of $S^1$) is not continuous. In other words, if you change the rotation slightly around a bad point, you may need to recompute the parameters completely. The quaternions give a nice parametrization of the covering space of $SO(3)$, and thus avoid this in 3D. – Jyrki Lahtonen Jun 12 '11 at 7:25
See for a more detailed mathematical description of the gimbal lock. – Jyrki Lahtonen Jun 12 '11 at 7:33
up vote 3 down vote accepted

As Jyrki suggests, it is possible to use a pair of unit quaternions to describe a rotation is four dimensions. Specifically, any rotation $R$ can be written as $$ R(v) \;=\; avb $$ where $v$ is a vector in $\mathbb{R}^4$ (treated as a quaternion), and $a$ and $b$ are the unit quaternions describing the rotation.

Given two such rotations $$ R(v) \;=\; avb \qquad\text{and}\qquad R'(v)\;=\;a'vb' $$ the composition $R\circ R'$ (i.e. rotating $R'$ and then rotating $R$) is obtained by multiplying the corresponding quaternions: $$ (R\circ R')(v) \;=\; (aa')v(b'b). $$

Rotations around the six coordinates planes can be described as follows: $$ \begin{array}{cc} R_{wx}^\theta(v) \;=\; e^{-i\theta/2}ve^{i\theta/2} & R_{yz}^\theta \;=\; e^{i\theta/2}ve^{i\theta/2} \\ \\ R_{wy}^\theta(v) \;=\; e^{-j\theta/2}ve^{j\theta/2} & R_{xz}^\theta \;=\; e^{j\theta/2}ve^{j\theta/2} \\ \\ R_{wz}^\theta(v) \;=\; e^{-k\theta/2}ve^{k\theta/2} & R_{xy}^\theta \;=\; e^{k\theta/2}ve^{k\theta/2} \end{array} $$ where $e^{j\theta} \;=\; \cos(\theta) + j\sin(\theta)$, etc.

Finally, note that the quaternion-pair representation of a rotation is not unique. Specifically, the rotation with coefficients $(a,b)$ is the same as the rotation with coefficients $(-a,-b)$, for all unit quaternions $a$ and $b$.

share|cite|improve this answer
Does that mean, I can take any two unit quaternion $a,b$ and make a rotation $R=avb$ which will generate a rotation part of $SO(4)$. So the set of all unit quaternion pairs span the set $SO(4)$? – Gabriel Mar 7 at 13:15

No, I don't believe quaternions work in 4 dimensions. See this and this.

share|cite|improve this answer
Doesn't the double cover map $S^3_L\times S^3_R\rightarrow SO(4)$ described in your latter link allow Greg to avoid gimbal locks much the same way that the use of the covering map from the unit quaternions to $SO(3)$ does? I may be completely wrong about this. I'm just curious :-) – Jyrki Lahtonen Jun 12 '11 at 7:51

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.