4

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?

Greg
  • 43
  • 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 00:12
  • So far I just specify an angle for each plane I want to rotate around and then rotate around the planes I listed above. Problem is, order of these rotations matters when I'm doing that method. – Greg Jun 12 '11 at 00:14
  • Right, but what are you using this for? Why is it a problem that the order in which you perform the rotations matters? Would it help to use matrices? (See http://en.wikipedia.org/wiki/Rotation_matrix) – Jim Belk Jun 12 '11 at 00:31
  • Oh, here's what I'm working on: http://www.youtube.com/watch?v=pn6aC_fRufo (code at http://code.google.com/p/4d-buddhabrot-render/ ). I'm rotating a 4 dimensional buddhabrot set. I suppose I might take a 3d subset of the 4 dimensional set I have and use a quaternion to rotate that. – Greg Jun 12 '11 at 00:35
  • And yes, I'm currently using rotation matrices. – Greg Jun 12 '11 at 00:36
  • If you want to rotate continuously, one option would be to use the matrix exponential (http://en.wikipedia.org/wiki/Matrix_exponential). If $A$ is a $4 \times 4$ antisymmetric matrix, then $e^{\theta A}$ represents a rotation by an angle of $\theta$ in a direction specified by $A$. Roughly speaking, $A$ is the four-dimensional analogue of the axis of a rotation in three dimensions. You can compute $e^{\theta A}$ using the power series or by diagonalizing $A$. – Jim Belk Jun 12 '11 at 00:47
  • 1
    @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 07:25
  • 1
    See http://math.stackexchange.com/q/8980/11619 for a more detailed mathematical description of the gimbal lock. – Jyrki Lahtonen Jun 12 '11 at 07:33
  • @Jyrki I see -- thanks for the link. I think I understand the problem better now. – Jim Belk Jun 12 '11 at 16:11

2 Answers2

4

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$.

Jim Belk
  • 49,278
  • 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 07 '16 at 13:15
2

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

mac
  • 2,142
  • 1
    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 07:51