# derivation of 2D reflection matrix

## Reflection across a line of given angle

Let $\mathbf{x},\mathbf{y}$ be perpendicular^{} unit vectors^{} in the plane.
Suppose we want to reflect^{} vectors (perpendicularly) over a line that makes an angle $\theta $ with
the positive $\mathbf{x}$ axis. More precisely, we are given
a direction direction vector $\mathbf{u}=\mathrm{cos}\theta \mathbf{x}+\mathrm{sin}\theta \mathbf{y}$ for the line of reflection.
A unit vector perpendicular to $\mathbf{u}$ is $\mathbf{v}=-\mathrm{sin}\theta \mathbf{x}+\mathrm{cos}\theta \mathbf{y}$
(as is easily checked). Then to reflect an arbitrary vector $\mathbf{w}$,
we write $\mathbf{w}$ in of its components^{} in the $\mathbf{u},\mathbf{v}$ axes:
$\mathbf{w}=a\mathbf{u}+b\mathbf{v}$, and the result of the reflection is to be ${\mathbf{w}}^{\prime}=a\mathbf{u}-b\mathbf{v}$.

We compute the matrix for such a reflection in the original $x,y$ coordinates.

Denote the reflection by $T$. By the matrix change-of-coordinates formula, we have

${[T]}_{xy}={[I]}_{uv}^{xy}{[T]}_{uv}{[I]}_{xy}^{uv},$ |

where ${[T]}_{xy}$ and ${[T]}_{uv}$ denote the matrix representing $T$ with respect to the $x,y$ and $u,v$ coordinates respectively; ${[I]}_{uv}^{xy}$ is the matrix that changes from $u,v$ coordinates to $x,y$ coordinates, and ${[I]}_{xy}^{uv}$ is the matrix that changes coordinates the other way.

The three matrices on the right-hand side are all easily derived from the description we gave for the reflection $T$:

${[I]}_{uv}^{xy}=\left[\begin{array}{cc}\hfill \mathrm{cos}\theta \hfill & \hfill -\mathrm{sin}\theta \hfill \\ \hfill \mathrm{sin}\theta \hfill & \hfill \mathrm{cos}\theta \hfill \end{array}\right],{[T]}_{uv}=\left[\begin{array}{cc}\hfill 1\hfill & \hfill 0\hfill \\ \hfill 0\hfill & \hfill -1\hfill \end{array}\right],{[I]}_{xy}^{uv}={\left({[I]}_{uv}^{xy}\right)}^{-1}=\left[\begin{array}{cc}\hfill \mathrm{cos}\theta \hfill & \hfill \mathrm{sin}\theta \hfill \\ \hfill -\mathrm{sin}\theta \hfill & \hfill \mathrm{cos}\theta \hfill \end{array}\right].$ |

Computing the matrix product^{} (with the help of the double angle identity) yields:

$${[T]}_{xy}=\left[\begin{array}{cc}\hfill \mathrm{cos}2\theta \hfill & \hfill \mathrm{sin}2\theta \hfill \\ \hfill \mathrm{sin}2\theta \hfill & \hfill -\mathrm{cos}2\theta \hfill \end{array}\right].$$ | (1) |

For the of the reader, we note that there are other ways of “deriving” this result. One is by the use of a diagram, which would show that $(1,0)$ gets reflected to $(\mathrm{cos}2\theta ,\mathrm{sin}2\theta )$ and $(0,1)$ gets reflected to $(\mathrm{sin}2\theta ,-\mathrm{cos}2\theta )$. Another way is to observe that we can rotate an arbitrary mirror line onto the x-axis, then reflect across the x-axis, and rotate back. (The matrix product ${[T]}_{xy}$ can be seen as operating this way.) We took neither of these two approaches, because to justify them rigorously takes a bit of work, that is avoided by the pure linear algebra approach.

Note also that ${[T]}_{uv}$ and ${[T]}_{xy}$ are orthogonal matrices^{},
with determinant^{} $-1$, as expected.

## Reflection across a line of given direction vector

Suppose instead of being given an angle $\theta $,
we are given the unit direction vector $u$ to reflect the vector $w$.
We can derive the matrix for the reflection directly, without involving any trigonometric functions^{}.

In the decomposition $\mathbf{w}=a\mathbf{u}+b\mathbf{v}$, we note that $b=\mathbf{w}\cdot \mathbf{v}$. Therefore

$${\mathbf{w}}^{\prime}=(a\mathbf{u}+b\mathbf{v})-2b\mathbf{v}=\mathbf{w}-2(\mathbf{w}\cdot \mathbf{v})\mathbf{v}.$$ |

(In fact, this is the formula used in the to draw the diagram in this entry.) To derive the matrix with respect to $x,y$ coordinates, we resort to a trick:

$${\mathbf{w}}^{\prime}=I\mathbf{w}-2\mathbf{v}(\mathbf{w}\cdot \mathbf{v})=I\mathbf{w}-2\mathbf{v}({\mathbf{v}}^{\text{tr}}\mathbf{w})=I\mathbf{w}-2({\mathrm{\mathbf{v}\mathbf{v}}}^{\text{tr}})\mathbf{w}.$$ |

Therefore the matrix of the transformation is

$$I-2{\mathrm{\mathbf{v}\mathbf{v}}}^{\text{tr}}=\left[\begin{array}{cc}\hfill {u}_{x}^{2}-{u}_{y}^{2}\hfill & \hfill 2{u}_{x}{u}_{y}\hfill \\ \hfill 2{u}_{x}{u}_{y}\hfill & \hfill {u}_{y}^{2}-{u}_{x}^{2}\hfill \end{array}\right],\mathbf{u}={({u}_{x},{u}_{y})}^{\text{tr}},\mathbf{v}={(-{u}_{y},{u}_{x})}^{\text{tr}}.$$ |

If $u$ was not a unit vector to begin with, it of course suffices to divide by its magnitude before proceeding. Taking this into account, we obtain the following matrix for a reflection about a line with direction $\mathbf{u}$:

$$\frac{1}{{u}_{x}^{2}+{u}_{y}^{2}}\left[\begin{array}{cc}\hfill {u}_{x}^{2}-{u}_{y}^{2}\hfill & \hfill 2{u}_{x}{u}_{y}\hfill \\ \hfill 2{u}_{x}{u}_{y}\hfill & \hfill {u}_{y}^{2}-{u}_{x}^{2}\hfill \end{array}\right].$$ | (2) |

Notice that if we put ${u}_{x}=\mathrm{cos}\theta $ and ${u}_{y}=\mathrm{sin}\theta $ in matrix (2), we get matrix (1), as it should be.

## Reflection across a line of given slope

There is another form for the matrix (1). We set $m=\mathrm{tan}\theta $ to be the slope of the line of reflection and use the identities:

${\mathrm{cos}}^{2}\theta $ | $={\displaystyle \frac{1}{{\mathrm{tan}}^{2}\theta +1}}={\displaystyle \frac{1}{{m}^{2}+1}}$ | ||

$\mathrm{cos}2\theta $ | $=2{\mathrm{cos}}^{2}\theta -1$ | ||

$\mathrm{sin}2\theta $ | $=2\mathrm{sin}\theta \mathrm{cos}\theta =2\mathrm{tan}\theta {\mathrm{cos}}^{2}\theta =2m{\mathrm{cos}}^{2}\theta .$ |

When these equations are substituted in matrix (1), we obtain an alternate expression for it in of $m$ only:

$$\frac{1}{{m}^{2}+1}\left[\begin{array}{cc}\hfill 1-{m}^{2}\hfill & \hfill 2m\hfill \\ \hfill 2m\hfill & \hfill {m}^{2}-1\hfill \end{array}\right].$$ | (3) |

Thus we have derived the matrix for a reflection about a line of slope $m$.

Alternatively, we could have also substituted ${u}_{x}=1$ and ${u}_{y}=m$ in matrix (2) to arrive at the same result.

## Topology of reflection matrices

Of course, formula (3) does not work literally when
$m=\pm \mathrm{\infty}$ (the line is vertical).
However, that case may be derived by taking the limit $|m|\to \mathrm{\infty}$ —
this limit operation can be justified by considerations of the topology^{} of
the space of two-dimensional reflection matrices.

What is this topology? It is the one-dimensional projective plane^{} $\mathbb{R}{\mathbb{P}}^{1}$,
or simply, the “real projective line”.
It is formed by taking the circle, and identifying opposite points, so
that each pair of opposite points specify a unique mirror line of reflection in ${\mathbb{R}}^{2}$.
Formula (1) is a parameterization of $\mathbb{R}{\mathbb{P}}^{1}$.
Note that (1) involves the quantity $2\theta $, not $\theta $,
because for a point $(\mathrm{cos}\theta ,\mathrm{sin}\theta )$ on the circle,
its opposite point $(\mathrm{cos}(\theta +\pi ),\mathrm{sin}(\theta +\pi ))$ specify the same reflection,
so formula (1) has to be invariant when $\theta $ is replaced by $\theta +\pi $.

But (1) might as well be written

$${[T]}_{xy}=\left[\begin{array}{cc}\hfill \mathrm{cos}\varphi \hfill & \hfill \mathrm{sin}\varphi \hfill \\ \hfill \mathrm{sin}\varphi \hfill & \hfill -\mathrm{cos}\varphi \hfill \end{array}\right].$$ | (4) |

where $\varphi =2\theta $. For this parameterization of $R{P}^{1}$ to be one-to-one,
$\varphi $ can range over interval^{} $(0,2\pi )$, and the endpoints^{} at $\varphi =0,2\pi $ overlap just
as for a circle, without identifying pairs of opposite points. What does this mean? It is the fact that $\mathbb{R}{\mathbb{P}}^{1}$ is homeomorphic to the circle ${S}^{1}$.

The real projective line $\mathbb{R}{\mathbb{P}}^{1}$ is also the one-point compactification of $\mathbb{R}$ (i.e. $\mathbb{R}{\mathbb{P}}^{1}=\mathbb{R}\cup \{\mathrm{\infty}\}$), as shown by formula (3); the number $m=\mathrm{\infty}$ corresponds to a reflection across the vertical axis. Note that this “$\mathrm{\infty}$” is not the same as the usual $\pm \mathrm{\infty}$, because here $-\mathrm{\infty}$ and $\mathrm{\infty}$ are actually the same number, both representing the slope of a vertical line.

Title | derivation of 2D reflection matrix |
---|---|

Canonical name | DerivationOf2DReflectionMatrix |

Date of creation | 2013-03-22 15:25:05 |

Last modified on | 2013-03-22 15:25:05 |

Owner | stevecheng (10074) |

Last modified by | stevecheng (10074) |

Numerical id | 14 |

Author | stevecheng (10074) |

Entry type | Derivation |

Classification | msc 15-00 |

Related topic | RotationMatrix |

Related topic | DecompositionOfOrthogonalOperatorsAsRotationsAndReflections |

Related topic | DerivationOfRotationMatrixUsingPolarCoordinates |