# Composition of rotations around nonintersecting axes

I know how to compute the composition of two rotations using quaternions (or by multiplying rotation matrices), and this theorem by Hamilton is very helpful in understanding geometrically how it works.

However, the above is for the case where both rotations are around axes that pass through the origin. I would like to know what happens if this is not the case.

So suppose I take a three dimensional object and rotate it first by an angle of $$\theta_1$$ around axis $$a_1$$ and then by an angle of $$\theta_2$$ around axis $$a_2$$, where $$a_1$$ and $$a_2$$ are oriented lines in 3D space that do not necessarily intersect.

From geometric intuition, it seems that the composition of rotations in 3d will be a rotation by some angle $$\theta_3$$ around some axis $$a_3$$, combined with a translation along the axis $$a_3$$. (Except in degenerate cases where it's just a translation or just a rotation).

I think the angle $$\theta_3$$ and the orientation of $$a_3$$ will be calculated in the same way as for the case when the axes pass through the origin. But what about the position of the new axis and the translational component along it? How can this be calculated, and, more importantly, how can I get a good geometric intuition about how it depends on the angles $$\theta_1$$, $$\theta_2$$ and the axes $$a_1$$ and $$a_2$$ of the original rotations?

• It might be more helpful for developing a geometric intuition about this to view a rotation as occurring in some plane instead of about some axis. You can then interpret the second rotation as modifying the plane of the first.
– amd
Oct 22, 2018 at 22:05
• The so-called “screw decomposition” of rigid motions in $\mathbb R^3$ might be useful, too.
– amd
Oct 22, 2018 at 22:59
• @amd where can I read more about the screw decomposition? I suppose the most general version of this question is, "how to compose screw motions", since it's those that form a group I think. Oct 23, 2018 at 1:16
• Just a general note: it seems that what I'm looking for is called "screw theory". Wikipedia has some material on it on the pages Plücker coordinates and screw theory, but it's not well organised or readable. I expect that much better introductory material can be found with a little web searching, which I will do later. Oct 23, 2018 at 1:46
• Another general note: in group theory, the group of screw transformations is called E+(3), which is a Lie group - reading up on this may also give a useful perspective. Oct 23, 2018 at 1:48

First, let's recall how translations and rotations behave in linear algebra:

Let's say you have a pure rotation matrix $$\mathbf{R}$$. To apply that rotation around point $$\vec{o}$$ to vector $$\vec{v}$$, we do $$T(\vec{v}) = \vec{o} + \mathbf{R}(\vec{v} - \vec{o})\tag{1}\label{NA1}$$ Because matrix-vector multiplication is associative, $$T(\vec{v}) = \mathbf{R}\vec{v} - [\mathbf{R}\vec{o} - \vec{o}]\tag{1a}\label{NA1a}$$ and because the inverse rotation $$\mathbf{R}^{-1}$$ exists if the rotation exists, $$T(\vec{v}) = \mathbf{R}(\vec{v} + [\mathbf{R}^{-1}\vec{o} - \vec{o}]) \tag{1b}\label{NA1b}$$ This means that we can always transform a translation-before-rotation into translation-after-rotation, and vice versa. In general, \begin{aligned} T(\vec{v}) &= \vec{t}_1 + \mathbf{R}(\vec{v} + \vec{t}_0) \\ \; &= \mathbf{R}\vec{v} + [\vec{t}_1 + \mathbf{R}\vec{t}_0] \\ \; &= \mathbf{R}\left(\vec{v} + [\vec{t}_0 + \mathbf{R}^{-1}\vec{t}_1]\right) \end{aligned} \tag{2}\label{NA2} For illustration, I used brackets $$[ ]$$ around the translation part, above.

Now, let's chain three rotations $$\mathbf{R}_1$$ through $$\mathbf{R}_3$$ around points $$\vec{o}_1$$ through $$\vec{o}_3$$: $$T(\vec{v}) = \vec{o}_3 + \mathbf{R}_3 \left ( \vec{o}_2 + \mathbf{R}_2 \left ( \vec{o}_1 + \mathbf{R}_1 ( \vec{v} - \vec{o}_1 ) - \vec{o}_2 \right) - \vec{o}_3 \right) \tag{3}\label{NA3}$$ Reordering the vector terms yields $$T(\vec{v}) = \vec{o}_3 + \mathbf{R}_3 \left ( \vec{o}_2 - \vec{o}_3 + \mathbf{R}_2 \left ( \vec{o}_1 - \vec{o}_2 + \mathbf{R}_1 ( \vec{v} - \vec{o}_1 ) \right) \right) \tag{3a}\label{NA3a}$$ and extracting the translation vectors so they're applied last, \begin{aligned} T(\vec{v}) & = \vec{o}_3 + \mathbf{R}_3 ( \vec{o}_2 - \vec{o}_3 ) + \mathbf{R}_3 \mathbf{R}_2 \left ( \vec{o}_1 - \vec{o}_2 + \mathbf{R}_1 ( \vec{v} - \vec{o}_1 ) \right) \\ \; &= \vec{o}_3 + \mathbf{R}_3 ( \vec{o}_2 - \vec{o}_3 ) + \mathbf{R}_3 \mathbf{R}_2 ( \vec{o}_1 - \vec{o}_2 ) + \mathbf{R}_3 \mathbf{R}_2 \mathbf{R}_1 ( \vec{v} - \vec{o}_1 ) \\ \; &= \vec{o}_3 + \mathbf{R}_3 ( \vec{o}_2 - \vec{o}_3 ) + \mathbf{R}_3 \mathbf{R}_2 ( \vec{o}_1 - \vec{o}_2 ) - \mathbf{R}_3 \mathbf{R}_2 \mathbf{R}_1 \vec{o}_1 + \mathbf{R}_3 \mathbf{R}_2 \mathbf{R}_1 \vec{v} \\ \end{aligned} \tag{3b}\label{NA3b} This means we can combine the entire translation into one rotation $$\mathbf{R}$$ followed by one translation by $$\vec{t}$$, $$T(\vec{v}) = \mathbf{R}\vec{v} + \vec{t} \tag{4}\label{NA4}$$ where $$\mathbf{R} = \mathbf{R}_3 \mathbf{R}_2 \mathbf{R}_1 \tag{4a}\label{NA4a}$$ and $$\vec{t} = \vec{o}_3 - \mathbf{R}_3 ( \vec{o}_3 - \vec{o}_2 ) - \mathbf{R}_3 \mathbf{R}_2 ( \vec{o}_2 - \vec{o}_1 ) - \mathbf{R}_3 \mathbf{R}_2 \mathbf{R}_1 \vec{o}_1 \tag{4b}\label{NA4b}$$ Of course, the translation $$\vec{t}$$ depends on the centers of rotation and the rotations themselves. Or, to be more specific, from the first and last center of rotation, and the vectors between the centers of successive rotations.

How can this be calculated, and, more importantly, how can I get a good geometric intuition about how it depends on the angles $$\theta_1$$, $$\theta_2$$, and the axes $$\vec{a}_1$$ and $$\vec{a}_2$$ of the original rotations?

Any number of rotations around arbitrary points can be combined to a single rotation around origin, followed by a translation as shown in $$\eqref{NA4}$$; it is just that the translation depends on the rotations and the rotation centers.

An intuitive way to construct the translation is to start with the location of the final rotation center (with respect to origin). Then, find the vector from that center to the previous center of rotation, rotate it by the final rotation, and substract it (add the opposite vector) to the translation. Repeat, but start with one earlier rotation at each step (so in the next step, you'd rotate by the next-to-last rotation and then by the last rotation). When you get to the very first rotation, rotate its center just like you would any point (each rotation matrix in turn), and substract that from translation.

Obviously, I wouldn't do that in my head. All I care about for an intuitive/geometric picture, is that the combined translation after combined rotation around origin depends on the center of the first rotation, the center of the last rotation, and the vectors between consecutive rotations centers; with all rotations applied to the first, only last rotation to the last.

It is obviously possible to apply the translation before the combined rotation, $$T(\vec{v}) = \mathbf{R}(\vec{v} + \vec{\tau})$$ but as seen from $$\eqref{NA1b}$$, that involves the inverses of the rotations. (Otherwise it is the exact same process.)

You can even add translations before/after each rotation, and combine those as well into the translation after (or before) combined rotation around origin.

While this answer may look like unnecessary waffling, it is actually a hugely important thing in practical computations, such as kinematics and inverse kinematics (say, examining how a robot arm moves, or how simulated orientable thrusters work).

Even if you have a long chain of rotations and translations (say, a long snake robot, or a complex articulated arm), the combined rotation around origin $$\mathbf{R}$$ and translation after rotation $$\vec{t}$$ are efficiently calculated (especially using unit quaternions aka versors) into a rotation matrix and a translation. The point is, the two operations can then be repeated for any number of vectors $$\vec{v}$$, regardless of how complex the chain of rotations and translations is.

Of course, if any intermediate rotation, rotation center, or translation changes, then the combined transformation must be recalculated.

• Thank you, this is just the sort of intuition I was looking for. (I'll accept this after some time.) Oct 24, 2018 at 0:51
• @Nathaniel: No worries! Do consider the other answers as well. In particular, Yves Daousts describes the same underlying idea in a fraction of the space. I am not a mathematician myself, and need the extra text and steps to integrate the ideas and get an intuitive grasp -- even though I often use this kind of math as a tool to solve various problems. Those with a more math-fu do not need the extra wordage, and prefer the more concise answers. It's okay either way: the point here is to help others learn. Oct 24, 2018 at 4:56

The composition of two rotations will not always be a rotation. Thinking first about the Euclidean plane, if we take the rotations by angle $$\pi$$ in two different centres, then the product of these transformations will be a translation. This is the reason that the set of all rotations of the Euclidean plane is not a group.

Now, we construct a three-dimensional example. Let $$R_{1},R_{2}$$ be rotations of $$\mathbb{E}^{2}$$ by angle $$\pi$$, with different centres $$p_{1},p_{2} \in \mathbb{E}^{2}$$. Then for $$i = 1,2$$ the rotations say $$\tilde{R}_{i} : \mathbb{E}^{3} \rightarrow \mathbb{E}^{3}$$ given by $$(x,y,z) \mapsto (R_{i}(x,y),z)$$ have composition $$\tilde{R}_{1} \circ \tilde{R}_{2}$$ which is a translation of $$\mathbb{E}^{3}$$.

• That makes sense. In fact, I think in general the composition of rotations in 3d will be a rotation combined with a translation along its axis, except in degenerate cases like this where is just a translation. (Or just a rotation.) I would still like to know how to calculate it, though. Oct 22, 2018 at 9:00

Things are not so complex.

If you rotate a body around an axis which is not through the origin, you get the same result as by

• translating the body so that the axis comes to the origin,

• rotating around the translated axis,

• translating back to the original axis.

In the second step, the first translation "rotates as well".

So you can combine the rotations as if they were made around axis through the origin, and combine with a single translation.

Let $$R$$ be the rotation matrix and $$O$$ a point on the axis,

$$P'=O+R(P-O)=RP+O-PO=RP+T.$$

If you concatenate two such operations,

$$P'=R_2(R_1P+T_1)+T_2=R_2R_1P+R_2T_1+T_2=RP+T.$$