es

This section is divided into a number of subsections, links to which are:

Rotations

3D Rotations

Euler Rotation Theorem

3D Rotations via Shearing

Quaternions

Compositions

Cayley Decomposition

$Post := If[MatrixQ[#1], MatrixForm[#1], #1] & (* outputs matrices in MatrixForm*)
Remove[ "Global`*"] // Quiet (* remove all variables *)

 

2D Rotations

A rotation on the plane (2D, for short) about the origin has only one parameter, the angle, which defines the amount of rotation. The standard convention found in most math books is to consider counterclockwise rotation positive and clockwise rotation negative. We can do rotation about the origin using matrix multiplication. A rotation matrix is a transformation performed by matrix multiplication on vectors that results in rotating of the vector by angle θ in counterclockwise direction. WE use matrices in bracket notation when they are considered as operators on column vectors and we embrace matrices in parentheses when they operate on row vectors from right.

When rotation occurs about a fixed point other than the origin, use the following three step approach:

  • Move fixed point to origin,
  • Rotate,
  • Move fixed point back.

Frame Rotation -- Points fixed

Let us consider a plane ℝ², which is the Cartesian product of two real number lines, ℝ × ℝ. Upon choosing two perpendicular lines with uniform grid, we obtain a coordinate system or a frame. Since a grid has a natural order, these two lines become axes and usually they are visualized with arrows. The point of intersection of these two lines is called the origin. The horizontal line, known as abscissa is usually labeled with x, and the vertical line pointed up is known as ordinate, we label it will letter y.

Note that, these two axes are ordered in the plane such that a 90 degree counter-clockwise rotation about the origin transfers the positive x-axis into the positive ordinate. The origin represents the zero point on each coordinate axis and is designated by the ordered pair of real numbers (0, 0). A unit vector on abscissa is usually denoted by i = (1, 0) ) or e₁, and the unit vector on ordinate is denoted by j = (0, 1) or e₂.

We fix a point P(x₀, y₀) in the xy-plane, which is also identified by vector \( \displaystyle \quad {\bf r} = \overline{OP} = (x_0 , y_0 )\quad \) because point P and vector r have the same coordinates. We are going to determine new coordinates of point P when frame O(x, y) is rotated by angle θ in counterclockwise direction (which is considered to be positive). For simplicity, we drop subscripts of point/vector in further derivation. Let the coordinates of P in the new frame be (X, Y), which can be expresed through its previous coordinates (x, y).

p = {2*Cos[Pi/3], 2*Sin[Pi/3]}; point = Graphics[{PointSize[0.05], Purple, Point[{p}]}]; arx = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{-0.3, 0}, {2*1.3, 0}}]}]; ary = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, -0.3}, {0, 2*1.3}}]}]; arX = Graphics[{Dashed, Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{-0.3*Cos[Pi/6], -0.3*Sin[Pi/6]}, {2*1.3*Cos[Pi/6], 2*1.3*Sin[Pi/6]}}]}]; arY = Graphics[{Dashed, Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0.3*Cos[Pi/3], -0.3*Sin[Pi/3]}, {-2*1.3*Cos[Pi/3], 2*1.3*Sin[Pi/3]}}]}]; txt = Graphics[{Black, Text[Style["P(x, y)", FontSize -> 18, Bold], {0.95, 2.05}], Text[Style["x-axis", FontSize -> 18, Bold], {2.2, 0.3}], Text[Style["X-axis", FontSize -> 18, Bold], {2.2, 1.5}], Text[Style["y-axis", FontSize -> 18, Bold], {0.44, 2.55}], Text[Style["Y-axis", FontSize -> 18, Bold], {-0.99, 2.35}]}]; l1 = Graphics[Line[{{1, 1.73}, {1.55, 0.95}}]]; l2 = Graphics[Line[{{1, 1.73}, {1, 0}}]]; l3 = Graphics[Line[{{1, 1.73}, {0, 1.73}}]]; l4 = Graphics[Line[{{1, 1.73}, {-0.5, 0.8}}]]; arr = Graphics[{Purple, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, p}]}]; arr1 = Graphics[{Black, Thickness[0.01], Arrowheads[0.06], Arrow[{{0.6, 0.55}, {0.4, 0.7}}]}]; arr2 = Graphics[{Black, Thickness[0.01], Arrowheads[0.06], Arrow[{{1.58, 0.63}, {1.5, 0.85}}]}]; angles = Graphics[{Black, Thick, Circle[{0, 0}, 1.7, {0, Pi/6}], Circle[{0, 0}, 0.8, {0, Pi/3}]}]; txt2 = Graphics[{Black, Text[Style[\[Theta], FontSize -> 16, Bold], {0.35, 0.35}], Text[Style[\[Phi], FontSize -> 16, Bold], {1.35, 0.35}], Text[Style["x", FontSize -> 16, Bold], {1, -0.2}], Text[Style["X", FontSize -> 16, Bold], {1.6, 1.06}], Text[Style["y", FontSize -> 16, Bold], {-0.2, 1.73}], Text[Style["Y", FontSize -> 16, Bold], {-0.6, 0.65}]}]; Show[arx, ary, point, arX, arY, txt, l1, l2, l3, l4, arr, txt2, angles, arr1, arr2]
Figure 1: Frame rotation by angle ϕ

From Figure 1 we notice that the angle between the vector \( \displaystyle \quad {\bf r} = \overline{OP} \quad \) b>r and the rotated X-axis is θ − ϕ. Let r be the length of the vector r and ϕ be the angle between the vector and the positive x axis. Then, using ordinary right triangle trigonometry, we see that

\begin{align*} X &= r\,\cos \left( \theta - \phi \right) , \\ Y &= r\,\sin \left( \theta - \phi \right) \end{align*}
Expanding these expressions, we obtain
TrigExpand[Cos[a - b]]
Cos[a] Cos[b] + Sin[a] Sin[b]
TrigExpand[Sin[a - b]]
Cos[b] Sin[a] - Cos[a] Sin[b]
\begin{align*} X &= r\,\cos \theta \,\cos \phi + r\,\sin\theta\, \sin \phi , \\ Y &= r\,\sin \theta \,\cos\phi - r\,\cos\theta \,\sin \phi . \end{align*}
Thus the desired relationship between old coordinates and new ones becomes
\begin{align*} X &= x\,\cos\phi + y\,\sin\phi , \\ Y &= y\,\cos\phi - x\,\sin\phi . \end{align*}

If you are familiar with matrix multiplication (see Part 2 of this tutorial), we can replace a pair of equations with a concise formula. Wring coordinates as column vectors, we get

\begin{equation} \label{Eq2D.1} \begin{bmatrix} X \\ Y \end{bmatrix} = \begin{bmatrix} \cos\phi & \sin\phi \\ -\sin\phi & \cos\phi \end{bmatrix} \begin{pmatrix} x \\ y \end{pmatrix} \end{equation}
. When coordinates of point P are written as rows, we obtain
\begin{equation} \label{Eq2D.2} \begin{bmatrix} X & Y \end{bmatrix} = \begin{bmatrix} x & y \end{bmatrix} \begin{pmatrix} \cos\phi & -\sin\phi \\ \sin\phi & \cos\phi \end{pmatrix} . \end{equation}
. In this context, the corresponding matrix
\begin{equation} \label{Eq2D.3} \left[ {\bf R}\right] (\phi ) = \begin{bmatrix} \cos\phi & \sin\phi \\ -\sin\phi & \cos\phi \end{bmatrix} = \begin{pmatrix} \cos\phi & -\sin\phi \\ \sin\phi & \cos\phi \end{pmatrix}^{\mathrm T} \end{equation}
is called the rotation matrix. Letter "T" stands for transposition. We embrace this matrix into brackets to emphasize that this matrix operates on column vectors upon multiplication from left. We will use parentheses when row vector is multiplied by matrix from right.

Point Rotation -- Frame fixed

We begin with rotating a point P(x₀, y₀) in the xy-plane about the origin through an angle θ in counterclockwise direction. We demonstrate derivation of the rotation matrix in two ways. First, we use trigonometric relations, and then show that the same matrix can be obtained based on rotations of basic vectors i = (1, 0) and j = (0, 1),

Suppose that a given point P(x, y) is moved under rotation by angle ϕ into a new point Q(X, Y). In order to derive the rotation matrix, we recognize that the new point Q will be the same distance from the origin as the starting point P. So both points P and Q lie on the circle centered at the origin of radius r = |OP|. The point Q is just an extra angle ϕ, as measured from the positive abscissa (= x-axis) relative to the position of P at this circle. If the point P is at angle θ, then the new point Q is at the angle ϕ + θ. Since all the points on the circle of radius r with center at the origin can be written as \( \displaystyle r\,e^{{\bf j}\alpha} = \left( r\,\cos\alpha , r\,\sin\alpha \right) \) for some real number α. We know that point P has coordinates \( \displaystyle r\,e^{{\bf j}\theta} = \left( r\,\cos\theta , r\,\sin\theta \right) , \) while point Q has coordinates \( \displaystyle r\,e^{{\bf j}(\phi + \theta )} = \left( r\,\cos (\phi + \theta ) , r\,\sin (\phi + \theta ) \right) , \) where j is the unit vector in the positive vertical direction on complex plane ℂ so j² = −1.

q = {2*Cos[Pi/3], 2*Sin[Pi/3]}; p = {2*Cos[Pi/6], 2*Sin[Pi/6]}; pointP = Graphics[{PointSize[0.04], Blue, Point[{p}]}]; pointQ = Graphics[{PointSize[0.04], Purple, Point[{q}]}]; arx = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{-0.3, 0}, {2*1.3, 0}}]}]; ary = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, -0.3}, {0, 2*1.3}}]}]; l1 = Graphics[Line[{{1.73, 1}, {1.73, 0}}]]; l2 = Graphics[Line[{{1, 1.73}, {1, 0}}]]; l3 = Graphics[Line[{{1.73, 1}, {0, 1}}]]; l4 = Graphics[Line[{{1, 1.73}, {0, 1.73}}]]; arP = Graphics[{Blue, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, p}]}]; arQ = Graphics[{Purple, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, q}]}]; angles = Graphics[{Black, Thick, Circle[{0, 0}, 1.5, {0, Pi/6}], Circle[{0, 0}, 1.3, {Pi/6, Pi/3}]}]; txt = Graphics[{Black, Text[Style["Q(X, Y)", FontSize -> 18, Bold], {0.95, 2.0}], Text[Style["x-axis", FontSize -> 18, Bold], {2.2, 0.3}], Text[Style["P(x,y)", FontSize -> 18, Bold], {1.9, 1.3}], Text[Style["y-axis", FontSize -> 18, Bold], {0.44, 2.55}], Text[Style["y", FontSize -> 18, Bold], {-0.2, 1.0}], Text[Style["Y", FontSize -> 18, Bold], {-0.2, 1.73}]}]; arr1 = Graphics[{Black, Thickness[0.01], Arrowheads[0.06], Arrow[{{0.77, 1.05}, {0.66, 1.13}}]}]; arr2 = Graphics[{Black, Thickness[0.01], Arrowheads[0.06], Arrow[{{1.38, 0.6}, {1.3, 0.75}}]}]; txt2 = Graphics[{Black, Text[Style[\[Phi], FontSize -> 16, Bold], {0.75, 0.75}], Text[Style[\[Theta], FontSize -> 16, Bold], {1.25, 0.3}], Text[Style["X", FontSize -> 16, Bold], {1, -0.2}], Text[Style["x", FontSize -> 16, Bold], {1.5, -0.2}]}];

Figure 2: Point rotation by angle ϕ

Now we make an animation:

anim1 = Animate[ circle = Graphics[{Blue, Thickness[0.01], Circle[{0, 0}, 3]}]; p = {3 Cos[Pi/6], 3 Sin[Pi/6]}; q = {3 Cos[Pi/6 + increment*Pi/5], 3 Sin[Pi/6 + increment*Pi/5]}; points = Graphics[{PointSize[0.05], Purple, Point[{p, q}]}]; lines = Graphics[{Black, Thickness[0.01], {Arrow[{{0, 0}, p}], Arrow[{{0, 0}, q}]}}]; arc = Graphics[{Red, Thickness[0.015], Circle[{0, 0}, 3, {Pi/6, Pi/6 + increment*Pi/5}]}]; angles = Graphics[{Black, Thick, Circle[{0, 0}, 1.7, {Pi/6, Pi/6 + increment*Pi/5}], Circle[{0, 0}, 0.9, {0, Pi/6}]}]; ll = Graphics[{Green, Thick, Arrow[{{0, 0}, {3.5, 0}}]}]; txt = Graphics[{Black , Text[Style["P", FontSize -> 18, Bold], {2.9, 1.9}] , Text[Style["Q", FontSize -> 18, Bold], {-2.5, 2.3}] , If[increment > 1.54, Text[Style["\[Theta]", FontSize -> 18, Bold], {(*2 *) Cos[Pi/6 + increment/2 - 1*Pi/5],(*2 *) Sin[Pi/6 + increment/2 - 1*Pi/5]}]] , Text[Style["\[Phi]", FontSize -> 18, Bold], {1.1, 0.25}] , Text[Style["O", FontSize -> 18, Italic], {0, -0.4}] , Text[Style["x", Green, FontSize -> 18, Italic], {3.3, 0.3}]}]; Labeled[Show[circle, lines, arc, points, angles, ll, txt], "Rotation P\[RightArrow]Q"], {{increment, 0, "Added\nRadians"}, 0, 3, Appearance -> "Labeled"} , AnimationRepetitions -> Infinity , AnimationDirection -> ForwardBackward , Paneled -> False ]
Figure 3: Rotation PQ

In order to determine the rotation matrix, we express coordinates of point Q through coordinates of point P. To accomplish this task, we use trigonometric identities and delegate this job to Mathematica:

TrigExpand[Cos[a + b]]
Cos[a] Cos[b] - Sin[a] Sin[b]
TrigExpand[Sin[a + b]]
Cos[b] Sin[a] + Cos[a] Sin[b]
Then coordinates of point Q are expressed as
\begin{align*} Q &= \left( r\,\cos (\phi + \theta ), r\,\sin (\phi + \theta ) \right) \\ &= \left( r\,\cos\phi\, \cos\theta - r\,\sin\phi \,\sin\theta , r\,\sin\phi \,\cos\theta + r\,\cos\phi \,\sin\theta \right) \\ &= \left( \cos\phi\,x_0 - \sin\phi \,y_0 , \sin\theta \,x_0 + \cos\theta\, y_0 \right) . \end{align*}
Now we can express coordinates of point Q(x, y) through coordinates of point P(x₀, y₀)
\[ \left( x, y \right) = \left( \cos\phi \,x_0 - \sin\phi \,y_0 , \sin\phi \,x_0 + \cos\phi\, y_0 \right) \]
where x₀ = cos(θ) and y₀ = rsin(θ). If we convert coordinates of these two points from ℝ² into equivalent form as columns from ℝ2×1, we get
\begin{equation} \label{Eq2D.4} \left[ \begin{array}{c} x \\ y \end{array} \right] = \begin{bmatrix} \cos\phi & -\sin\phi \\ \sin\phi & \cos\phi \end{bmatrix} \cdot \left[ \begin{array}{c} x_0 \\ y_0 \end{array} \right] \end{equation}
or
\begin{equation} \label{Eq2D.5} \begin{bmatrix} x & y \end{bmatrix} = \begin{bmatrix} x_0 & y_0 \end{bmatrix} \begin{pmatrix} \cos\phi & \sin\phi \\ -\sin\phi & \cos\phi \end{pmatrix} . \end{equation}
Finally, we obtain 2-by-2 rotation matrix:
\begin{equation} \label{Eq2D.6} \left[ {\bf R} \right] (\phi ) = \begin{bmatrix} \cos\phi & -\sin\phi \\ \sin\phi & \phantom{-}\cos\phi \end{bmatrix} = \begin{pmatrix} \cos\phi & \sin\phi \\ -\sin\phi & \cos\phi \end{pmatrix}^{\mathrm T} , \end{equation}
where we embrace the rotation matrix into brackets to emphasize that this matrix acts on column vectors upon multiplication from left. Since matrices can operate either on column vectors from left or on row vectors from right, we distinguish these matrix operators by embracing matrices either in brackets (when acting on column vectors) or in parentheses (when acting on row vectors). Note that row rotation matrix is transposed of the column rotation matrix.

Actually, the deriation of rotation matrix above is euivalent to multiplication of vector z = OP on complex plane ℂ by complex number \( \displaystyle \ e^{{\bf j}\theta} .\ \) In order to implement this approach, you need to recall complex numbers.

We can derive the rotation matrix \eqref{EqPlane.2} by considering transformation of base vectors i = (0, 1) and j = (0, 1). Moreover, rotation matrices are orthogonal matrices (A−1 = AT) with a determinant equals to 1.    

Example 1: For illustration of rotations, we consider a unit square with verteces O(0, 0), A(1, 0), B(1, 1), and C(0, 1). Suppose we want to find coordinates of these points in a new system of coordinates obtained by rotation with respect to the origin by 60° (= π/3). So we apply formula (1) to each vertex. First, we evaluate elements of the corresponding rotation matrix \[ \cos\left( \frac{\pi}{3} \right) = \frac{1}{2}, \qquad \sin\left( \frac{\pi}{3} \right) = \frac{\sqrt{3}}{2}. \]
Cos[Pi/3]
1/2
Sin[Pi/3]
Sqrt[3]/2
Therefore, the rotation matrix is \[ {\bf R}\left( \frac{\pi}{3} \right) = \begin{bmatrix} \frac{1}{2} & \frac{\sqrt{3}}{2} \\ -\frac{\sqrt{3}}{2} & \frac{1}{2} \end{bmatrix} = \begin{pmatrix} \frac{1}{2} & -\frac{\sqrt{3}}{2} \\ \frac{\sqrt{3}}{2} & \frac{1}{2} \end{pmatrix} \] Then we apply formula (1) and obtain \begin{align*} \begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 0 & 0 \end{bmatrix} \,{\bf R} = \begin{bmatrix} 0 & 0 \end{bmatrix} , \\ \begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 1 & 0 \end{bmatrix} \,{\bf R} = \begin{bmatrix} \frac{1}{2} & -\frac{\sqrt{3}}{2} \end{bmatrix} \\ \begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 1 & 1 \end{bmatrix} \,{\bf R} = \begin{bmatrix} \frac{1+ \sqrt{3}}{2} & -\frac{1-\sqrt{3}}{2} \end{bmatrix} , \\ \begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 0 & 1 \end{bmatrix} \,{\bf R} = \begin{bmatrix} \frac{\sqrt{3}}{2} & \frac{1}{2}\end{bmatrix} . \end{align*}
R = {{1/2, Sqrt[3]/2}, {-Sqrt[3]/2, 1/2}};
R . {1, 0}
{1/2, -(Sqrt[3]/2)}
R . {1, 1}
{1/2 + Sqrt[3]/2, 1/2 - Sqrt[3]/2}
R . {0, 1}
{Sqrt[3]/2, 1/2}
We plot rotation of the frame:
Roger plots

Now we rotate this unit square by 60°. We can use transposed matrix from the previous part as the rotation matrix. \begin{align*} \begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 0 & 0 \end{bmatrix} \,{\bf R}^{\mathrm T} = \begin{bmatrix} 0 & 0 \end{bmatrix} , \\ \begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 1 & 0 \end{bmatrix} \,{\bf R} = \begin{bmatrix} \frac{1}{2} & \frac{\sqrt{3}}{2} \end{bmatrix} \\ \begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 1 & 1 \end{bmatrix} \,{\bf R}^{\mathrm T} = \begin{bmatrix} \frac{1- \sqrt{3}}{2} & -\frac{1+\sqrt{3}}{2} \end{bmatrix} , \\ \begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 0 & 1 \end{bmatrix} \,{\bf R}^{\mathrm T} = \begin{bmatrix} -\frac{\sqrt{3}}{2} & \frac{1}{2}\end{bmatrix} . \end{align*}

Transpose[R . {1, 0}
{1/2, Sqrt[3]/2}
Transpose[R . {1, 1}
{1/2 - Sqrt[3]/2, 1/2 + Sqrt[3]/2}
Transpose[R . {0, 1}
{-(Sqrt[3]/2), 1/2}
Roger plots
   ■
End of Example 1
Observarion: Rotations in ℝ² are represented by matrices of the group 50(2). However, there ae two kinds of rotations: rotation of the coordinate frame and rotation of a point(vector). Note that the rotation operator (or matrix) for the one case is simply the transpose of the rotation operator for the other case.

Compositions

We now consider a case when one rotation is followed by another one. Suppose a rotation of the initial coordinate frame (points fixed) through an angle α is followed by a rotation of the resulting coordinate frame through an angle β. Clearly the result is a rotation of the initial coordinate frame (points fixed) through an angle α + β, as illustrated in Figure 4.
rx = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{-0.3, 0}, {2*1.3, 0}}]}]; ary = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, -0.3}, {0, 2*1.3}}]}]; arx1 = Graphics[{Blue, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {Sqrt[3], 1}}]}]; ary1 = Graphics[{Blue, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {-1, Sqrt[3]}}]}]; arx2 = Graphics[{Purple, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {1, Sqrt[3]}}]}]; ary2 = Graphics[{Purple, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {-Sqrt[3], 1}}]}]; angle = Graphics[{Black, Thick, Circle[{0, 0}, 1.4, {0, Pi/3}]}]; arr1 = Graphics[{Black, Thickness[0.01], Arrowheads[0.06], Arrow[{{0.92, 1.05}, {0.7, 1.23}}]}]; arr2 = Graphics[{Black, Thickness[0.01], Arrowheads[0.06], Arrow[{{1.25, 0.6}, {1.2, 0.7}}]}]; txt = Graphics[{Black, Text[Style[Subscript[x, 2], FontSize -> 18, Bold], {0.95, 2.0}], Text[Style["x-axis", FontSize -> 18, Bold], {2.2, 0.3}], Text[Style[Subscript[x, 1], FontSize -> 18, Bold], {1.9, 1.3}], Text[Style["y-axis", FontSize -> 18, Bold], {0.44, 2.55}], Text[Style[Subscript[y, 1], FontSize -> 18, Bold], {-1, 1.9}], Text[Style[Subscript[y, 2], FontSize -> 18, Bold], {-1.5, 1.16}]}]; txt2 = Graphics[{Black, Text[Style[ \[Beta], FontSize -> 16, Bold], {0.75, 0.75}], Text[Style[\[Alpha], FontSize -> 16, Bold], {1.2, 0.25}]}]; Show[arx, ary, arx1, ary1, arx2, ary2, angle, arr1, arr2, txt, txt2]
Figure 4: Composition of two rotation

We consider a sequence of rotations when the initial coordinate frame (points fixed) through an angle α is followed by a rotation of the resulting coordinate frame through an angle β. Clearly the result is a rotation of the initial coordinate system (points fixed) through an angle of α + β, as illustratrated in Figure 4. The corresponding matrices of rotation are

\[ {\bf R}_{\alpha} = \begin{bmatrix} \cos\alpha & \sin\alpha \\ -\sin\alpha & \cos\alpha \end{bmatrix} , \qquad {\bf R}_{\beta} = \begin{bmatrix} \cos\beta & \sin\beta \\ -\sin\beta & \cos\beta \end{bmatrix} \]
that act on column vctors from left:
\[ \begin{bmatrix} x_1 \\ y_1 \end{bmatrix} = {\bf R}_{\alpha} \begin{bmatrix} x \\ y \end{bmatrix} , \qquad \begin{bmatrix} x_2 \\ y_2 \end{bmatrix} = {\bf R}_{\beta} \begin{bmatrix} x_1 \\ y_1 \end{bmatrix} . \]
Then, using rules of matrix algebra, we may write
\begin{align*} {\bf v}_2 &= {\bf R}_{\beta} {\bf v}_1 \\ &= {\bf R}_{\beta} \left( {\bf R}_{\alpha} {\bf v} \right) \\ &= \left( {\bf R}_{\beta} {\bf R}_{\alpha} \right) {\bf v} . \end{align*}
where \( \displaystyle \quad {\bf v}_2 = \begin{bmatrix} x_2 \\ y_2 \end{bmatrix} , \quad {\bf v}_1 = \begin{bmatrix} x_1 \\ y_1 \end{bmatrix} , \quad {\bf v} = \begin{bmatrix} x \\ y \end{bmatrix} . \quad \) This equation shows that the rotation operator for the sequence of rotations is exactly the product of the two individual rotation operators Rβ and Rα. Multiplication of these two rotation matrices yields
\begin{align*} {\bf R}_{\beta} {\bf R}_{\alpha} &= \begin{bmatrix} \cos\beta & \sin\beta \\ -\sin\beta & \cos\beta \end{bmatrix} \begin{bmatrix} \cos\alpha & \sin\alpha \\ -\sin\alpha & \cos\alpha \end{bmatrix} \\ &= \begin{bmatrix} \cos \left( \alpha + \beta\right) & \sin \left( \alpha + \beta \right) \\ -\sin \left( \alpha + \beta \right) & \cos \left( \alpha + \beta \right) \end{bmatrix} = {\bf R}_{\alpha + \beta} \end{align*}
as Mathematica confirms.
{{Cos[b], Sin[b]}, {-Sin[b], Cos[b]}} . {{Cos[a], Sin[a]}, {-Sin[a], Cos[a]}};
TrigReduce[%]
{{Cos[a + b], Sin[a + b]}, {-Sin[a + b], Cos[a + b]}}
Actually, you don't need any software to verify this identity, you just need to recall trigonometric identities
\begin{align*} \sin \left( \alpha + \beta \right) &= \sin\alpha\, \cos\beta + \cos\alpha\, \sin\beta , \\ \cos \left( \alpha + \beta \right) &= \cos\alpha \,\cos\beta - \sin\alpha \,\sin\beta . \end{align*}
We notice immediately that this final matrix does not depend on the order of matrices in their multiplication. It is just the rotation operator representing a rotation of the coordinate frame through an angle α + β, while the points (or vectors) remain fixed.

Examples

rotat\[Theta] = house2[.5 {{Sqrt[3], -1}, {1, Sqrt[3]}}, "Rotation by angle \[Pi]/6"]; Grid[{{"House to be\nTransformed", "Transform\nMatrix", "Transformed\nHouse"}, {house[], HoldForm[1/2 MatrixForm[{{Sqrt[3] - 1}, {1, Sqrt[3]}}]], rotat\[Theta]}}, Frame -> All]

House in quadrant I.
      \[ \frac{1}{2} \begin{bmatrix} \sqrt{3} & -1 \\ 1 & \sqrt{3} \end{bmatrix} \]      
Rotation by angle π/6.

rotat\[Theta]2 = house2[.5 {{-Sqrt[3], -1}, {1, -Sqrt[3]}}, "Rotation by angle 5\[Pi]/6"]; Grid[{{"House to be\nTransformed", "Transform\nMatrix", "Transformed\nHouse"}, {house[], HoldForm[1/2 MatrixForm[{{-Sqrt[3] - 1}, {1, -Sqrt[3]}}]], rotat\[Theta]2}}, Frame -> All]

House in quadrant I.
      \[ \frac{1}{2} \begin{bmatrix} -\sqrt{3} & -1 \\ 1 & -\sqrt{3} \end{bmatrix} \]      
Rotation by angle 5π/6.

rotat\[Theta]3 = house2[(*.5*) {{0, -1}, {1, 0}}, "Rotation by 270\[Degree] clockwise"]; Grid[{{"House to be\nTransformed", "Transform\nMatrix", "Transformed\nHouse"}, {house[], HoldForm[(*1/2*) MatrixForm[{{0, -1}, {1, 0}}]], rotat\[Theta]3}}, Frame -> All]

House in quadrant I.
      \[ \frac{1}{2} \begin{bmatrix} 0 & -1 \\ 1 & \phantom{-}0 \end{bmatrix} \]      
Rotation by 270° clockwise.

rotat\[Theta]4 = house2[(*.5*) {{0, 1}, {-1, 0}}, "Rotation by 270\[Degree]\n counterclockwise"]; Grid[{{"House to be\nTransformed", "Transform\nMatrix", "Transformed\nHouse"}, {house[], HoldForm[(*1/2*) MatrixForm[{{0, 1}, {-1, 0}}]], rotat\[Theta]4}}, Frame -> All]

House in quadrant I.
      \[ \frac{1}{2} \begin{bmatrix} \phantom{-}0 & 1 \\ -1 & 0 \end{bmatrix} \]      
Rotation by 270° counterclockwise.

 

Summary


Type       angle θ       matrix
Rotation             \( \displaystyle \begin{bmatrix} 1&0 \\ 0&1 \end{bmatrix} \)
Rotation       30° = π/6       \( \displaystyle \frac{1}{2} \begin{bmatrix} \sqrt{3}&-1 \\ 1&\sqrt{3} \end{bmatrix} \)
Rotation       45° = π/4       \( \displaystyle \frac{\sqrt{2}}{2} \begin{bmatrix} 1&-1 \\ 1&1 \end{bmatrix} \)
Rotation       60° = π/3       \( \displaystyle \frac{1}{2} \begin{bmatrix} 1&-\sqrt{3} \\ \sqrt{3}&1 \end{bmatrix} \)
Rotation       90° = π/2       \( \displaystyle \begin{bmatrix} 0&1 \\ 1&0 \end{bmatrix} \)
Rotation       120° = 2π/3       \( \displaystyle \frac{1}{2} \begin{bmatrix} -1&-\sqrt{3} \\ \sqrt{3}&-1 \end{bmatrix} \)
Rotation       135° = 3π/4       \( \displaystyle \frac{\sqrt{2}}{2} \begin{bmatrix} -1&-1 \\ 1&-1 \end{bmatrix} \)
Rotation       150° = 5π/6       \( \displaystyle \frac{1}{2} \begin{bmatrix} -\sqrt{3}&-1 \\ 1&-\sqrt{3} \end{bmatrix} \)
Rotation       180° = π       \( \displaystyle \begin{bmatrix} -1&0 \\ 0&-1 \end{bmatrix} \)

   

Example 2: Instead of rotating points, we consider the three paddled flower and rotate it with respect to a new center, not necessarily the origin.
(*Create ParametricPlot*)
F = (2*Cos[3*t] + 3)*Cos[t];
G = (2*Cos[3*t] + 3)*Sin[t];
origPlot = ParametricPlot[{F, G}, {t, 0, 2*Pi}, PlotStyle -> {Blue, Thickness[0.01]}]
Define Rotation Matrix R for counterclockwise rotation of 1.15 radians
R = {{Cos[a], -Sin[a]}, {Sin[a], Cos[a]}} /. a -> 1.15
Define Point P on original curve
P = {{F}, {G}};
Define point to serve as center of the rotation
center = {{-2}, {-3}};
Define new point Q obtained by rotating P counterclockwise by 1.15 radians about the center
Q = R . (P - center) + center;
Create a new ParametricPlot, now defined by Q and show the center \ with market "+"
rotPlot = ParametricPlot[Flatten[Q], {t, 0, 2*Pi}, PlotStyle -> {Purple, Thickness[0.01]}];
centerPlot = ListPlot[{Flatten[center]}, PlotMarkers -> {"+", Medium}];
sho2 = Show[rotPlot, centerPlot, PlotRange -> All]

Three peddled flower.
           
Rotation by 1.15 radians counterclockwise.

An alternative method

F = (2*Cos[3*t] + 3)*Cos[t];
G = (2*Cos[3*t] + 3)*Sin[t];
origPlot = ParametricPlot[{F, G}, {t, 0, 2*Pi}, PlotStyle -> {Blue, Thickness[0.01]}];
Use the built - in function to generate the rotation matrix
R = RotationMatrix[1.15];
P = {F, G}; center = {-2, -3}; Q = R . (P - center) + center; (* We don't need to flatten Q here *)
rotPlot2 = ParametricPlot[Q, {t, 0, 2*Pi}, PlotStyle -> {Purple, Thickness[0.01]}]; centerPlot2 = ListPlot[{center}, PlotMarkers -> {"+", Medium}]; sho3 = Show[rotPlot2, centerPlot2, PlotRange -> All]

The latter figure clearly depicts the rotation of the parametric curve. Now let us animate the rotation so all intermediate curves will be visible.

F = (2*Cos[3*t] + 2)*1*Cos[t];
G = (2*Cos[3*t] + 2)*1*Sin[t];
origPlot = ParametricPlot[{F, G}, {t, 0, 2*Pi}, PlotStyle -> {Blue, Thickness[0.01]}];
P = {{F}, {G}};
R = {{Cos[a], -Sin[a]}, {Sin[a], Cos[a]}};
center = {{-2}, {-3}};
QP = R.(P - center) + center;
centerPlot2 = Graphics[{Red, PointSize -> Medium, Point[{-2, -3}]}];
rotPlot = ParametricPlot[Flatten[Q], {t, 0, 2*Pi}, PlotStyle -> {Purple, Thickness[0.01]}]; anim2 = Animate[QPE = Evaluate[QP /. {a -> theta}]; QPEPlot = ParametricPlot[Flatten[QPE], {t, 0, 2*Pi}, PlotStyle -> {Black, Thickness[0.01]}]; Show[origPlot, QPEPlot, rotPlot, centerPlot2, PlotRange -> {{-10, 10}, {-10, 10}}], {{theta, 0, a}, 0, 2*Pi, Pi/16}, AnimationRepetitions -> Infinity ]
Animation of rotation
   ■
End of Example 2
   
Example 2: We provide a geometrical "proof" of the Pythagorus theorem and as a side effect demonstrate usefulness of computer solve for its illustration. So we start with a right triangle

Thriangle.
     
tri = Triangle[{{0, 0}, {4, 0}, {0, 3}}]; triRt = Graphics[Style[tri, Opacity[.3], Blue], Axes -> True, GridLines -> Automatic]

Then we attach a red 5 x 5 square to the hypotenuse of the triangle:

Thriangle with a square.
     
angle = ArcTan[-(3/4)]; redSq = Graphics[{LightRed, Translate[ Rotate[Rectangle[{0, 0}, {5, 5}], angle, {0, 0}], {4, 6} - {5 Cos[angle], -5 Sin[angle]}]}]; Show[triRt, redSq]

Here is code that produces a 5 x 5 grid of small boxes
vLines = Table[ {Dashing[{0.02, 0.02}], Line[{{i, 0}, {i, 5}}]}, {i, 1, 4}]; hLines = Table[ {Dashing[{0.02, 0.02}], Line[{{0, i}, {5, i}}]}, {i, 1, 4}]; grid = Graphics[ Join[vLines, hLines], Axes -> True, PlotRange -> {{0, 5}, {0, 5}}, AspectRatio -> 1 ];
Showing them together...
Show[triRt, redSq, grid]
Thriangle with a square. and grid

We need the grid to occupy the 5x5 red box. Below this is done in three steps. First we define the center of the grid

center = {2.5, 2.5};
Now we rotate the grid using RotationTransform on the individual lines
rotatedDashedLinesVertical = Table[ {Dashing[{0.02, 0.02}], Line[RotationTransform[angle, center] /@ {{i, 0}, {i, 5}}]}, {i, 1, 4}]; rotatedDashedLinesHorizontal = Table[ {Dashing[{0.02, 0.02}], Line[RotationTransform[angle, center] /@ {{0, i}, {5, i}}]}, {i, 1, 4}];
rotLines = Join[rotatedDashedLinesVertical, rotatedDashedLinesHorizontal]; Show[triRt, redSq, Graphics[rotLines, Axes -> True, PlotRange -> {{0, 5}, {0, 5}}, AspectRatio -> 1 ]]
Thriangle with a square. and rotated grid

Now, using Translate, we move the grid northeast until it is inside the red square.

tranLines = Graphics[ Translate[rotLines, {1, 1}], Axes -> True, PlotRange -> {{0, 5}, {0, 5}}, AspectRatio -> 1 ]; Show[triRt, redSq, tranLines]
Thriangle with a square. and rotated grid

Note that using the coordinates indicated by the gridlines we can describe the beginning and ending positions of the square of dashed lines. It seems to me that there may be a matrix operation you might see that I do not which would simplify this.    ■

End of Example 2

Reflections

A rotation in the plane is closely related to reflection operation---a transformation that produces a mirror image of an object relative to anaxis of reflection (which is a fixed point for this transformation). Every rotation by angle θ can be formed by a pair of reflections. Suppose we have two lines (through the origin) L₁ and L₂ having angle θ between them. An arbitrary point P on the plane can be rotated by angle 2θ by reflecting P with respect to L₁ into P₁, which then is reflected into point P₂ with respect to line L₂.

\[ \mbox{Ref}(\theta )\, \mbox{Ref}(\phi ) = \mbox{Rotation}( 2\phi - 2\theta ) . \]
   
Example 3:    ■
End of Example 3

Let a reflection about a line L through the origin which makes an angle θ with the abscissa (x-axis) be denoted as Ref(θ). Suppose that these reflections operate on all points on the plane, and let these points be represented by position vectors. Then a reflection can be acomplished by applying orthogonal matrix (from left on column vectors or from right on row vectors) that performs mirrowing about the line that passes through the origin and is perpendicular to the unit vector \( \displaystyle \ \hat{\bf n} = \left( n_x, n_y \right) \ \) is given by

\[ \mbox{Ref}(\theta ) = \begin{bmatrix} 1&0 \\ 0&1 \end{bmatrix} - 2 \begin{bmatrix} n_x^2 & n_x n_y \\ n_x n_y & n_y^2 \end{bmatrix} . \]
Since axis of reflection goes through the origin, every vector in &Riof;² can be separated in two parts:
\[ {\bf v} = {\bf v}_{\|} + {\bf v}_{\perp} , \]
where v is the projection of v on the axis and v is perpendicular to the axis. Then action of reflection operation on any vector can be expressed as
\[ \mbox{Ref}({\bf v}) = {\bf v}_{\|} - {\bf v}_{\perp} ,\qquad {\bf v} = {\bf v}_{\|} + {\bf v}_{\perp} . \]
If the unit vector along the axis of reflection is given as \( \displaystyle \ \hat{\bf n} = \left( \cos\theta , -\sin\theta \right) , \ \) we obtain
\begin{equation} \label{EqReflection.1} \mbox{Ref}(\theta ) = \begin{bmatrix} \cos (2\theta ) & \sin (2\theta ) \\ \sin (2\theta ) & - \cos (2\theta ) \end{bmatrix} . \end{equation}

Using Eq.\eqref{EqReflection.1}, we derive

Type       angle θ       matrix
Reflection             \( \displaystyle \begin{bmatrix} 1&0 \\ 0&-1 \end{bmatrix} \)
Reflection       30° = π/6       \( \displaystyle \frac{1}{2} \begin{bmatrix} 1&\sqrt{3} \\ 1\sqrt{3} & -1 \end{bmatrix} \)
Reflection       45° = π/4       \( \displaystyle \begin{bmatrix} 0&1 \\ 1&0 \end{bmatrix} \)
Reflection       60° = π/3       \( \displaystyle \frac{1}{2} \begin{bmatrix} -1&\sqrt{3} \\ \sqrt{3}&1 \end{bmatrix} \)
Reflection       90° = π/2       \( \displaystyle \begin{bmatrix} -1&0 \\ 0&1 \end{bmatrix} \)
Reflection       120° = 2π/3       \( \displaystyle \frac{1}{2} \begin{bmatrix} -1&\sqrt{3} \\ \sqrt{3} &1 \end{bmatrix} \)
Reflection       135° = 3π/4       \( \displaystyle \begin{bmatrix} 0&-1 \\ -1&0 \end{bmatrix} \)
Reflection       150° = 5π/6       \( \displaystyle \frac{1}{2} \begin{bmatrix} 1&-\sqrt{3} \\ \sqrt{3}&-1 \end{bmatrix} \)
Reflection       180° = π       \( \displaystyle \begin{bmatrix} 1&0 \\ 0&1 \end{bmatrix} \)

   
Example 4:    ■
End of Example 4

  1. Consider the point P(2,1). Without using matrix multiplication, find the resulting point undr rotation about the origin by angles π/2 and π/4.
  2. Given a point P on the plane ℝ², let Q be the point corresponding to the rotation of P in counterclockwise direction about the origin through an angle θ. Let R be the point corresponding to the rotation of Q in counterclockwise direction about the origin through an angle ϕ. Verify that \[ \mathbf{R}[\phi ]\,\mathbf{R}[\theta ] = \mathbf{R}[\phi + \theta ] , \] where R[θ] is the rotation matrix according to formula (1). Does it mean that products of rotation matrices are commutative?
  3. Find the coordinates of the point Q corresponding to the point P(3, 2) that has been rotated in counterclockwise direction about the origin through an angle θ = 2π/3.

  1. Anton, Howard (2005), Elementary Linear Algebra (Applications Version) (9th ed.), Wiley International
  2. Dunn, F. and Parberry, I. (2002). 3D math primer for graphics and game development. Plano, Tex.: Wordware Pub.
  3. Foley, James D.; van Dam, Andries; Feiner, Steven K.; Hughes, John F. (1991), Computer Graphics: Principles and Practice (2nd ed.), Reading: Addison-Wesley, ISBN 0-201-12110-7
  4. Matrices and Linear Transformations
  5. Pen and Paper Science
  6. Rogers, D.F., Adams, J. A., Mathematical Elements for Computer Graphics, McGraw-Hill Science/Engineering/Math, 1989.