I'm been doing some paperwork on reflection of light, and I think I finally got it. Before I continue, there's gonna be a lot of Math mumbo-jumbo, so, again, if you hate Maths more than you hate the annoying little barking
Here goes:
Let's say we have a beam of light. The beam's direction will be called as vector D. I'm going to be using a lot of vectors here.
There's also a plane of mirror, with a normal vector, N. This normal vector is a unit vector, ie, a 1-unit long vector. The normal vector is a vector that is perpendicular to the mirror.
Now, I shall draw it out. Introducing, MS Paint!!
I know, the normal vector is a little too long. I just drew it long so it's easier to see. But remember, vector N is a unit vector, as shown by the symbol above the letter N in the picture.
Ok, now, let's add more stuff.
On the left of vector N, there's another vector. Well, actually, it's just an inverted vector D, or -D. It's inverted for the calculations later. And there's one more extra vector, vector R, which is the reflection.
One very important thing that applies to all reflection:
The angle of incidence = angle of reflection
Therefore, a = b.
Because of that, the scalar projection of vector -D on vector N = the scalar projection of vector R on vector N.
I have coloured the so-called scalar projections in green.
Still with me so far?
The magnitude (length) of the scalar projections can be obtained through what's called the dot product.
The full stop (period) sign is a little too small for me, so to use as the dot product symbol, I'll utilise the "o" symbol instead.
Now, -D o N = |D| |N| cos a
But since N is a unit vector, thus |N|=1
-D o N = |D| cos a
which gives us the scalar projection of -D on N. According to
"the scalar projection of vector -D on vector N = the scalar projection of vector R on vector N."
we should now have:
-D o N = R o N
but we will use
R o N = -D o N instead. It's just the same, anyway.
Ok, that's 1 equation down, we will need 1 more.
The magnitude of the reflection vector (R) should be the same as the incidence vector (-D), so, here comes the equation (oh boy)
Rx2+Ry2=(-Dx)2+(-Dy)2
now, Rx means the x component of the vector. Ry means the y component. Same goes for the D vector.
Ok, I omitted the square root to make things simpler.
Now, we got 2 equations:
R o N = -D o N
Rx2+Ry2=(-Dx)2+(-Dy)2
Right, let's try with an example:
Right, I have normalized the normal vector, N. Normalizing is basically making a vector exactly 1 unit long. The vector is perpendicular to the mirror, therefore, it is "normal" to the mirror. So, "Normalize" and "Normal vector" are two different things.
Actually, N's direction is supposed to be (1/sqrt(2) , 1/sqrt(2)), but I was lazy to draw the root, so I got the decimal number instead.
So, let's get cracking.
R o N = -D o N
can be rewritten as
RxNx+RyNy = (-D)xNx+(-D)yNy
Substituting values, we get:
Rx(1/sqrt(2)) + Ry(1/sqrt(2)) = (-1)(1/sqrt(2)) + (2)(1/sqrt(2))
(1/sqrt(2)) (Rx+Ry) = (1/sqrt(2))
Dividing both sides by (1/sqrt(2)):
Rx+Ry=1
Dang, there are 2 unknowns!! What to do?? Chill man. That's where the 2nd equation comes in.
Rx2+Ry2=(-Dx)2+(-Dy)2
Plugging in the known values...
Rx2+Ry2=(-1)2 + 22
Rx2+Ry2=5
Ok, now, let's solve for Rx. First, get Ry.
Ry=1-Rx
Dump that into the previous equation:
Rx2+(1-Rx)2=5
Rx2+1-2Rx+Rx2=5
Remember the "completing the squares" thingie? Right, let's apply it here.
Now, make it so that it is in the form x2-2ax+a2, then it'll be easier.
2Rx2-2Rx+1=5
Rx2-Rx+1/2 = 5/2
To complete the square, take away -1/4 from both sides
Rx2-Rx+1/4 = 9/4
(Rx-1/2)2=9/4
Take the square root of both sides
Rx-1/2=3/2
So,
Rx=2
Placing this into Rx+Ry=1, and you'll get Ry=-1.
Therefore, the reflection vector is (2,-1). Makes sense right?
Woohoo!!! That was long! Now, I'm gonna do more research and probably refine these equations. This might not be the best way to calculate reflection, but at least it's something. Haha