Order of the Values in the Matrix

Started by AGP, March 05, 2010, 09:47:05 PM

Previous topic - Next topic

AGP

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

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:


                        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.

AGP

I read the wikipedia on row major. Not completely clear to me yet. Does anyone have any idea about Max's 4x3 matrices?

EgonOlsen

Conversion between row- and column-major isn't difficult. If this is a row-major matrix:


a b c d
e f g h
i j l m
n o p q


then this is the column major variant:


a e i n
b f j o
c g l p
d 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.