[Math] How to calculate reflected light angle

geometryproject eulertrigonometry

On a two dimensional plane, line $X$ is at an angle of $x$ radians and an incoming light travels at an angle of $y$ radians. How can I calculate the angle of the outgoing light reflected off of the line $X$? How can I cover all possible cases?

Edit: I was trying to figure out Project Euler problem 144.

Best Answer

Since you've stated all three angles in similar terms, and want a formula that works in all cases, lets use the angle with the x axis, in 360 degree terms, which accomplishes both purposes and is good for computation. So here's the picture, with z the angle you are seeking, and a the angle of reflection...

Then, using the two triangles with the x axis as base and the fact that an exterior angle of a triangle is the sum of the other interior angles, you get

z = x + a

y = $\pi$ - 2a + z

And solving those for z in terms of x and y gives

z = $\pi$ + 2x - y

OK, this is actually far from a general analysis -- angles x, y and z could occur in any order on the x axis, but we may assume that y is to the right of x without losing generality, so there are only two other cases. Also angle x could > $\frac{\pi}{2}$, but since the lines are undirected, we may assume that x < $\pi$. Finally, angle x could be 0.

Hmmm... thinking about this some more. When z falls to the right of y, the same formula follows because the roles of z and y are interchanged. But when z falls to the left of x, it's because the line of the reflected light intersects the x axis "backwards". And then the geometry yields z = 2x - y, or the prior formula if you take the angle of the reflected light as the supplement of z.

So we really need vectors for the light rays, not undirected lines, and/or the original problem is not altogether well-formed, that is the notion "angle" of a light ray needs to be defined as the direction of its vector. If you do that, then the angle labeled z in my diagram is not the correct vector directional angle. It should be $\pi$ + z, so the true formula, in vector direction is z = 2x - y, and that works for all cases. (Haven't checked the degenerate cases, but no reason to expect them to fail).

Related Question