PDA

View Full Version : Spherical Mapping math HELP!

Purvis
02-05-2006, 04:46 PM
Hi,

I'll try posting this one here, as nobody replied on the beginners forum.

In short, I need to mimic OpenGL's spherical mapping in a vertex program, but I'm stuck with the math. The documentation says the reflection vector is not using the standard reflection formula, instead f is computed as:

f = u - 2n'n'T u

where u is the vector to position in eye-space and n' the normal in eye space. All this is ok, but what n'T means? What is the transpose of a vector and how is resolved in a multiplication?

I suppose the transpose of a column vector is the same, as a row vector.

If so, how do I multiply (in plain C) a column vector by a row vector (or viceversa) ?

Relic
02-05-2006, 10:11 PM
A standard matrix multiplication is row by column.
If you assume the vectors n' and n'T as matrices n' to be 3x1 and n'T to be 1x3 (row x colunm), then the multiplication n'n'T of these two gives a 3x3 matrix as result.
That's called outer multiplication, whereas inner multiplication is the dot-product.

Though the OpenGL 2.0 spec actually says
r = u − 2 nf^T (nf u)
So it's a dot product after all.

Check the OpenGL Programming Guide Appendix F, there is another example of this for the rotional matrix.

Purvis
02-06-2006, 05:29 AM
Thanks Relic. The notation bugged me, thinking it was not the standard reflection formula, that is using dot product and not the transpose of a vector. I got it working now!