You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation of matrix() points out that the 16-float constructor form accepts values in row major order, and the [][] operator accepts first a row and then a column. However that by itself is not meaningful, it also needs to specify if matrices have basis vectors in rows or columns. Depending on that choice:
A translation matrix may be either matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, tx, ty, tz, 1), or matrix(1, 0, 0, tx, 0, 1, 0, ty, 0, 0, 1, tz, 0, 0, 0, 1).
The expression point p3 = transform(M1 * M2, p1) may be equivalent to either point p2 = transform(M1, p1) ; point p3 = transform(M2, p2);, or point p2 = transform(M2, p1) ; point p3 = transform(M1, p2);
In algebraic terms, that matrix multiplication would look like $\mathbf{p}\mathbf{M}_1\mathbf{M}_2$ (if vectors are rows), or $\mathbf{M}_2\mathbf{M}_1\mathbf{p}$ (if vectors are columns).
The text was updated successfully, but these errors were encountered:
roelandschoukens
changed the title
Matrix layout is undocumented
Matrix layout is only partially documented
Oct 28, 2024
The documentation of
matrix()
points out that the 16-float constructor form accepts values in row major order, and the[][]
operator accepts first a row and then a column. However that by itself is not meaningful, it also needs to specify if matrices have basis vectors in rows or columns. Depending on that choice:matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, tx, ty, tz, 1)
, ormatrix(1, 0, 0, tx, 0, 1, 0, ty, 0, 0, 1, tz, 0, 0, 0, 1)
.point p3 = transform(M1 * M2, p1)
may be equivalent to eitherpoint p2 = transform(M1, p1) ; point p3 = transform(M2, p2);
, orpoint p2 = transform(M2, p1) ; point p3 = transform(M1, p2);
In algebraic terms, that matrix multiplication would look like$\mathbf{p}\mathbf{M}_1\mathbf{M}_2$ (if vectors are rows), or $\mathbf{M}_2\mathbf{M}_1\mathbf{p}$ (if vectors are columns).
The text was updated successfully, but these errors were encountered: