I am doing Isometries i.e. Rotations, translations and reflections at the moment. General equations for 2 of them are "easy"
Translation: $f(x,y)=(x+a,y+b)$
Rotation about origin through the angle $\alpha$ is just $f(r,\theta)=(r,\theta+\alpha)$
However I struggle to find similiar function for a reflection in a line. For some simple cases like Reflection in line $y=x$ this is easy, $f(x,y)=(y,x)$ but I struggle to find the way for a general function $f(x)=mx+c$.
Thanks for any help
This is fun. If point P is given and a line $y=m x + c$, then the mirror point Q is
$$ \begin{pmatrix} x_Q \\ y_Q \end{pmatrix} =\begin{bmatrix} \frac{1-m^2}{1+m^2} & \frac{2 m}{1+m^2} \\ \frac{2 m}{1+m^2} & \frac{m^2-1}{1+m^2} \end{bmatrix} \begin{pmatrix} x_P \\ y_P \end{pmatrix} + \begin{pmatrix} -\frac{2 c m}{1+m^2} \\ \frac{2 c}{1+m^2} \end{pmatrix}$$
How
I decomposed the coordinates of point P into three vector parts
You can confirm that the following is true
$$ \begin{pmatrix} x_P \\ y_P \end{pmatrix} = \begin{pmatrix} -\frac{c m}{1+m^2} \\ \frac{c}{1+m^2} \end{pmatrix} + \begin{pmatrix} \frac{m y_P+x_P}{1+m^2} \\ \frac{m ( m y_P+x_P)}{1+m^2} \end{pmatrix} + \begin{pmatrix} \frac{m (m x_P - y_P+c)}{1+m^2} \\ -\frac{m x_P-y_P+c}{1+m^2} \end{pmatrix} $$
To get to the mirror point Q flip the direction of the last part
$$ \begin{pmatrix} x_Q \\ y_Q \end{pmatrix} = \begin{pmatrix} -\frac{c m}{1+m^2} \\ \frac{c}{1+m^2} \end{pmatrix} + \begin{pmatrix} \frac{m y_P+x_P}{1+m^2} \\ \frac{m ( m y_P+x_P)}{1+m^2} \end{pmatrix} - \begin{pmatrix} \frac{m (m x_P - y_P+c)}{1+m^2} \\ -\frac{m x_P-y_P+c}{1+m^2} \end{pmatrix} $$