   [D3D10] Matrix byte order
  Hello,since some days I had to switch from OpenGL to DirectX due to a decission, that my science project should use DirectX. So I started learning DirectX using the DirectX 10 SDK.I'm very familiar with computer graphics and very firm with OpenGL. But there's a question, I couldn't really find an answer to.How is the byte ordering in D3D10 Matrices? that means in fact, if I have a 16 element float array describing a 4x4 matrix, where's the translation vector? is it in elements 12, 13, 14 (begining at 0)? Or in elements 3, 7, 11 (which, in fact, is the transposed matrix)?Thanks for help!Bastian   
  it's the ancient row vs column matrices discussion ;)OpenGL uses a column matrix:1 0 0 X0 1 0 Y0 0 1 Z0 0 0 1while DirectX uses a row matrix:1 0 0 00 1 0 00 0 1 0X Y Z 1;Quote:Original post by Yourselfit's the ancient row vs column matrices discussion ;)OpenGL uses a column matrix:1 0 0 X0 1 0 Y0 0 1 Z0 0 0 1while DirectX uses a row matrix:1 0 0 00 1 0 00 0 1 0X Y Z 1That doesn't answer the question.What you've shown above is a column-basis matrix (i.e. a matrix intended for use with column vectors) as opposed to a row-basis matrix (i.e. a matrix intended for use with row vectors), but that doesn't tell us anything about byte order or how the matrix is laid out in memory.@The OP: Unless something has changed between DX9 and DX10, the translation elements are 12, 13, and 14.To be more specific, the DX math library use row vectors (as shown above) and row-major matrix order (not shown above). When the vector notation convention and matrix layout 'match' (i.e. row-row or column-column), the elements of the basis vectors are contiguous in memory, which means (among other things) that the translation elements of an affine transform reside in elements 12, 13, and 14.If the vector notation convention and matrix layout don't match (row-column or column-row), you get the transpose of that (translation in elements 3, 7, and 11, as you noted).Since OpenGL is typically thought of as being column-column, and since DirectX is row-row, OpenGL and DirectX matrices are actually arranged in memory exactly the same way (that is, they have the same 'byte order', and for both APIs, the translation is in elements 12, 13, and 14).   ;  Thank you jyk, that answered my question.I googled a lot and in nearly all cases I found the discussion about row or column-major. But this doesn't need to have anything to do with the memory layout. it's "just" a mathematical point of view. @yourself: you can have a column major and a row major matrix stored exactly the same way in memory, means you can store both matrices so that you can't decide which is which (if you "just" look an the bytes in memory). It's a mathematical decission which one to use. It depends further on using row- or column vectors and using pre- or post-multiplying.;Quote:I googled a lot and in nearly all cases I found the discussion about row or column-major. But this doesn't need to have anything to do with the memory layout. it's "just" a mathematical point of view. @yourself: you can have a column major and a row major matrix stored exactly the same way in memory, means you can store both matrices so that you can't decide which is which (if you "just" look an the bytes in memory). It's a mathematical decission which one to use. It depends further on using row- or column vectors and using pre- or post-multiplying.I might be misunderstanding your post, but it seems to me that there are a few inaccuracies here.Row-major vs. column-major is only about memory layout, and has nothing (directly, at least) to do with mathematics.Row vectors vs. column vectors is only a mathematical convention, and has nothing (directly, at least) to do with memory layout.As I understand it at least, whether you 'pre-multiply' or 'post-multiply' is just a consequence of whether you're using row vectors or column vectors, so it's not a separate issue in and of itself. (In other words, there are only two issues to consider here - matrix 'majorness' and vector notation convention.)Matrix 'majorness' means one thing and one thing only: whether the matrix elements are stored in memory by row and then by column or by column and then by row, i.e.:A row-major 4x4 matrix as stored in 16 contiguous 'memory slots':[ 0  1  2  3  ][ 4  5  6  7  ][ 8  9  10 11 ][ 12 13 14 15 ]A column-major 4x4 matrix as stored in 16 contiguous 'memory slots':[ 0  4  8  12 ][ 1  5  9  13 ][ 2  6  10 14 ][ 3  7  11 15 ]'Majorness' is purely a programming issue - it has nothing to do with math.Vector notation convention, however, is a 'pure' mathematical issue (in the sense that it's still relevant, for example, if we do some linear algebra on paper without ever touching a computer). When we use matrices to represent geometrical transforms, when using row vectors the basis vectors of the transforms end up in the matrix rows, and when using column vectors the basis vectors end up in the matrix columns.Although the two issues (majorness and vector notation convention) are conceptually orthogonal, they interrelate with one another in practice (as described in my earlier reply).   