# Nakafa Learning Content

> For AI agents: use [llms.txt](https://nakafa.com/llms.txt) for the site index. Markdown versions are available by appending `.md` to content URLs or sending `Accept: text/markdown`.

URL: https://nakafa.com/en/subjects/mathematics/geometric-transformation/rotation-matrix
Source: https://raw.githubusercontent.com/nakafaai/nakafa.com/refs/heads/main/packages/contents/material/lesson/mathematics/geometric-transformation/rotation-matrix/en.mdx

Learn rotation matrices for 2D transformations with derivation, formulas, and practical examples. Learn rotations about origin and arbitrary points.

---

## Finding the Rotation Matrix about the Origin

The image of a point $$(x,y)$$ rotated about the origin $$(0,0)$$ by an angle $$\theta$$ is $$(x \cos \theta - y \sin \theta, x \sin \theta + y \cos \theta)$$.

Visible text: The image of a point rotated about the origin by an angle is .

We want to find a $$2 \times 2$$ matrix, say $$\begin{pmatrix} r & s \\ t & u \end{pmatrix}$$, that represents this rotation transformation.

Visible text: We want to find a matrix, say , that represents this rotation transformation.

This matrix must satisfy:

```math
\begin{pmatrix} r & s \\ t & u \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} x \cos \theta - y \sin \theta \\ x \sin \theta + y \cos \theta \end{pmatrix}
```

From the matrix multiplication on the left side, we get:

```math
\begin{pmatrix} rx + sy \\ tx + uy \end{pmatrix} = \begin{pmatrix} x \cos \theta - y \sin \theta \\ x \sin \theta + y \cos \theta \end{pmatrix}
```

By equating the corresponding components:

- First row: $$rx + sy = x \cos \theta - y \sin \theta$$.

  For this equation to hold for all $$x$$ and $$y$$, the coefficients of $$x$$ must be equal and the coefficients of $$y$$ must be equal. Thus, $$r = \cos \theta$$ and $$s = -\sin \theta$$.

- Second row: $$tx + uy = x \sin \theta + y \cos \theta$$.

  Similarly, $$t = \sin \theta$$ and $$u = \cos \theta$$.

Visible text: - First row: .

 For this equation to hold for all and , the coefficients of must be equal and the coefficients of must be equal. Thus, and .

- Second row: .

 Similarly, and .

### Rotation Matrix about the Origin

The matrix associated with a rotation by an angle $$\theta$$ radians (or degrees) about the origin $$O(0,0)$$ is:

Visible text: The matrix associated with a rotation by an angle radians (or degrees) about the origin is:

```math
R_\theta = \begin{pmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{pmatrix}
```

## Matrix Operation for Rotation about an Arbitrary Point

To rotate a point $$(x,y)$$ about an arbitrary point $$P(a,b)$$ by an angle $$\theta$$, we perform three steps:

Visible text: To rotate a point about an arbitrary point by an angle , we perform three steps:

1. Translate the point $$(x,y)$$ so that $$P(a,b)$$ becomes the origin: $$(x-a, y-b)$$.
2. Rotate the translated point about the origin by $$\theta$$ using the matrix $$R_\theta$$.
3. Translate the rotated point back by adding $$(a,b)$$.

Visible text: 1. Translate the point so that becomes the origin: .
2. Rotate the translated point about the origin by using the matrix .
3. Translate the rotated point back by adding .

### Matrix Operation for Rotation about an Arbitrary Point

The operation associated with rotation by an angle $$\theta$$ radians about the point $$(a,b)$$ is:

Visible text: The operation associated with rotation by an angle radians about the point is:

```math
\begin{pmatrix} x' \\ y' \end{pmatrix} = \begin{pmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{pmatrix} \begin{pmatrix} x-a \\ y-b \end{pmatrix} + \begin{pmatrix} a \\ b \end{pmatrix}
```

## Finding a Specific Rotation Matrix

The matrix associated with a rotation by $$\theta = \frac{1}{4}\pi$$ radians ($$45^\circ$$) about the origin is:

Visible text: The matrix associated with a rotation by radians () about the origin is:

We know $$\cos(\frac{\pi}{4}) = \frac{1}{\sqrt{2}}$$ and $$\sin(\frac{\pi}{4}) = \frac{1}{\sqrt{2}}$$.

Visible text: We know and .

```math
R_{\frac{\pi}{4}} = \begin{pmatrix} \cos(\frac{\pi}{4}) & -\sin(\frac{\pi}{4}) \\ \sin(\frac{\pi}{4}) & \cos(\frac{\pi}{4}) \end{pmatrix} = \begin{pmatrix} \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \end{pmatrix}
```

This is the required matrix.

Component: LineEquation
Props:
- title: Visualization of Rotating Point $$(2,0)$$ by $$45^\circ$${" "}
about the Origin
  Visible text: Visualization of Rotating Point by {" "}
about the Origin
- description: Point $$A(2,0)$$ is rotated by{" "}
$$45^\circ$$ to become{" "}
<InlineMath math="A'(\sqrt{2}, \sqrt{2})" />.{" "}
$$\sqrt{2} \approx 1.414$$.
  Visible text: Point is rotated by{" "}
 to become{" "}
<InlineMath math="A'(\sqrt{2}, \sqrt{2})" />.{" "}
.
- data: [
{
points: [{ x: 0, y: 0, z: 0 }],
color: getColor("ROSE"),
showPoints: true,
labels: [{ text: "O", at: 0, offset: [0.3, -0.3, 0] }],
},
{
points: [{ x: 2, y: 0, z: 0 }],
color: getColor("SKY"),
showPoints: true,
labels: [{ text: "A(2,0)", at: 0, offset: [0.3, -0.3, 0] }],
},
{
points: [{ x: Math.sqrt(2), y: Math.sqrt(2), z: 0 }],
color: getColor("EMERALD"),
showPoints: true,
labels: [{ text: "A'(√2, √2)", at: 0, offset: [0.3, 0.3, 0] }],
},
{
points: [
{ x: 0, y: 0, z: 0 },
{ x: 2, y: 0, z: 0 },
],
color: getColor("INDIGO"),
},
{
points: [
{ x: 0, y: 0, z: 0 },
{ x: Math.sqrt(2), y: Math.sqrt(2), z: 0 },
],
color: getColor("INDIGO"),
},
]
- showZAxis: false
- cameraPosition: [0, 0, 8]

## Exercises

1.  Determine the matrices associated with a rotation about the origin $$O(0,0)$$ by $$\frac{1}{6}\pi$$ radians.
2.  Determine the image of point $$P(4,2)$$ if it is rotated about the origin $$O(0,0)$$ by $$60^\circ$$.
3.  Determine the image of point $$Q(3,1)$$ if it is rotated about the point $$C(1,-2)$$ by $$90^\circ$$.

Visible text: 1. Determine the matrices associated with a rotation about the origin by radians.
2. Determine the image of point if it is rotated about the origin by .
3. Determine the image of point if it is rotated about the point by .

### Key Answers

1.  Given $$\theta = \frac{\pi}{6}$$ or $$30^\circ$$:

    <MathContainer>
      
    
    ```math
    \cos(\frac{\pi}{6}) = \frac{\sqrt{3}}{2}
    ```

      
    
    ```math
    \sin(\frac{\pi}{6}) = \frac{1}{2}
    ```

    </MathContainer>

    Rotation matrix:

    
    
    ```math
    \begin{pmatrix} \frac{\sqrt{3}}{2} & -\frac{1}{2} \\ \frac{1}{2} & \frac{\sqrt{3}}{2} \end{pmatrix}
    ```

2.  Point $$P(4,2)$$, $$\theta = 60^\circ$$. $$\cos 60^\circ = \frac{1}{2}$$, $$\sin 60^\circ = \frac{\sqrt{3}}{2}$$.

    <BlockMath math="\begin{pmatrix} x' \\ y' \end{pmatrix} = \begin{pmatrix} \frac{1}{2} & -\frac{\sqrt{3}}{2} \\ \frac{\sqrt{3}}{2} & \frac{1}{2} \end{pmatrix} \begin{pmatrix} 4 \\ 2 \end{pmatrix} = \begin{pmatrix} (4)(\frac{1}{2}) - (2)(\frac{\sqrt{3}}{2}) \\ (4)(\frac{\sqrt{3}}{2}) + (2)(\frac{1}{2}) \end{pmatrix} = \begin{pmatrix} 2 - \sqrt{3} \\ 2\sqrt{3} + 1 \end{pmatrix}" />

    Image: <InlineMath math="P'(2-\sqrt{3}, 2\sqrt{3}+1)" />.

3.  Given point $$Q(3,1)$$, center $$C(1,-2)$$, $$\theta = 90^\circ$$. $$(a,b)=(1,-2)$$.

    <MathContainer>
      
    
    ```math
    \cos 90^\circ = 0
    ```

      
    
    ```math
    \sin 90^\circ = 1
    ```

      <BlockMath math="\begin{pmatrix} x' \\ y' \end{pmatrix} = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 3-1 \\ 1-(-2) \end{pmatrix} + \begin{pmatrix} 1 \\ -2 \end{pmatrix}" />
      
    
    ```math
    = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 2 \\ 3 \end{pmatrix} + \begin{pmatrix} 1 \\ -2 \end{pmatrix} = \begin{pmatrix} -3 \\ 2 \end{pmatrix} + \begin{pmatrix} 1 \\ -2 \end{pmatrix} = \begin{pmatrix} -2 \\ 0 \end{pmatrix}
    ```

    </MathContainer>

    Image: <InlineMath math="Q'(-2,0)" />.

Visible text: 1. Given or :

 <MathContainer>
 
 

 
 

 </MathContainer>

 Rotation matrix:

 
 

2. Point , . , .

 <BlockMath math="\begin{pmatrix} x' \\ y' \end{pmatrix} = \begin{pmatrix} \frac{1}{2} & -\frac{\sqrt{3}}{2} \\ \frac{\sqrt{3}}{2} & \frac{1}{2} \end{pmatrix} \begin{pmatrix} 4 \\ 2 \end{pmatrix} = \begin{pmatrix} (4)(\frac{1}{2}) - (2)(\frac{\sqrt{3}}{2}) \\ (4)(\frac{\sqrt{3}}{2}) + (2)(\frac{1}{2}) \end{pmatrix} = \begin{pmatrix} 2 - \sqrt{3} \\ 2\sqrt{3} + 1 \end{pmatrix}" />

 Image: <InlineMath math="P'(2-\sqrt{3}, 2\sqrt{3}+1)" />.

3. Given point , center , . .

 <MathContainer>
 
 

 
 

 <BlockMath math="\begin{pmatrix} x' \\ y' \end{pmatrix} = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 3-1 \\ 1-(-2) \end{pmatrix} + \begin{pmatrix} 1 \\ -2 \end{pmatrix}" />
 
 

 </MathContainer>

 Image: <InlineMath math="Q'(-2,0)" />.