TITLE: How to calculate reflected light angle?
QUESTION [7 upvotes]: 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.

REPLY [2 votes]: Ok, here's another way to look at it, using vector directions and kinda intuitive, but I think it is pretty close to a real proof. 
Start with the mirror line X horizontal, that is, its angle x = 0. The it's clear that the vector angle, z, of the reflected light is the negative of the vector angle, y, of the light itself: z = -y.

Now rotate line X by d degrees around the point of reflection, either way, leaving the original light ray (angle y) fixed and letting the reflected ray (angle z) rotate around the point of reflection to maintain the angle of reflection equal to the angle of incidence. Assuming counterclockwise rotation, d > 0, this "pushes" the reflected line by 2d, one d for a direct push to maintain the angle fo reflection, and another d because the angle of incidence also increases by d, so the reflected light must rotate that much more to keep the two angles of the light equal. Likewise when d < 0 for clockwise rotation.
So we are increasing (or decreasing, for counterclockwise rotation) angle x by d, but angle z (vector angle) by 2d. Hence...
z = 2d - y = 2x - y