## Clifford Algebras for Rotating, Scaling, and Translating SpaceJuly 6th, 2009 Patrick Stein

In (very much) earlier articles, I described:

Today, it is time to tackle rotating, translating, and scaling three-dimensional space using Clifford algebras.

### Three dimensions now instead of two

Back when we used Clifford algebras to rotate, translate, and scale the plane, we were using the two-dimesional Clifford algebra. With the two-dimensional Clifford algebra, we represented two-dimensional coordinates $(x,y)$ as $xe_1 + ye_2$. It shouldn’t surprise you then to find we’re going to represent three-dimensional coordinates $(x,y,z)$ as $xe_1 + ye_2 + ze_3$.

As before, we will have $e_1e_1 = 1$ and $e_2e_2 = 1$. Similarly, we will have $e_3e_3 = 1$. In the two-dimesional case, we showed that $e_1e_2 = -e_2e_1$. By the same logic as the two-dimensional case, we also find that $e_1e_3 = -e_3e_1$ and $e_2e_3 = - e_3e_2$. We could potentially also end up multiplying $e_1$, $e_2$, and $e_3$ all together. This isn’t going to be equal to any combination of the other things we’ve seen so we’ll just leave it written $e_1e_2e_3$.

Using the identities like $e_ie_j = - e_je_i$ for $i \ne j$, we can shuffle any combination of $e_1$, $e_2$, and $e_3$ so that all of the indexes are in order. We may have to change the sign, but we won’t have to change anything else. For example:

$\begin{array}{rcl} e_3e_2e_1 &=& - e_3e_1e_2 \\ &=& e_1e_3e_2 \\ &=& -e_1e_2e_3\end{array}$

$\begin{array}{rcl} e_2e_3e_1 &=& - e_2e_1e_3 \\ &=& e_1e_2e_3\end{array}$

Recall that $e_1e_2$ was a bivector. Here, we have added one more vector: $e_3$, two more bivectors: $e_1e_3$ and $e_2e_3$, and a trivector $e_1e_2e_3$. The general element of the three-dimensional Clifford algebra looks like:

$a + be_1 + ce_2 + de_3 + ke_1e_2 + m e_1e_3 + n e_2e_3 + p e_1e_2e_3$

For the two-dimensional Clifford algebra, we had $4 = 2^2$ terms in the general element—the Clifford algebra is an algebra on a four-dimensional vector space. For the three-dimensional Clifford algebra, we have $8 = 2^3$ terms in the general element. If we backtrack here to the one-dimensional Clifford algebra, we see that the general element looks like $a + be_1$ meaning there are $2 = 2^1$ terms in the general element of the one-dimensional Clifford algebra. If we backtrack even further, we see that for a zero-dimensional Clifford algebra, the general element looks like $a$ meaning there is $1 = 2^0$ term in the general element of the zero-dimensional Clifford algebra.

This relation is going to hold for Clifford algebras in general. If $k$ is a non-negative integer, then there are $2^k$ terms in the general element of the $k$-dimensional Clifford algebra. The $k$-dimensional Clifford algebra is an algebra over a $2^k$-dimensional vector space. There are $2^k$ degrees of freedom, if you like. We won’t be using all of those degrees of freedom because we are restricting ourselves to scaling, rotating, and translating vectors.

### Translating and Scaling

We are going to represent our points in three-dimensional space using the vector portion of our three-dimensional Clifford algebra $\mathcal{C\ell}_2$. So, a point with coordinates $(x,y,z)$ will be $p = xe_1 + ye_2 + ze_3$.

Just as we did in the two-dimensional case, we can scale three-space away from the origin by a factor of $s$ just by multiplying each point $p$ by the real number $s$. So, $p^\prime = s p$.

Similarly, we can translate the point $p$ by $a$ units in the x-direction, $b$ units in the y-direction and $c$ units in the z-direction by creating a translation vector $t = ae_1 + be_2 + ce_3$ and adding it to each point $p$ so that $p^\prime = p + t$.

### Rotating three-space

When we used Clifford algebras to rotate the xy-plane, we let $r = \cos\frac{\theta}{2} + \sin\frac{\theta}{2} e_1e_2$ and let $\overline{r} = \cos\frac{\theta}{2} - \sin\frac{\theta}{2} e_1e_2$. Then, to rotate a point $p$ we multiplied out $r \cdot p \cdot \overline{r}$.

Three-dimensional space contains the xy-plane. We want to be able to rotate things in the xy-plane in just the same way we did in the two-dimensional case. We even spent some time in another article verifying that these rotations in the xy-plane would leave coordinates on other axises alone.

Rotating space with the quaternions, we found that could rotate around an arbitrary axis. If we pick an axis that points from the origin to $(a,b,c)$ where $a^2 + b^2 + c^2 = 1$, then we used the quaternion $\alpha + \beta ai + \beta bj + \beta ck$ (where $\alpha = \cos\frac{\theta}{2}$ and $\beta = \sin\frac{\theta}{2}$ just like we used the two-dimensional Clifford algebra rotation. We let $r = \alpha + \beta ( ai + bj + ck )$and $\overline{r} = \alpha - \beta ( ai + bj + ck )$. Then, we could rotate a point $p = xi + yj + zk$ by evaluating $p^\prime = r \cdot p \cdot \overline{r}$.

With Clifford algebras, we don’t mush together translations and rotations both into the vector portion. We keep translations in the vector portion, but we move rotations to the bivector portion. We’re going to rotate around the axis from the origin to $(a,b,c)$ (where $a^2 + b^2 + c^2 = 1$ by an angle $\theta$ by letting $r = \alpha + \beta ( a e_2e_3 + b e_3e_1 + c e_1e_2 )$
and $\overline{r} = \alpha - \beta ( a e_2e_3 + b e_3e_1 + c e_1 e_2 )$ where $\alpha = \cos\frac{\theta}{2}$ and $\beta = \sin\frac{\theta}{2}$. Then, we can rotate a point $p = xe_1 + ye_2 + ze_3$ just by multiplying on the left by $r$ and on the right by $\overline{r}$ so that $p^\prime = r\cdot p \cdot \overline{r}$.

I wrote $r$ a little differently here than I did above for the general element. If I were to keep totally consistent with what I wrote above, I should write $r = \alpha + \beta( c e_1e_2 - b e_1e_3 + a e_2e_3 )$. Certainly, we can add in any order, so it is totally cosmetic to write it one way or the other. I chose to keep $a$, $b$, and $c$ in order rather than $e_1e_2$, $e_1e_3$, and $e_2e_3$. I also chose to keep them all positive at the expense of using $e_3e_1$ instead of $e_1e_3$.

Before we get into why we used $e_3e_1$ instead of $e_1e_3$ for the $b$, let’s look at the case of rotating around the z-axis. In that case, $(a,b,c)$ would be $(0,0,1)$. This should degenerate to exactly what we had for rotating the xy-plane with Clifford algebras. Sure enough, if we plop those values in for $a$, $b$, and $c$ we find that $r = \alpha + \beta e_1e_2$ exactly as we had in the two-dimensional case. Bonus!

Why should the $b$ end up with $e_3e_1$ instead of $e_1e_3$? The way that our axis system worked with the quaternions is that we had the x-axis going east, the y-axis going north, and the z-axis going up. If we are going to rotate around the y-axis, then we need to rotate the z-axis toward the x-axis as opposed to rotating the x-axis toward the z-axis. The rotation around the z-axis takes the x-axis toward the y-axis. This is represented with the $e_1e_2$. $e_1$ is the x-axis and it is moving toward the y-axis $e_2$. If we reverse the order, $e_2e_1$, then we are moving the y-axis toward the x-axis. Using our transposing tricks, $e_2e_1 = -e_1e_2$. Thus, rotating the y-axis toward the x-axis is just negatively rotating the x-axis toward the y-axis. In better English, that is: rotating the y-axis toward the x-axis is just rotating the x-axis away from the y-axis.

If we had chosen $e_1e_3$ instead of $e_3e_1$, then we would have messed up how our axises fit together. To keep the axis of rotation obvious, we used $(a e_2e_3 + b e_3e_1 + c e_1e_2 )$. We can still rewrite the result in any form we like. If we were given $r = \alpha + \beta ( A e_1e_2 + B e_1e_3 + C e_2e_3 )$, that would be a rotation around the axis from the origin to the point $(C,-B,A)$. I think it’s more intuitive to write $r$ as $\alpha + \beta ( C e_2e_3 - B e_3e_1 + A e_1e_2 )$ because then you can read the axis of rotation right off of the coefficients.

### Next time

Next time, we’ll tackle rotating, scaling, and translating hyperspace (four-dimensional space).