I tend to enjoy reinventing the wheel, coming up with formulas for things that I know, have already been figured out. Its more fun when you don't know the formula for something (ie. a 3d engine) but try to figure it out yourself rather then looking it up and being told. (thats no fun)
I thought I'd figure one out for reflection. I came across a need for this in one of my programs. It is said angle of incidents equals angle of reflection. Well thats nice but that only deals with the angles in relation to eachother, how about in relation to the world? It would be nice to have a simple formula to calculate the angle of reflection in relation to angle zero. And not have to worry about the angles in relation to eachother, and which side of the object you are on.
My drawing shows a formula I came up with. Where angle A is the angle of a flat surface in relation to zero and B is the angle at which the object is moving, in relation to zero. Read the diagram.
First we subtract A from B, and A from A to rotate the whole picture so that Angle A is zero. When an object impacts a flat surface who's angle is zero, it returns at the negative of angle at which it was moving, whether it hits it from above or below. Now that we have the correct reflection, we must add the original value of A again to rotate it back to where it was. This gives us the correct angle of reflection.
Now lets take a look at what we did:
We took the original angle B and subtracted angle A:
(B - A)
We reversed the sign of the this differance
-(B - A)
Then added angle A to find the angle of reflection
-(B-A) + A
Angle of reflection = 2A – B where A is the angle of a flat surface, and B is the angle at which the incoming object is moving. Hardly complicated, but fun to figure out all the same. :-)
Last edited by mikau (2005-10-29 12:19:10)