Noncommuting rotations about fixed axes (source code)

= Noncommuting rotations about fixed axes
{title2=$R_zR_x\ne R_xR_z$}

Use a fixed right-handed <Cartesian basis> in three dimensions and active <rotations in three dimensions> through $\pi/2$ <radians>. The <right-hand rule> gives the following <rotation matrices> about the positive $x$ and $z$ axes:
$$
R_x=\begin{pmatrix}1&0&0\\0&0&-1\\0&1&0\end{pmatrix},\qquad
R_z=\begin{pmatrix}0&-1&0\\1&0&0\\0&0&1\end{pmatrix}.
$$
For the <vector> $v=(1,1,0)^T$, the two orders give
$$
\begin{aligned}
v&\xrightarrow{R_x}(1,0,1)^T\xrightarrow{R_z}(0,1,1)^T,\\
v&\xrightarrow{R_z}(-1,1,0)^T\xrightarrow{R_x}(-1,0,1)^T.
\end{aligned}
$$
Both outputs have <Euclidean norm> $\sqrt2$, but they point in different directions. Each arrow below is a <vector> from the origin; the curved paths track its endpoint during each <rotation in three dimensions>.

\Image[/rotation-fixed-axes-noncommuting-composition.png]
{title=Active <rotations in three dimensions> about fixed axes: the order changes the final <vector>}

The axes in this example remain fixed throughout. A command to turn about an object's own current axis describes a different operation because that axis can move after the first turn. With an object's <orthonormal basis> represented by columns of $Q$, a fixed-axis <rotation matrix> $R$ acts by $RQ$, whereas the corresponding rotation expressed in the object's own <basis> acts by $QR$.<Modern Robotics: Mechanics, Planning, and Control by Kevin M. Lynch and Frank C. Park>[Modern Robotics, §3.2.1.2, preprint pp. 72–73: premultiplication uses fixed-frame axes; postmultiplication uses body-frame axes]{ref}