### Author Topic: Order of the Values in the Matrix  (Read 2972 times)

#### AGP

•      • Posts: 1724 ##### Order of the Values in the Matrix
« on: March 05, 2010, 09:47:05 pm »
I'm trying to convert between Max's camera matrix to jPCT (which, by the way, will make for a good Wiki). Problem is that the documentation doesn't specify how the matrices are arranged (just that it's a 4x4 matrix), and jPCT's matrix doesn't match Max's. So, what is the order?

#### EgonOlsen

•     • • Posts: 12287 ##### Re: Order of the Values in the Matrix
« Reply #1 on: March 05, 2010, 09:50:35 pm »
Like the docs for Matrix state: All matrices in jPCT are row major....and that's true, as long as you are using the set()-method in Matrix. If you are using setDump() to set a float, it's different. That one does this:

Code: [Select]
`                        int cnt = 0; for (int i = 0; i < 4; i++) { mat[i] = dump[cnt]; mat[i] = dump[cnt + 1]; mat[i] = dump[cnt + 2]; mat[i] = dump[cnt + 3]; cnt += 4; }`With i being the row, [0...3] the columns.

#### AGP

•      • Posts: 1724 ##### Re: Order of the Values in the Matrix
« Reply #2 on: March 05, 2010, 10:20:11 pm »
I read the wikipedia on row major. Not completely clear to me yet. Does anyone have any idea about Max's 4x3 matrices?

#### EgonOlsen

•     • • Posts: 12287 ##### Re: Order of the Values in the Matrix
« Reply #3 on: March 05, 2010, 11:13:09 pm »
Conversion between row- and column-major isn't difficult. If this is a row-major matrix:

Code: [Select]
`a b c de f g hi j l mn o p q`
then this is the column major variant:

Code: [Select]
`a e i nb f j oc g l pd h m q`
Plus, if your are doing matrix multiplications, the order changes. I.e. a*b with row-major matrices becomes b*a for column-major.