# Combining Two 3D Rotations

Every rotation in 3D space can be defined by a rotation axis and an angle. Now let's say we have two rotations $R_1 (\text{(axis)}_1, \text{(angle)}_1)$, $R_2 (\text{(axis)}_2, \text{(angle)}_2)$.

I remember that Rotation operator is closed under composition, so $R_1 (R_2(\text{object}))$ will be a rotation again.

Does anybody know how to find the new axis and angle for $R_1R_2$?

-
depending on what on context of the problem, you might compute the eigenspace of eigenvalue 1 (i.e. the rotation axis whose vectors are fixed under that rotation). – shuhalo Feb 17 '11 at 2:15
nice point of view :) – Nima Feb 19 '11 at 14:34

Once again, the easiest way of doing this (IMHO, at least) turns out to be quaternions: a rotation of $\theta$ about the (normalized) vector $\hat{v} = (v_0, v_1, v_2)$ is represented by the quaternion ${\bf q}=\mathrm{cos}(\theta/2) + \mathrm{sin}(\theta/2)*(v_0{\bf i}+v_1{\bf j}+v_2{\bf k})$; and quaternion multiplication is easy to compute (all you need are the base axioms ${\bf i}^2 = {\bf j}^2 = {\bf k}^2 = {\bf i}{\bf j}{\bf k} = -1$ - note that the latter implies for instance that ${\bf i}{\bf j} = {\bf k}$ by simply multiplying both sides by ${\bf k}$); once you have your resultant quaternion, the axis can be extracted as the (normalized) imaginary part of the result and the angle can be found by taking the arc-cosine of the scalar part. See the Wikipedia page on quaternions and rotations for more details on just how this works.