Rotations in four dimensions: matrix to angle representation

58 Views Asked by At

I'm putting together a visualizer for the $120$-cell (a four-dimensional platonic solid), and would like a way of rotating one dodecahedron to the location of another, as selected by the user. I can calculate the $4\times4$ matrix corresponding to this rotation, but I would like to interpolate this rotation to animate it.

Is there an easy way to algorithmically convert a $4\times4$ rotation matrix into an angle-based representation? Ideally as a combination of rotations purely in the $xy, xz, xw, yz, yw$, and $zw$ planes, but otherwise as a change of basis applied to a matrix of the form $$\left( \begin{matrix} \cos(s) & -\sin(s) & 0 & 0\\ \sin(s) & \cos(s) & 0 & 0 \\ 0 & 0 & \cos(t) & -\sin(t) \\ 0 & 0 & \sin(t) & \cos(t) \end{matrix}\right)$$

Is there an easier way of approaching this task based on the fact that I'm working specifically with "faces" of the $120$-cell? That is, are the specific rotations I'm looking for known?

2

There are 2 best solutions below

0
On BEST ANSWER

To add to perfectly valid answer of Cade Reinberger, I want to elaborate on why the log interpolation is exactly the same as double rotation.

As you already know, for your rotational transformation $R$ there exists an orthogonal matrix $S$ and angles $\theta_1$, $\theta_2$, that: $$ R = S^T J S, \quad \text{where } J=\left( \begin{matrix} \cos \theta_1 & -\sin \theta_1 & 0 & 0\\ \sin \theta_1 & \cos \theta_1 & 0 & 0 \\ 0 & 0 & \cos \theta_2 & -\sin \theta_2 \\ 0 & 0 & \sin \theta_2 & \cos \theta_2 \end{matrix}\right) $$

When you take log of $R$: $$ \log R =(R-I) - \frac{(R-I)^2}2+ \frac{(R-I)^3}3\ldots = S^T(J-I)S-S^T \frac{(J-I)^2}2S+\ldots = \\ S^T\log (J)S $$

Logarithm of $J$ is just the log of simple rotations: $$\log J = \begin{pmatrix} 0 & -\theta_1 & 0 & 0\\ \theta_1 & 0 & 0 & 0 \\ 0 & 0 & 0 & -\theta_2 \\ 0 & 0 & \theta_2 & 0 \end{pmatrix}$$

When you multiply it by $0\le t\le 1$ and exponentiate, you will get:

$$ R_t = S^T J_t S, \quad \text{where } J_t=\left( \begin{matrix} \cos (\theta_1t) & -\sin (\theta_1t) & 0 & 0\\ \sin (\theta_1t) & \cos (\theta_1t) & 0 & 0 \\ 0 & 0 & \cos (\theta_2t) & -\sin(\theta_2t) \\ 0 & 0 & \sin (\theta_2t) & \cos (\theta_2t) \end{matrix}\right). $$

In other words, it's exactly what you are asking for. However, from a practical point of view the formula $\exp(t \log R)$ isn't good, since the most computationally heavy part is calculating the Jordan decomposition when you calculate logs and exps, but we know that $R$ and $t\log R$ have the same eigenspaces. So in practice, you would do Jordan decomposition to find $S$, $\theta_1$ and $\theta_2$ and then construct matrix $R_t=S^TJ_tS$ directly. Thus, you would need only one decomposition for the whole animation.

Finally, although it's possible to find 6 Euler angles (similarly to Givens rotations), the interpolation of Euler angles usually look bad (especially near gimbal locks), so I advise you not to look into it.

0
On

This doesn't give you angles, but since your main goal is interpolation, one quite natural way to interpolate is using the Lie structure of $\operatorname{SO}(4, \mathbb{R}$). You can just use the matrix logarithm and matrix exponential to get an interpolation that

$$\operatorname{interp}(R_1, R_2, t) = \exp\left(t\log\left(R_2R_1^{-1}\right)\right)R_1$$

If I'm not mistaken (and I very much could be, since this came from an idea we once used in some code I didn't write), the Lie structure guarantees that this will give an interpolation that remains in $\operatorname{SO}(4, \mathbb{R}$), and will be along the geodesic in some meaningful sense.