[Math] Reflecting a vector over another line

vectors

So I'm really stuck with this math problem lately. I have a ray that is set along another line and gets reflected. What i am trying to do is to simply get reflected line's equation ($y = mx + c$). However, i think i should be using vectors. The problem is, even tho generally I understand them, I just can't get over how to use them in this case. I'm a senior so i haven't touched this topic yet and I need a little bit of help for my programming project.

I have two line equations and a point that the actual ray hits. I found this formula $r=d−2(d \cdot n)n$ where $r$ is the reflected line's vector, $n$ is the normal of a mirror, $d$ is the incident ray. How do i actually use these equations as vectors?!

an example is shown here

enter image description here

-Any help is reeaaally appreciated. Thaaanks!:))

Best Answer

Start by rearranging the equation of the mirror line into $\frac23x-y=-\frac83$. The normal form of the equation of a line is $\mathbf n\cdot\mathbf x=\text{const}$, where $\mathbf n$ is some vector normal (perpendicular) to the line. Comparing this to the mirror line equation, I see that a normal to it is $\left(\frac23,-1\right)$. Since any normal will do, I’ll multiply this by $-3$ so that I don’t have to fiddle with as many fractions and so that the normal is on the same side of the line as the incident ray: $\mathbf n=(-2,3)$.

The incoming vector is $(1,m_{\text{in}})=(1,-1/3)$, which I’ll also multiply by $3$ to make the arithmetic simpler. Your reflection formula wants the normal to be a unit vector, but that can be dealt with by dividing by the length of $\mathbf n$ twice, once for each appearance in the formula. This is somewhat nicer for calculation anyway, since $\|\mathbf n\|^2=\mathbf n\cdot\mathbf n$ so that there’s no need to compute square roots. So, for the reflected ray, we have $$\mathbf r=\mathbf d-2{\mathbf d\cdot\mathbf n\over\mathbf n\cdot\mathbf n}\mathbf n = (3,-1)-2{(3,-1)\cdot(2,-3)\over(2,-3)\cdot(2,-3)}(-2,3)=\left(\frac3{13},\frac{41}{13}\right).$$ Divide the $y$-coordinate by the $x$-coordinate to find the corresponding outgoing slope, which is $41/3$. You know that the ray hits the mirror at $(5,6)$, so the equation of the reflected line is $(y-6)={41\over3}(x-5)$, or $$y={41\over3}x-{187\over3}.$$

You can also work entirely with normal vectors because the normal of the reflected line is the same as the reflection of the incoming line’s normal. The incoming normal can be read from the equation: $(-1/3,-1)$, or $(1,3)$ to simplify the arithmetic. The reflection formula produces $\left(\frac{41}{13},-\frac3{13}\right)$, which you can verify is perpendicular to the vector $\mathbf r$ computed previously. The equation of the outgoing line is then $41x-3y=\dots$ (I’ve multiplied the entire equation by $13$ to eliminate the fractions.) Referring to the general normal equation at the top of this answer, it says that the dot product of $\mathbf n$ with every point on the line is constant, so we can find this constant by taking the dot product with any known point—$(5,6)$ in this case. This gives $41x-3y=187$, which should be looking a bit familiar. Rearranging this equation to isolate $y$ produces the same one as computed previously.

Related Question