-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The book uses column-major order for matrices, while three.js docs use row-order #27
Comments
Hey, good catch. Actually neither is incorrect - the difference is because there are two conventions for writing matrices called row-major and column-major ordering. Internally, three.js matrices are stored in column-major order. However, for some reason the If the 4x4 matrix is made up of four vectors:
Then we can write the matrix in row major order (each vector makes up a row): Mr = (
a, b, c, d,
e, f, g, h,
i, j, k, l,
m,n,o,p
) Or column-major order (each vector makes up a column): Mc = (
a, e, i, m,
b, f, j, n,
c, g, k, o,
d, h, l, p
) Then a transformation matrix representing an X rotation around θ can be written either in row major order: ROTXr = (
1, 0, 0, 0,
0, cos(θ), -sin(θ), 0,
0, sin(θ), cos(θ), 0,
0, 0, 0, 1
) or in column major order: ROTXc = (
1, 0, 0, 0,
0, cos(θ), sin(θ), 0,
0, -sin(θ), cos(θ), 0,
0, 0, 0, 1
) The docs follow the So there's two choices here: A. Current situation: write matrices to match the literature (e.g. realtime rendering book, wikipedia, several game math books that I checked) Neither one of these is correct so I'm open to suggestions. |
I tracked down the original reasoning here, way back in 2013. mrdoob/three.js#3814 (comment) Originally three.js stored matrices internally in row-major (I guess from pre-WebGL days) but then switched (in r49) to column-major for efficiency and to match other WebGL/OpenGL libraries. To help with backwards compatibility they kept the |
Thanks to the work you have done. |
Describe the bug
When i was reading about transformation matrices topic in this book, i found that the description of formula of X-Rotation has a little difference with the makeRotationX method of Matrix4 class in official docs. I didn't know which one was correct. So, i report a issue here now.
Screenshots
Transformation Matrices
makeRotationX method of Matrix4 class
The text was updated successfully, but these errors were encountered: