48

The linear transformation matrix for a reflection across the line $y = mx$ is:

$$\frac{1}{1 + m^2}\begin{pmatrix}1-m^2&2m\\2m&m^2-1\end{pmatrix} $$

My professor gave us the formula above with no explanation why it works. I am completely new to linear algebra so I have absolutely no idea how to go about deriving the formula. Could someone explain to me how the formula is derived? Thanks

dsd
  • 505

6 Answers6

63

You can have (far) more elegant derivations of the matrix when you have some theory available. The low-tech way using barely more than matrix multiplication would be:

The line $y = mx$ is parametrised by $t \cdot \begin{pmatrix}1\\m\end{pmatrix}$. The line orthogonal to it is parametrised by $r \cdot \begin{pmatrix}-m\\1\end{pmatrix}$. The line $y = mx$ shall be fixed, the line orthogonal to it shall be reflected, so you want a matrix $R$ with

$$R \begin{pmatrix}1 & -m\\ m & 1\end{pmatrix} = \begin{pmatrix}1 & m\\ m & -1\end{pmatrix},$$

and that means

$$\begin{align} R &= \begin{pmatrix}1 & m\\m&-1\end{pmatrix} \begin{pmatrix}1&-m\\m&1\end{pmatrix}^{-1}\\ & = \begin{pmatrix}1&m\\m&-1\end{pmatrix}\cdot \frac{1}{1+m^2}\begin{pmatrix}1&m\\-m&1\end{pmatrix}\\ &= \frac{1}{1+m^2} \begin{pmatrix}1 - m^2 & 2m\\2m &m^2-1\end{pmatrix}. \end{align}$$

Daniel Fischer
  • 206,697
26

Another way. To reflect along a line that forms an angle $\theta$ with the horizontal axis is equivalent to:

  • rotate an angle $-\theta$ (to make the line horizontal)
  • invert the $y$ coordinate
  • rotate $\theta$ back.

Further, $y=mx$ implies $\tan \theta = m$, and $1+m^2 = \frac{1}{\cos^2\theta}$ .

Then, assumming you know about rotation matrices, you can write

$$\begin{align}T&=\begin{pmatrix}\cos \theta & -\sin \theta\\ \sin \theta & \cos \theta\end{pmatrix} \begin{pmatrix}1&0\\ 0 & -1\end{pmatrix} \begin{pmatrix}\cos \theta & \sin \theta\\ -\sin \theta & \cos \theta\end{pmatrix} \\ &= \begin{pmatrix}\cos \theta & -\sin \theta\\ \sin \theta & \cos \theta\end{pmatrix} \begin{pmatrix}\cos \theta & \sin \theta\\ \sin \theta & -\cos \theta\end{pmatrix} \\ &= \cos^2 \theta \begin{pmatrix}1 & -\tan \theta\\ \tan \theta & 1\end{pmatrix} \begin{pmatrix}1 & \tan \theta\\ \tan\theta & -1\end{pmatrix} \\ &= \frac{1}{1 + m^2} \begin{pmatrix}1 & -m\\ m & 1\end{pmatrix} \begin{pmatrix}1 & m\\ m & -1\end{pmatrix} \\ &=\frac{1}{1 + m^2}\begin{pmatrix}1-m^2&2m\\2m&m^2-1\end{pmatrix}\end{align}$$

leonbloy
  • 63,430
  • 3
    Regarding the order: I'm using the same conventions as in the linked wikipedia page (points as column vectors, the standard x-y plane, positive rotations are counter-clockwise). Hence any composed transformation is written as $ p' = T p = T_2 T_1 p$ , i.e., the rightmost matrix in the multiplication corresponds to the firstly applied transformation. Further, my rightmost matrix corresponds to a rotation of $-\theta$ degrees (not 45 degrees!), i.e. $\theta$ degrees clockwise. – leonbloy Jan 17 '20 at 10:32
  • thanks for clarifying –  Jan 17 '20 at 10:35
3

Here is a slightly different take. One can check with a picture that $R=2P-I$, where $P$ is the projection onto the line. Taking $v=(1,m)^T$ a vector along the line, then $$ P\begin{bmatrix} x\\ y\end{bmatrix} = \begin{bmatrix} 1&m\end{bmatrix} \begin{bmatrix} x\\ y\end{bmatrix}\,\begin{bmatrix} 1\\ m\end{bmatrix} / \begin{bmatrix} 1&m\end{bmatrix} \begin{bmatrix} 1\\ m\end{bmatrix} =\frac1{1+m^2} \begin{bmatrix} x+my\\ mx+m^2y\end{bmatrix}. $$ So $$P=\frac1{1+m^2} \begin{bmatrix} 1&m\\ m&m^2\end{bmatrix}$$ and $$ R=2P-I=\frac1{1+m^2} \begin{bmatrix} 1-m^2&2m\\ 2m&m^2-1\end{bmatrix}. $$

Martin Argerami
  • 205,756
3

Vectors on the line obey the equation

$$y - mx = 0$$

Let $e_x, e_y$ be Cartesian basis vectors associated with the $x, y$ coordinates, respectively. The above equation implies that any vector $r = x e_x + y e_y$ that lies on the line must satisfy

$$r \cdot n = 0, \quad n = -m e_x + e_y$$

The vector $n$ is the normal vector to the line, perpendicular to the line. The associated unit normal is $\hat n = n/\sqrt{1+m^2}$.

Any vector $a$ can be broken down into a component that is parallel to the line and a component that is perpendicular. This is written $a = a_\parallel + a_\perp$. When the vector is reflected by a reflection map $\underline N$, the perpendicular component changes sign; the parallel component does not. That is,

$$\underline N(a) = a_\parallel - a_\perp = a - 2 a_\perp$$

The perpendicular component $a_\perp$ is given by

$$a_\perp = (a \cdot \hat n) \hat n$$

where $a = a^x e_x + a^y e_y$. You should be able to recognize that this is merely a projection map onto the vector $\hat n$.

Thus, the reflection map is given as

$$\underline N(a) = \underline I(a) - 2(a \cdot \hat n) \hat n$$

where $\underline I$ is the identity map.

From here, one need only evaluate this in terms of basis vectors to find the matrix components.

$$\underline N(e_x) = e_x - 2 (e_x \cdot \hat n) \hat n = e_x - \frac{2(-m)(-m e_x + e_y)}{1 + m^2} = \frac{(1-m^2)e_x + 2m e_y}{1+m^2}$$

and

$$\underline N(e_y) = e_y - 2 (e_y \cdot \hat n) \hat n = e_y - \frac{2(1)(-me_x + e_y)}{1+m^2} = \frac{2m e_x + (m^2 - 1)e_y}{1+m^2}$$

Both of these are columns of the associated matrix representation.

Muphrid
  • 19,902
1

If you made a sketch you will se that $R(x)=2 \Pi_v(x)-x$ where $v=(1,m)$ and $\Pi_v$ is the projection of the vector $x$ over the vector $v$.

Eduardo
  • 957
1

It is derived from the physics of reflection.

The reflected ray rotates by an amount equal to $2 \theta,$ if the mirror itself rotates by $\theta,$ when we are given

$$ \tan \theta = m$$

Rotation matrix for double angle

Edit 1:

$$ \begin{pmatrix}\cos 2 \theta & -\sin 2 \theta\\\sin 2 \theta &\cos 2 \theta\end{pmatrix}$$

Using Weierstrass half angle relations we have

$$ = \frac{1}{1+m^2}\begin{pmatrix}1 - m^2 & -2m\\2m &1-m^2\end{pmatrix}$$

skew symmetric, with consistency of rotation direction.

Narasimham
  • 40,495
  • Nice variant. "Cannot explain the sign": When mathematicians talk about a reflection, be skeptical, they often mean a symmetry. As a symmetry can be created by the physical reflection on a mirror perpendicular to the symmetry axis, you can use your analogy but signs in your matrix must be adjusted for the additional 90°. Accurately, the reflected object in math is the virtual image of the physical reflection along the line. The virtual image is behind the mirror, while the reflection is on the same side. – mins Nov 30 '23 at 13:37
  • OK, thanks. Symmetry with sketch explains the sign. Also a typo in diagonal for rotation matrix found and corrected! – Narasimham Nov 30 '23 at 16:37