Let's say I have a right handed column major 4x4 transformation matrix. Can I safely assume (even though there exist non uniform scale) that first column is X axis vector, second column is Y axis vector and third column is Z axis vector?

$$ \begin{bmatrix} Xx & Yx & Zx & 0 \\ Xy & Yy & Zy & 0 \\ Xz & Yz & Zz & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} $$

Iis the above layout correct? By the way I am using glm and I don't know if there is a function to extract these axis.

  • 1
    \$\begingroup\$ Thought it was rows that held the axis. For X,Y,Z axis on rows 0,1,2. But it makes no difference as long as the vectors are in the appropriate direction, If transform matrix axis are along rows then a vector is a column and if axis a column then vectors are a row \$\endgroup\$ – Blindman67 Oct 19 '16 at 12:27

Yes, in GLM it is laid out as such:

$$ \begin{bmatrix} ux & vx & nx & tx \\ uy & vy & ny & ty \\ uz & vz & nz & tz \\ 0 & 0 & 0 & 1 \end{bmatrix} $$

Where the vector t is translation, and the top-left 3x3 matrix is rotation.

You can also use the GLM method decompose(...).

Note that the documentation is outdated - you need to include <glm/gtx/matrix_decompose.hpp> instead of <glm/gtx/decomposition.hpp>


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.