# Reflect point across line with matrix

What is the transformation matrix that I multiply a point by if I want to reflect that point across a line that goes through the origin in terms of the angle between the line and the x-axis?

In other words, $$y = mx$$

$\theta$ is the angle between the $x$-axis and the line.

The position vector $P=\begin{bmatrix}a\\b\\\end{bmatrix}$ is a point on the same plane as the line.

The vector $P'$ is $P$ reflected across $y=mx$.

What matrix do I multiply $P$ by to get $P'$, in terms of $\theta$?

I've looked online and found $$\begin{bmatrix} \cos(2\theta) & \sin(2\theta) \\ \sin(2\theta) & -\cos(2\theta) \\ \end{bmatrix}$$but I tested it and it doesn't work for me.

Also, examples with the vector $$\begin{bmatrix}2\\1\\\end{bmatrix}$$ and the line $y = \frac 43x$ would help to stay consistent with my tests.

• If you have the slope of the line, you don't need the angle. There are different way how this can be done, including linear algebra methods. I don't know your math back ground, so this link may be helpful: math.stackexchange.com/questions/525082/… – imranfat Mar 27 '16 at 3:08

The correct answer is the one for which you said "I tested it and it doesn't work for me," namely

$$\begin{bmatrix} \cos(2\theta) & \sin(2\theta) \\ \sin(2\theta) & -\cos(2\theta) \\ \end{bmatrix}$$

Here is a diagram for your example.

The line is $y=\frac 43x$, which has the angle of inclination $\theta\approx 53.1301023542°$ with $\cos(2\theta)=-0.28$ and $\sin(2\theta)=0.96$, and the points before and after reflection are

$$P=\begin{bmatrix}2\\1\\\end{bmatrix}, \quad P'=\begin{bmatrix}0.4\\2.2\\\end{bmatrix}$$

(The line and point $P$ were entered in Geogebra: the angle, cosine, sine, and point $P'$ were calculated by Geogebra.) The matrix calculation is then

$$\begin{bmatrix}\cos(2\theta)&\sin(2\theta)\\\sin(2\theta)&-\cos(2\theta)\\\end{bmatrix}\cdot P =\begin{bmatrix}-0.28&0.96\\0.96&0.28\\\end{bmatrix}\cdot \begin{bmatrix}2\\1\\\end{bmatrix} =\begin{bmatrix}0.4\\2.2\\\end{bmatrix} =P'$$

so it all works out.

Do you want a derivation of that transformation matrix? And what tests did you try that did not work for you?