Question

I have looked on several resources such as this http://antongerdelan.net/teaching/3dprog1/maths_cheat_sheet.pdf

I have found out that I am supposed to use column major ordering, the confusion comes in when I discover the answer of this question

Why does my translation matrix needs to be transposed?

the answer shows a translation matrix in column major ordering but the previous resource shows a translation matrix in column major ordering and it appears to be the transpose of the one shown in this answer.

I understand that the matrix in this answer is correct because I have tried it out and my transformation works. what I am trying to find is the column major scale, rotation and perspective matrices also written in this c++ array style notation rather that the one in the first resource.

Was it helpful?

Solution

According to a careful reading of

Why does my translation matrix needs to be transposed?

the difference is that the first page you are looking at is showing you the mathematical notation for your matrices, in which each single column is arranged along a vertical line; whereas the other notation you are looking at is a sequence of characters resembling something that might occur in your C++ code. There are many other differences, such as the tall square brackets in the math notation (which are impossible to reproduce exactly in C++ code, as there are no characters that span multiple lines), and the fact that there are no commas between the numbers in math notation.

But the main thing is that since the matrix is stored in column-major order, if you initialize the entries in the order in which they are stored (such as by using the notation for initializing an array from a comma-separated list), then x, y, z, and 1 will be the last four entries you will set in the matrix. And since C++ is always parsed as a linear string reading left to right (the parser doesn't care what number happens to be directly under what other number when you look at the listing), if you happen to format a list of 16 values in 4 rows of 4 values each, the last four values in the list are the ones on the last row of your format.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top