   D3DXVec4Transform question, matrix transposed
  I have a problem understanding the matrix-vector-product in D3DX. The is an old topic I found, but it is retired, so I post my question again.My problem:If I set the elements of a 4x4 matrix A and a 4D vector b by hand and compute their product with D3DXVec4Transform, I get a different result than if I compute it by hand or any math software. What I get is AT*b instead of A*b, which I was expecting (or guessing, since MSDN doesn't say anything).I set the elements with the D3DXMATRIX element access operator, so I expected the element (i,j) to be the i-th row and j-th column:FLOAT& operator () ( UINT Row, UINT Col )Also, I was expecting a standard math notation with rows being horizontal, columns vertical, vectors being column vectors and for x=A*b, x[0] = A(0,0)*b[0] + A(0,1)*b[1] + A(0,2)*b[2].Someone in the old post mentioned row-major and column-major matrices, but (according to wikipedia) the matrix order is just a "method for storing multidimensional arrays in linear memory", so this shouldn't make my matrix transposed.So what am I missing? :)   
Quote:Original post by crobiSomeone in the old post mentioned row-major and column-major matrices, but (according to wikipedia) the matrix order is just a "method for storing multidimensional arrays in linear memory", so this shouldn't make my matrix transposed.it will transpose it depending on row/colum major.in linear memory:0 1 2 3 4 5 6 7 8row major:0 1 23 4 56 7 8column major0 3 61 4 72 5 8How are you entering these matrices?   ;  I am entering the matrices with a the operator I mentioned, as in this example:D3DXMATRIX mat;D3DXVECTOR4 vec;for(unsigned int uiRow = 0; uiRow < 4; uiRow++){vec[uiRow] = (float) uiRow;for(unsigned int uiColumn = 0; uiColumn < 4; uiColumn++){mat(uiRow, uiColumn) = (float) (uiRow*4 + uiColumn);}}D3DXVECTOR4 product;D3DXVec4Transform(&product, &vec, &mat);This should get me the matrix0  1  2  34  5  6  78  9  10 1112 13 14 15And the vector0123And the product14 = 0*0  + 1*1  + 2*2  + 3*338 = 0*4  + 1*5  + 2*6  + 3*762 = 0*8  + 1*9  + 2*10 + 3*1186 = 0*12 + 1*13 + 2*14 + 3*15Instead I get56 = 0*0  + 1*4  + 2*8  + 3*1262 = 0*1  + 1*5  + 2*9  + 3*1368 = 0*2  + 1*6  + 2*12 + 3*1474 = 0*3  + 1*7  + 2*11 + 3*15As I never access the linear memory, I don't see how the matrix order should matter.   ;  Each graphics system needs to make clear what its conventions are.  For matrix storage, you have row-major order or column-major order.  For matrices applied to vectors, you have (column) vector on the right or (row) vector on the left.  Note that rowMajor+vectorOnRight produces the same output as colMajor+vectorOnLeft.  rowMajor+vectorOnLeft produces the same output as colMajor+vectorOnRight.The reference documentation for D3DXVec4Transform in directx_sdk.chm does not state what the conventions are.  The D3DMATRIX documentation makes it clear that the matrix is stored in row-major order.  When you go to the "contents" tab and select "DirectX Graphics | Direct3D 9 | Programming Guide | Getting Started | Transforms", the "Matrix Transform" section shows that the convention for application to a vector is vectorOnLeft.  The order of the inputs to D3DXVec4Transform hint at this.  To be clear, what you are computing is bT*A, which produces the same 4-tuple as AT*b, but stresses the order of operands.It is as equally important for a graphics system to specify how it represents rotations with matrices.  Not everyone chooses the same conventions.;  Thank you for this very good explanation! The key for me was understanding that D3D uses row vectors. I am about to rewrite my linear algebra classes (yes I have reasons [smile]), so I needed to know how D3DX works.I probably should have read the getting started section even if I have been using D3D for some time now. And also the fact that my code had an operator which allowed me to write A*b confused me. I guess there is a reason why such an operator is not provided by Microsoft.   