Deriving the matrix can be tricky. Let me try to help you out with this one. Once you see how to do it, it will help you figure out a lot of stuff. Try to hang with me here, as the logic can be a bit difficult to expain in text.
Lets assume we want to build a 4x4 matrix M, which we can multiply by a 4x1 vector P. When we multiply M*P we will get the reflected vector R. To make things simpiler, lets look at how to generate the first row of matrix M. When you think about it, to get the x component of vector R, we multiply (the first row of M) * P. Now, lets see again how we calculated the x component of reflected point again:
R = P-2*((P-V) dot N)*N
lets remove V from the equation. Lets use the plane description (A,B,C,D) where the normal N is actually the vector (A,B,C). We now have:
R = P-2*((P dot N)-D)*N
R.x = P.x - 2*(((P dot N)-D)*N.x
noting that P = (P.x,P.y,P.z) and that N = (N.x,N.y,N.z) = (A,B,C) we can rewrite this again (expanding the dot product too) as
R.x = P.x - 2*(P.xA + P.yB + P.z*C -D)*A
distributing the terms -2 and A, we get
R.x = P.x - 2AP.xA - 2AP.yB - 2AP.zC - 2A*D
regrouping terms and factoring out the P.* terms:
R.x = P.x*(1 - 2AA) + P.y*(-2AB) + P.z*(-2AC) + 1*(-2AD)
Noting that our coefficients of (P.x, P.y, P.z, 1) make our 4x1 vector P, it should be fairly simple to see how to put the remainder of the components into the first row of the matrix M. Repeat this process for the other 3 rows, and you should get the whole matrix.
Does this help? Kind of obscure in text, but hopefully it will be enough to point you in the right direction so you can solve these types of things on your own in the future. I had to use this technique to develop this reflection matrix function by hand, as I could not find a generic reflection matrix function anywhere I looked.
[This message has been edited by LordKronos (edited 10-12-2000).]