# www.jpct.net

## jPCT - a 3d engine for Java => Support => Topic started by: AGP on March 05, 2010, 09:47:05 pm

Title: Order of the Values in the Matrix
Post by: AGP 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?
Title: Re: Order of the Values in the Matrix
Post by: EgonOlsen 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[16], it's different. That one does this:

Code: [Select]
`                        int cnt = 0; for (int i = 0; i < 4; i++) { mat[i][0] = dump[cnt]; mat[i][1] = dump[cnt + 1]; mat[i][2] = dump[cnt + 2]; mat[i][3] = dump[cnt + 3]; cnt += 4; }`With i being the row, [0...3] the columns.
Title: Re: Order of the Values in the Matrix
Post by: AGP 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?
Title: Re: Order of the Values in the Matrix
Post by: EgonOlsen 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.