deriving formula for reflection over y=mx+b using dot product

1.5k Views Asked by At

So, I know that the formula for a generic point is $$\left(\frac{1-m^2}{1+m^2}x + \frac{2m}{1+m^2}(y-b), \left(\frac{2m}{1+m^2}\right)x - \left(\frac{1-m^2}{1+m^2}\right)(y-b)+b\right)$$ when you reflect it over the line $y=mx+b$. It's straightforward enough to derive that with complex mappings.

I need to derive the same result using the dot product and the projection of vectors in $\mathbb{R}^2$. I'd really appreciate any help on this. Thanks!

2

There are 2 best solutions below

0
On

Let's m <> Infinity (otherwise we have to use another line description). P=(px, py) is point to reflect, P0=(x0, y0) is projection of P point to the line. Vector PP0 is perpendicular to direction vector of the line (1, m), so scalar product of these vectors is zero:

(px-x0) * 1 + (py - (m*x0 + b)) * m = 0

Solve this equation against x0, then find y0 = m * x0 + b , then calculate reflection point

P' = P + 2 * (P0 - P) = 2 * P0 - P
0
On

Let $P$ be a point of the line and $\vec u$ a unit vector along the line direction. If the line is given by its cartesian equation $y=mx+b$ you can take for instance $P=(0,b)$ and $\vec u={(1,m)\over\sqrt{1+m^2}}$.

Let $A$ be the point to reflect and define $\vec a=A-P$. The projection of $\vec a$ on the line is $(\vec u\cdot\vec a)\vec u$ so we get for reflected point $A'$: $$ A'=A+2\big((\vec u\cdot\vec a)\vec u-\vec a\big). $$ Substitute here $A$, $\vec a$ and $\vec u$ with their coordinates and you'll get your formula.