Matrix4 documentation confusion

The section regarding Row vs Column order in the Matrix4 documentation claims the order of elements is column major (translation occupies indices 3,7,11) but when logging the array translation occupies indices 12,13,14 (row major). The next assumption is that, given the math is done around the elements array, is the math also row major? Or am I reading the page wrong completely?

My test:

// r.0.135.0
const b = new THREE.Matrix4().makeTranslation(2, 2, 2);
console.log(b.elements);

My output:

0: 1
1: 0
2: 0
3: 0 // expected 2
4: 0
5: 1
6: 0
7: 0 // expected 2
8: 0
9: 0
10: 1
11: 0 // expected 2
12: 2 // expected 0
13: 2 // expected 0
14: 2 // expected 0
15: 1

This isn’t correct. The last 4 elements should be the translation elements in a column major representation. See the wikipedia article illustration.

2 Likes

Are you referring to the illustration on with the arrows? I guess I misunderstood the graphic. If I follow the arrow it goes a11, a21, a31, a41, where i assumed a41 is x translation, and I thought, oh its the 4th element in the list.

I mean I have to believe I’m wrong since, 1) this is a fundamental part of the code that if it was wrong everything would break 2) the math is column major so the data, must also be column major or again, everything would break. I guess I’m just finding all the material confusing.

I see where I went wrong. for reasons, probably from forever ago, I fixed a41,a42,a43 with translation in my mind, when really, they are just indices. a41 does NOT implicitly mean, translation x.