Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|cite|improve this question
Can you please make a drawing? It's hard to see which angle you're referring to. – kennytm Aug 8 '10 at 14:58
@KennyTM, sorry about that, please see this link: – grokus Aug 8 '10 at 15:00
There are no angles x and y in the link. – kennytm Aug 8 '10 at 19:15
@KennyTM, you are right. That was how I wanted to solve the problem. Now think of it, it might be better to just try to figure out the outgoing light's tangent. – grokus Aug 8 '10 at 20:10
up vote 7 down vote accepted

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).

share|cite|improve this answer
Seeing your answer, I tried to figure out how to guarantee that it was general, and couldn't easily do so. That's what led me to my answer, where I started by moving the x-axis to the point where the light hits the mirror (or, alternately, moving that point to the "origin") and used directed angles to guarantee the generality – Isaac Aug 8 '10 at 20:21
See my hmmm comment added to the post. – David Lewis Aug 8 '10 at 21:47
I'm curious about what software you used to draw a picture like this. Thanks. – grokus Aug 9 '10 at 3:34

Let the line has equation $ax + by + c = 0$, point where light comes on the line has coordinates $(x_0, y_0)$ and direction of the light is $(v_x, v_y)$. Suppose also that line and light direction are normed: $a^2 + b^2 = 1$ and $v_x^2 + v_y^2 = 1$.

Vector $(-b, a)$ is a vector parallel to the line. Let $d = -bv_x + av_y$ --- projection of light's direction to the line.

Then new direction of the light is $((-b)\cdot(2d) - v_x, (a)\cdot(2d) - v_y)$.

share|cite|improve this answer
sir I didn't forget you. I will take sometime to understand what you say here. The Wikipedia article on Specular reflection seems to talk about the same approach. – grokus Aug 9 '10 at 21:40


Note that regardless of what line the angles are measured from, there is a parallel line through the point of reflection on the mirror for which the angle measures will be the same. My diagram is not fully general as drawn (in terms of the angles), but the argument below is fully general, provided that all angle measures are directed—that is, counterclockwise angles are positive and clockwise angles are negative. x is the angle from a reference line to (one half of) the mirror, y is the angle from that same reference line to the incoming light ray.

The angle from the measured half of the mirror to the incoming light ray is $y-x$ (note that if the diagram is as I'd drawn, except that x were to the other half of the mirror, $x>y$ so $y-x<0$, which makes sense since $y-x$ would be going counterclockwise from the other half of the mirror to the incoming light ray). Because the magnitude of the angles of incidence and reflection are the same, but the angle of reflection is the opposite direction from the other half of the mirror, the angle from the other half of the mirror to the outgoing light ray is $-(y-x)=x-y$.

This makes the directed angle from the measured half of the mirror to the outgoing light ray $\pi+(x-y)$ (start at the measured half of the mirror, rotate $\pi$ counterclockwise, then rotate $x-y$, which is directed back clockwise). From the angle reference line to the outgoing light ray is then $x+\pi+x-y=\pi+2x-y$ (as in David Lewis's answer).

share|cite|improve this answer

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

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.