views:

69

answers:

2

I recently started reading OpenGL Superbible 5th edition and noticed the following:

Equation in question

Having just taken linear algebra this seemed odd to me. The column vector is of dimension 4x1 and the matrix is 4x4, how is it possible to multiply them together? If the vector were a row-vector and the output were a row vector I agree that it would be possible, but this?

Update: I emailed the author and he said that I was correct. He noticed the order was wrong in the previous edition of the book, however it ended up not being fixed in the 5th edition.

+4  A: 

I agree: it should be a column vector that's pre-multiplied by the identity matrix.

If it's a row vector, then the RHS needs to be a row vector as well to make the dimensions match.

duffymo
+3  A: 

This is not a typo or an error, it's a common way in 3D graphics to express vector-matrix multiplications. But mathematically speaking, you are correct : the left vector should be written horizontally. In 3D you will never see this, though.

Calvin1602
The GL specification disagrees. It's mathematically correct there. (better, the GL spec uses Mat x Col and Row x Mat, based on whether you deal with positions or normals).
Bahbar
That's nonsense. You can't multiply a 1x4 matrix by a 4x4 matrix. This book merely uses a handy shortcut notation.
Calvin1602
not sure what you mean. Mat x Col and Row x Mat are 2 fine operations. In general, you can always multiply NxM and MxP matrices to produce a NxP matrix (see http://en.wikipedia.org/wiki/Matrix_multiplication). That's what the GL spec does (4x4 X 4x1 = 4x1, 1x4 X 4x4 = 1x4).
Bahbar
I just mean that 4x1 X 4x4 is undefined :)
Calvin1602