   Vector relection Formula Explanaton
  Hello !I'm trying to understand the math behind the vector reflection formula:RefVect = 2N (N dot Vect) - VectI'have search the web for explanations, but i do not find anything very clear (Most of the time, thy just give the formula without explanations...)I wanna use this formula in my program, but i wanna understand how it work before...Can you help me to understand it ?I know what are cross and dot product, but i do not get this formula ...Thanks  a lotClement ...   
  Do you know what a vector projection is?I won't be making any nice pictures, but I encourage you to do so, as it's probably essential to understanding something geometrical like this...If you have two coplanar vectors, imagine sticking them with their start points together, so they point off in different directions from that start point.Now imagine one of those vectors is a ray that goes on forever away from that start point.Now, draw a line from end of the the vector that still has a length, to the ray.  Draw that line so that the line is perpendicular to the ray.If you made a new vector, which is from the point where the new line meets the ray, to the tip of the other vector, you've got the projection of the vector onto the normal vector of the vector that was turned into a ray.If you made another new vector, which is from the start point of the two original vectors, to the point where the new line meets the ray, you have to projection of the non-ray vector onto the ray-vector.Mathematically, the magnitude of a vector does not affect the magnitude of any vector projection in its direction (hence the business about imagining an infinite length ray).Also, if you take the projection of a vector onto another vector, and add it to the projection of the same vector onto the normal of the the other vector, you get back the original vector.  You can call these to projected vectors the components of the non-ray vector onto the ray-vector.  This works just like taking the components of a vector in the x and y directions, but you've just taken them in the ray and perpendicular-to-ray directions.In order to calculate the projection of the non-ray vector onto the ray-vector, what you do is make a new vector which has direction given by the normalized ray-vector direction, and length given by the dot product of the normalized ray-vector and the vector being projected onto the ray-vector.  Since normalized vector in the direction of the ray-vector has length 1, the projection is justD(D dot Vect)where D is the normalized vector in the direction of the ray-vector, and Vect is the vector being projected.Similary, projecting on the the normal to the ray-vector gives the perpendicular component of the other vectorN(N dot Vect)What's happening in a reflection is that the component of the reflected vector in the direction normal to the surface is being changed, but the parallel component is not.  These components are the projections of the reflected vector onto the normal or the tangent (parallel) vectors to the surface.Also, note that since if you add the components of a vector together, you get that vector, you can also subtract a component from a vector to get the other component.  So, if you take the vector being reflected, and subtract its normal component, you get the component parallel to the reflection plane.If you subtract the normal component from the parallel component, you get a vector with the same parallel component, but with a normal component in the opposite direction from the original vector... which is a vector that has been reflected by the vector you were taking components in the direction of.So, the formula:RefVect = 2N (N dot Vect) - Vectseems a bit off to me... I think it should beRefVect = Vect - 2N (N dot Vect)So what's happening is that you take Vect, find it's component N (N dot Vect) in the direction N normal to the reflection line, then subtract that from Vect once to get the vector projection of Vect onto the reflection line, then subtract the normal projection again to get the reflected vector.   ;  I would give you a link to a MathWorld page with a detailed diagram, but it appears I've been banned for "mass downloading" when I have downloaded absolutely nothing...So with that said, I'll give it my best shot to explain without any fancy graphics. I assume you understand the fundamental vector operations of dot and cross product, addition, and it's inverse.Imagine a ball flying rightwards at a wall and you wish to properly bounce the ball off the wall ignoring the underlying physics. Then your goal is equivalent to negating that component of the ball's velocity vector which is normal to the wall, or equivalently parallel with the normal to the wall.Call the normal to the wall n. Assume it to be normalized for simplicity. Then the component of the ball's velocity vector (call it v) parallel to n is v.n, where '.' denotes vector dot product. This can be verified by simple trigonometry, and is also the projection of v onto n.Convert this magnitude to a vector by multiplying by n. Then, negate the component or equivalently "flip it over" by subtracting twice n(v.n) from v. Intuitively, subtracting n(v.n) once reduces that component of v parallel to n to 0. Subtracting a second time makes it the negation of it's original self. Thus the formula is v' = v - 2n(v.n).HTN,nilkn   ;  Of course the exact formula depends on what your input vectors are.  If the incident vector Vect happens to face away from the surface (such that Vect dot N > 0) then you'd use the formula 2N(N dot Vect) - Vect, otherwise if Vect is reversed to face toward the surface you'd use Vect - 2N(N dot Vect).  Both cases are plausible, although the latter case is seen more often so I don't know why the former equation is most prevalent online.   