To me multiplication between matrices is mathematically defined something like:
R(r,c) = (A*B)(r,c) = A(r,:)*B(:,c)// for relevant r, c
.. where
R is the result matrix
A(r,c) means element on row r, column c of matrix A
A(r,:) means row r of A (a.k.a. row-vector)
B(:,c) means column c of B (a.k.a. column-vector)
The definition could be read aloud something like "the element on row r column c of the result matrix equals the scalar product of row vector r of A and column vector c of B".
Multiplying a row and a column vector means:
|b1|
|a1 a2 a3| * |b2| = a1b1 + a2b2 + a3b3 // similar to scalar-product of two vectors
|b3|
I'm not entirely sure what you mean by row-major; does it have anything to do with the ordering of the elements in a computer representation of a matrix using an array?
Comments
May 03
11:39:42Re: Column Major?
posted by Inertiahttp://www.opentk.com/node/138
May 03
13:19:18Re: Column Major?
posted by KamujinI think less efficiently when I am tired. I think I see my mistake now.
Can you check my order here?
In row major, modelViewProjection = projection * modelView? (not modelView * projection)
Is this right?
May 04
11:03:00Re: Column Major?
posted by InertiaModelView * Projection if memory serves right. There's a whole chapter dedicated to matrix operation at http://www.glprogramming.com/red/chapter03.html
in OpenTK.Math matrices are concatenated like this
// should be the same operation as:
GL.Matrixmode( ModelViewMatrix );
GL.LoadTransposedMatrix( A );
GL.MultTransposedMatrix( B );
GL.GetFloat( TransposedModelViewMatrix, out C.row0.X );
May 04
23:40:03Re: Column Major?
posted by KamujinYeah, I'm not using immediate mode though. I'm sending it to the shader as a uniform.
I wasn't confused until I started using the OpenTK math libraries with OpenGL via shaders. I just have to get it all sorted out in my head.
Thanks for the link. Its been a while since I've played with matrix ordering, so I am trying to get it straight in my head again.
May 05
08:59:05Re: Column Major?
posted by objarniI use this "mind model" when thinking of matrix ordering:
.. so matrix1 is applied 'last' and matrixN 'first', on the oldVec-vector.
May 05
22:34:02Re: Column Major?
posted by KamujinObjarni, your "mind model" is row major, correct?
May 06
11:42:55Re: Column Major?
posted by objarniMy mind model comes from linear algebra.
To me multiplication between matrices is mathematically defined something like:
.. where
The definition could be read aloud something like "the element on row r column c of the result matrix equals the scalar product of row vector r of A and column vector c of B".
Multiplying a row and a column vector means:
|a1 a2 a3| * |b2| = a1b1 + a2b2 + a3b3 // similar to scalar-product of two vectors
|b3|
I'm not entirely sure what you mean by row-major; does it have anything to do with the ordering of the elements in a computer representation of a matrix using an array?
May 06
21:45:29Re: Column Major?
posted by KamujinI think thats row-major notation.
There is information on row-major vs column-major matrices at the following link.
http://lists.apple.com/archives/Mac-opengl/2000/Dec/msg00045.html