Tag Archives: Transformations

Matrices – Linear Transformations (reflection in y=mx)

We are going to derive the transformation matrix for a reflection across a line y=mx.

Reflecting P across the line to P'

Things to remember about a reflection:

  • The distance between P' and the line is same as the distance between P and the line. Hence M is the midpoint of P and P'.
  • The line segment joining P and P' is perpendicular to the line.

Our aim is to find a general identity for P' and then use that to derive a transformation matrix.

Let’s start by finding the equation of the line joining P and P'.

We know the gradient of this line is perpendicular to the gradient of y=mx, hence the gradient is -\frac{1}{m}.

    \begin{equation*}y-y_0=-\frac{1}{m}(x-x_0)\end{equation}

And (a,b) is a point on the line.

    \begin{equation*}y-b=-\frac{1}{m}(x-a)\end{equation}

Which simplifies to

(1)   \begin{equation*}y=-\frac{1}{m}x+\frac{a+bm}{m}\end{equation*}

We are going to find the co-ordinates of M in two ways; as the midpoint of P and P', and as the point of intersection of y=mx and y=-\frac{1}{m}x+\frac{a+bm}{m}

As the midpoint of P and P'

(2)   \begin{equation*}M=(\frac{a+c}{2}, \frac{b+d}{2})\end{equation*}

As the point of intersection of y=mx and y=-\frac{1}{m}x+\frac{a+bm}{m}

    \begin{equation*}mx=-\frac{1}{m}x+\frac{a+bm}{m}\end{equation}

    \begin{equation*}mx+\frac{x}{m}=\frac{a+bm}{m}\end{equation}

    \begin{equation*}\frac{m^2x+x}{m}=\frac{a+bm}{m}\end{equation}

    \begin{equation*}x(m^2+1)=a+bm\end{equation}

    \begin{equation*}x=\frac{a+bm}{m^2+1}\end{equation}

Substitute x into y=mx

    \begin{equation*}y=\frac{am+bm^2}{m^2+1}\end{equation}

(3)   \begin{equation*}M=(\frac{a+bm}{m^2+1},\frac{am+bm^2}{m^2+1})\end{equation*}

M must equal M, hence we can find (c, d) in terms of (a, b)

Equate equation 2 and 3

    \begin{equation*}\frac{a+c}{2}=\frac{a+bm}{m^2+1}\end{equation}

    \begin{equation*}a+c=2(\frac{a+bm}{m^2+1})\end{equation}

    \begin{equation*}c=2(\frac{a+bm}{m^2+1})-a\end{equation}

    \begin{equation*}c=\frac{2a+2bm-am^2-a}{m^2+1}\end{equation}

    \begin{equation*}c=\frac{a+2bm-am^2}{m^2+1}\end{equation}

(4)   \begin{equation*}c=\frac{1-m^2}{m^2+1}a+\frac{2m}{m^2+1}b\end{equation*}

And

    \begin{equation*}\frac{b+d}{2}=\frac{am+bm^2}{m^2+1}\end{equation}

    \begin{equation*}b+d=2(\frac{am+bm^2}{m^2+1})\end{equation}

    \begin{equation*}d=2(\frac{am+bm^2}{m^2+1})-b\end{equation}

    \begin{equation*}d=\frac{2am+2bm^2-bm^2-b}{m^2+1}\end{equation}

    \begin{equation*}d=\frac{2m}{m^2+1}a+\frac{m^2-1}{m^2+1}b\end{equation}

    \begin{equation*}d=\frac{2m}{m^2+1}a-\frac{-m^2+1}{m^2+1}b\end{equation}

(5)   \begin{equation*}d=\frac{2m}{m^2+1}a-\frac{1-m^2}{m^2+1}b\end{equation*}

Hence P'=(\frac{1-m^2}{m^2+1}a+\frac{2m}{m^2+1}b, \frac{2m}{m^2+1}a-\frac{1-m^2}{m^2+1}b)

For ease of writing, let p=\frac{1-m^2}{m^2+1} and q=\frac{2m}{m^2+1}

Then

P'=(pa+qb, qa-px), which we can generalise to (px+qy, qx-py)

Now let’s think about a transformation matrix, we want to transform (x, y) to (px+qy, qx-py)

    \begin{equation*}\begin{bmatrix}p&q\\q &-p\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}=\begin{bmatrix}px+qy\\qx-py\end{bmatrix}\end{equation}

Remember the gradient of a line is the tangent of the angle of inclination, tan(\theta)=m

    \begin{equation*}p=\frac{1-m^2}{m^2+1}=\frac{1-tan^2(\theta)}{tan^2(\theta)+1}\end{equation}

Remember the identity

    \begin{equation*}tan^2(\theta)+1=sec^2(\theta)\end{equation}

    \begin{equation*}p=\frac{1-(sec^2(\theta)-1)}{sec^2(\theta)}\end{equation}

    \begin{equation*}p=\frac{2-sec^2(\theta)}{sec^2(\theta)}\end{equation}

    \begin{equation*}p=\frac{2}{sec^2(\theta)}-\frac{sec^2(\theta)}{sec^2(\theta)}\end{equation}

    \begin{equation*}p=2cos^2(\theta)-1\end{equation}

(6)   \begin{equation*}p=cos(2\theta)\end{equation*}

And we will do the same for q.

    \begin{equation*}q=\frac{2m}{m^2+1}=\frac{2tan(\theta)}{tan^2(\theta)+1}\end{equation}

    \begin{equation*}q=\frac{\frac{2sin(\theta)}{cos(\theta)}}{sec^2(\theta)}\end{equation}

    \begin{equation*}q=\frac{2sin(\theta)}{cos(\theta)} \times cos^2(\theta)\end{equation}

    \begin{equation*}q=2sin(\theta)cos(\theta)\end{equation}

(7)   \begin{equation*}q=sin(2\theta)\end{equation*}

Hence our transformation matrix is

(8)   \begin{equation*}\begin{bmatrix}cos(2\theta)&sin(2\theta)\\sin(2\theta)&-cos(2\theta)\end{bmatrix}\end{equation*}

Example

The vertices of a triangle T are A(-3, 1), B(6, -4) and C(1, 5). T' is a reflection of T in the line y-x=0

The gradient of the line y=x is 1.

    \begin{equation*}tan(\theta)=1\end{equation}

    \begin{equation*}\theta=\frac{\pi}{4}\end{equation}

Our transformation matrix is

    \begin{equation*}\begin{bmatrix}cos(\frac{\pi}{2})&sin\frac{\pi}{2})\\sin\frac{\pi}{2})&-cos(\frac{\pi}{2})\end{bmatrix}\end{equation}

Which is

    \begin{equation*}\begin{bmatrix}0&1\\1&0\end{bmatrix}\end{equation}

So

    \begin{equation*}T'=\begin{bmatrix}0&1\\1&0\end{bmatrix}\begin{bmatrix}-3&6&1\\1&-4&5\end{bmatrix}\end{equation}

    \begin{equation*}T'=\begin{bmatrix}1&-4&5\\-3&6&1\end{bmatrix}\end{equation}

Leave a Comment

Filed under Matrices, Transformations