Tutorials › Linear Algebra › Rotation Matrices in R^2

Orthogonal Matrices and Isometries · Tutorial 714 of 1000

Rotation Matrices in R^2

Learn how a planar rotation becomes a matrix, why that matrix is orthogonal with determinant one, and how to compute rotations and their compositions.

Intermediate 10 min read

What You'll Learn

  • Derive the matrix for a counterclockwise rotation through an arbitrary angle.
  • Interpret the columns of a rotation matrix as the images of the standard basis vectors.
  • Verify directly that a rotation matrix is orthogonal and has determinant one.
  • Multiply rotation matrices and connect the product to addition of angles.
  • Calculate rotated vectors and check the results using lengths.
  • Recognize and correct the sign error that reverses the direction of rotation.

From a Turn in the Plane to a Matrix

A rotation about the origin changes the direction of a vector without changing its length. To describe the rotation by a matrix, we must fix a direction convention: throughout, a positive angle means a counterclockwise turn. Coordinates are measured in the standard basis \(\mathbf{e}_1=(1,0)\) and \(\mathbf{e}_2=(0,1)\). Thus a vector pointing along the positive horizontal axis turns upward when rotated through a small positive angle.

Let \(\theta\in\mathbb{R}\). A rotation through angle \(\theta\) sends a nonzero vector of length \(r\) and direction angle \(\phi\) to the vector of the same length and direction angle \(\phi+\theta\). In coordinates, the starting vector is \(r(\cos\phi,\sin\phi)\), while the rotated vector is \(r(\cos(\phi+\theta),\sin(\phi+\theta))\). The zero vector remains fixed. This describes rotation about the origin, not a rotation about a different centre.

Definition: The counterclockwise rotation through angle \(\theta\) is the map \(T_\theta:\mathbb{R}^2\to\mathbb{R}^2\) that turns each vector through angle \(\theta\), with positive angles measured counterclockwise, while preserving its length. Its matrix in the standard basis is denoted by \(\mathbf{R}_\theta\).

The columns of a matrix are the images of the standard basis vectors under its associated linear map. The vector \(\mathbf{e}_1\) has direction angle \(0\), so its image under \(T_\theta\) is \((\cos\theta,\sin\theta)\). The vector \(\mathbf{e}_2\) has direction angle \(\frac{\pi}{2}\), so its image is \((\cos(\theta+\frac{\pi}{2}),\sin(\theta+\frac{\pi}{2}))=(-\sin\theta,\cos\theta)\). These two images give the columns of the rotation matrix.

Rotation matrix: For every \(\theta\in\mathbb{R}\), the matrix of the counterclockwise rotation through angle \(\theta\), in standard coordinates, is $$ \mathbf{R}_\theta= \begin{bmatrix} \cos\theta&-\sin\theta\\ \sin\theta&\cos\theta \end{bmatrix}. $$

Here is a direct check that this matrix does perform the stated rotation. Write a nonzero vector as \(\mathbf{x}=(r\cos\phi,r\sin\phi)^\top\), where \(r>0\). Multiplying by the proposed matrix gives $$ \mathbf{R}_\theta\mathbf{x} = \begin{bmatrix} r(\cos\theta\cos\phi-\sin\theta\sin\phi)\\ r(\sin\theta\cos\phi+\cos\theta\sin\phi) \end{bmatrix} = \begin{bmatrix} r\cos(\phi+\theta)\\ r\sin(\phi+\theta) \end{bmatrix}. $$ The last equality uses the angle-addition identities for sine and cosine. The result has length \(r\) and direction angle \(\phi+\theta\), as required. For \(\mathbf{x}=\mathbf{0}\), matrix multiplication also gives \(\mathbf{R}_\theta\mathbf{0}=\mathbf{0}\).

Orthogonality and Determinant

A real \(2\times2\) matrix is orthogonal when its transpose times the matrix equals the identity matrix. For a rotation matrix, this property follows directly from the trigonometric identity \(\cos^2\theta+\sin^2\theta=1\).

Theorem: For every real angle \(\theta\), the rotation matrix \(\mathbf{R}_\theta\) is orthogonal and has determinant \(1\).

Proof. Put \(c=\cos\theta\) and \(s=\sin\theta\), so \(\mathbf{R}_\theta=\begin{bmatrix}c&-s\\s&c\end{bmatrix}\) and \(\mathbf{R}_\theta^\top=\begin{bmatrix}c&s\\-s&c\end{bmatrix}\). Multiplication gives $$ \mathbf{R}_\theta^\top\mathbf{R}_\theta = \begin{bmatrix} c^2+s^2&-cs+sc\\ -sc+cs&s^2+c^2 \end{bmatrix} = \begin{bmatrix}1&0\\0&1\end{bmatrix} =\mathbf{I}_2. $$ Therefore the matrix is orthogonal. Its determinant is $$ \det\mathbf{R}_\theta=c\cdot c-(-s)\cdot s=c^2+s^2=1. $$ Both conclusions hold for every real \(\theta\), since \(c^2+s^2=1\) for every real angle. \(\square\)

Orthogonality means that the rotation preserves inner products and lengths. In particular, \(\|\mathbf{R}_\theta\mathbf{x}\|=\|\mathbf{x}\|\) for every \(\mathbf{x}\in\mathbb{R}^2\). The determinant \(1\), rather than \(-1\), records that the rotation preserves orientation. These properties are useful checks on a calculation, but they do not replace carrying out the matrix-vector multiplication when an image is required.

Worked Example: Rotate a Vector Through \(\frac{\pi}{3}\)

Find the image of \(\mathbf{x}=(2,-1)^\top\) under a counterclockwise rotation through \(\frac{\pi}{3}\), and check its length.

Use \(\cos\frac{\pi}{3}=\frac12\) and \(\sin\frac{\pi}{3}=\frac{\sqrt{3}}2\) to form the matrix: $$ \mathbf{R}_{\pi/3} = \begin{bmatrix} \frac12&-\frac{\sqrt{3}}2\\ \frac{\sqrt{3}}2&\frac12 \end{bmatrix}. $$ Then multiply: $$ \mathbf{R}_{\pi/3}\mathbf{x} = \begin{bmatrix} \frac12&-\frac{\sqrt{3}}2\\ \frac{\sqrt{3}}2&\frac12 \end{bmatrix} \begin{bmatrix}2\\-1\end{bmatrix} = \begin{bmatrix} 1+\frac{\sqrt{3}}2\\ \sqrt{3}-\frac12 \end{bmatrix}. $$

Check: The input has squared length \(2^2+(-1)^2=5\). The output has squared length $$ \left(1+\frac{\sqrt{3}}2\right)^2+ \left(\sqrt{3}-\frac12\right)^2 = \left(\frac74+\sqrt{3}\right)+ \left(\frac{13}4-\sqrt{3}\right) =5. $$ The image therefore has the same length as the input, as a rotation should.

Composing Rotations Adds Their Angles

A product of matrices represents successive actions: in \(\mathbf{R}_\phi\mathbf{R}_\theta\), the right-hand matrix acts first. For rotations about the same origin, the two turns combine into one turn whose angle is the sum. The matrix identity below establishes this fact directly.

Theorem: For all \(\theta,\phi\in\mathbb{R}\), $$ \mathbf{R}_\phi\mathbf{R}_\theta=\mathbf{R}_{\theta+\phi}. $$

Proof. Write \(c_\alpha=\cos\alpha\) and \(s_\alpha=\sin\alpha\) for any angle \(\alpha\). Multiplying the two matrices gives $$ \mathbf{R}_\phi\mathbf{R}_\theta = \begin{bmatrix} c_\phi c_\theta-s_\phi s_\theta& -(c_\phi s_\theta+s_\phi c_\theta)\\ s_\phi c_\theta+c_\phi s_\theta& c_\phi c_\theta-s_\phi s_\theta \end{bmatrix}. $$ By the angle-addition identities, \(c_\phi c_\theta-s_\phi s_\theta=\cos(\theta+\phi)\) and \(s_\phi c_\theta+c_\phi s_\theta=\sin(\theta+\phi)\). Also, \(c_\phi s_\theta+s_\phi c_\theta=\sin(\theta+\phi)\). Substitution makes the product exactly $$ \begin{bmatrix} \cos(\theta+\phi)&-\sin(\theta+\phi)\\ \sin(\theta+\phi)&\cos(\theta+\phi) \end{bmatrix} =\mathbf{R}_{\theta+\phi}. $$ Thus the equality holds for every pair of real angles. \(\square\)

Some useful consequences follow by choosing particular angles. A turn through \(0\) gives \(\mathbf{R}_0=\mathbf{I}_2\). A turn through \(-\theta\) undoes a turn through \(\theta\), since \(\mathbf{R}_{-\theta}\mathbf{R}_\theta=\mathbf{R}_0=\mathbf{I}_2\). And adding a full turn does not change the matrix, because sine and cosine have period \(2\pi\): \(\mathbf{R}_{\theta+2\pi}=\mathbf{R}_\theta\).

Worked Example: Compose Two Rotations

Calculate \(\mathbf{R}_{\pi/6}\mathbf{R}_{\pi/3}\), then apply the product to \(\mathbf{x}=(1,2)^\top\). The right-hand matrix acts first, so the vector is first rotated through \(\frac{\pi}{3}\), then through \(\frac{\pi}{6}\).

Using the exact values of sine and cosine, $$ \mathbf{R}_{\pi/6} = \begin{bmatrix}\frac{\sqrt{3}}2&-\frac12\\\frac12&\frac{\sqrt{3}}2\end{bmatrix}, \qquad \mathbf{R}_{\pi/3} = \begin{bmatrix}\frac12&-\frac{\sqrt{3}}2\\\frac{\sqrt{3}}2&\frac12\end{bmatrix}. $$ Their product is $$ \mathbf{R}_{\pi/6}\mathbf{R}_{\pi/3} = \begin{bmatrix} \frac{\sqrt{3}}4-\frac{\sqrt{3}}4& -\frac34-\frac14\\ \frac14+\frac34& -\frac{\sqrt{3}}4+\frac{\sqrt{3}}4 \end{bmatrix} = \begin{bmatrix}0&-1\\1&0\end{bmatrix} =\mathbf{R}_{\pi/2}. $$ This agrees with the angle sum \(\frac{\pi}{3}+\frac{\pi}{6}=\frac{\pi}{2}\).

Applying the product to \(\mathbf{x}\) gives $$ \begin{bmatrix}0&-1\\1&0\end{bmatrix} \begin{bmatrix}1\\2\end{bmatrix} = \begin{bmatrix}-2\\1\end{bmatrix}. $$ To check by applying the rotations one at a time, the first image is $$ \mathbf{R}_{\pi/3}\mathbf{x} = \begin{bmatrix}\frac12-\sqrt{3}\\\frac{\sqrt{3}}2+1\end{bmatrix}. $$ Rotating this result through \(\frac{\pi}{6}\), its first coordinate becomes $$ \frac{\sqrt{3}}2\left(\frac12-\sqrt{3}\right) -\frac12\left(\frac{\sqrt{3}}2+1\right) = \frac{\sqrt{3}}4-\frac32-\frac{\sqrt{3}}4-\frac12=-2, $$ and its second coordinate becomes $$ \frac12\left(\frac12-\sqrt{3}\right) +\frac{\sqrt{3}}2\left(\frac{\sqrt{3}}2+1\right) = \frac14-\frac{\sqrt{3}}2+\frac34+\frac{\sqrt{3}}2=1. $$ The sequential calculation gives the same image \((-2,1)^\top\).

Worked Example: Rotate a Vector on the Horizontal Axis

Find the image of \(\mathbf{v}=(3,0)^\top\) under a counterclockwise rotation through \(\frac{2\pi}{3}\).

Since \(\cos\frac{2\pi}{3}=-\frac12\) and \(\sin\frac{2\pi}{3}=\frac{\sqrt{3}}2\), $$ \mathbf{R}_{2\pi/3} = \begin{bmatrix} -\frac12&-\frac{\sqrt{3}}2\\ \frac{\sqrt{3}}2&-\frac12 \end{bmatrix}. $$ Multiplying by \(\mathbf{v}\) gives $$ \mathbf{R}_{2\pi/3}\mathbf{v} = \begin{bmatrix} -\frac12&-\frac{\sqrt{3}}2\\ \frac{\sqrt{3}}2&-\frac12 \end{bmatrix} \begin{bmatrix}3\\0\end{bmatrix} = \begin{bmatrix}-\frac32\\\frac{3\sqrt{3}}2\end{bmatrix}. $$ Check: the input length is \(3\), and the output has squared length \(\frac94+\frac{27}4=9\), hence length \(3\). Its direction is in the second quadrant, consistent with turning the positive horizontal axis counterclockwise by \(\frac{2\pi}{3}\).

Common Sign Error

The negative sign in the upper-right entry is essential when positive angles mean counterclockwise turns. A common incorrect matrix is $$ \begin{bmatrix}\cos\theta&\sin\theta\\\sin\theta&\cos\theta\end{bmatrix}. $$ For \(\theta=\frac{\pi}{2}\), this incorrect expression becomes \(\begin{bmatrix}0&1\\1&0\end{bmatrix}\), which sends \(\mathbf{e}_1=(1,0)^\top\) to \((0,1)^\top\) but sends \(\mathbf{e}_2=(0,1)^\top\) to \((1,0)^\top\). That is not a quarter-turn: the second basis vector should move to \((-1,0)^\top\). The correct calculation is $$ \mathbf{R}_{\pi/2} = \begin{bmatrix}0&-1\\1&0\end{bmatrix}, \qquad \mathbf{R}_{\pi/2}\mathbf{e}_2 = \begin{bmatrix}-1\\0\end{bmatrix}. $$ Testing the images of the two standard basis vectors is an efficient way to catch a sign error before using a matrix on other vectors.

When calculating compositions, also keep track of the order of multiplication. In \(\mathbf{R}_\phi\mathbf{R}_\theta\), the angle \(\theta\) acts first, but the resulting total angle is \(\theta+\phi\). Since addition of real numbers is commutative, the two rotation matrices commute; this does not change the rule that the right-hand factor acts first on a vector.

Check Your Understanding

Use the matrix formula and show enough calculation to verify each result.

  1. Write the matrix for a counterclockwise rotation through \(\frac{\pi}{4}\), using exact values.
  2. Find the image of \((0,2)^\top\) under \(\mathbf{R}_{\pi/2}\). Check its length.
  3. Calculate \(\mathbf{R}_{-\pi/3}\mathbf{R}_{\pi/6}\) and identify the single rotation represented by the product.
  4. Show directly that \(\mathbf{R}_{-\theta}\mathbf{R}_\theta=\mathbf{I}_2\) for any real \(\theta\).
  5. For \(\theta=\frac{\pi}{2}\), explain what vector results from using the incorrect matrix with both off-diagonal entries \(+\sin\theta\) on \(\mathbf{e}_2\), and state the correct image.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon