rotation matrix difference between row vs. column representations I have the direction vectors Dx, Dy and Dz of a local coordinate frame of an object w.r.t. a global coordinate frame. They are given as:
$$
    Dx = \begin{bmatrix}
    i1 & j1 & k1 \\
    \end{bmatrix}
$$
$$
    Dy = \begin{bmatrix}
    i2 & j2 & k2 \\
    \end{bmatrix}
$$
$$
    Dz = \begin{bmatrix}
    i3 & j3 & k3 \\
    \end{bmatrix}
$$
Now, I know in order to create my rotation matrix, I have to arrange these vectors either row-wise like this:
$$
    M = \begin{bmatrix}
    i1 & j1 & k1 \\
    i2 & j2 & k2 \\
    i3 & j3 & k3\\
    \end{bmatrix}
$$
or column-wise like this:
$$
    M = \begin{bmatrix}
    i1 & i2 & i3 \\
    j1 & j2 & j3 \\
    k1 & k2 & k3\\
    \end{bmatrix}
$$
I intend to use this to transform a point P
$$
    P = \begin{bmatrix}
    x \\
    y \\
    z \\
    \end{bmatrix}
$$
in the following manner P' = M * P:
$$
    P' = M * \begin{bmatrix}
    x \\
    y \\
    z \\
    \end{bmatrix}
$$


*

*Which form of the matrix M above is correct and how do I intuitively think about it?

*Does M transform the point from local coordinate frame to global coordinate frame? Or from global coordinate frame to local? 


Thank you 
 A: The answer is: it depends on which convention you want to adopt since both are equivalent.
If you choose to use column-major matrix, then you are in agreement with most standard mathematical textbooks. In such textbooks (and also wikipedia), the column-major matrix $M$ will transform the column vector $P$ as:
$$P' = M P$$
You can interpret thar matrix as sending $P$ from local to global frame if you like. In the particular case of $M$ being a rotation matrix, its transpose (i.e., the row-major version of it, in this case) is equal to its inverse $M^{-1} = M^T$. The reason is that any rotation matrix is an orthonormal matrix. So the inverse mapping is:
$$P = M^T P'$$
Getting back the original vector $P$. Now if you multiply two column-major matrices $M_1$ and $M_2$ the resulting matrix $M_3 = M_1 M_2$ applies both transformations in the following order:
$$P' = M_3 P = (M_1 M_2) P = M_1 (M_2 P)$$
Wich is kind of backwards order for some authors (to me its just fine). 
Now, compare the above to choosing the row-major matrix convention, then you are in agreement with some other authors and some popular software packages. The row-major matrix $M$ will transform the column vector $P$ as:
$$P'^T = P^T M$$
As you can see we obtain the same vector $P'$ than before but transposed (i.e., as a row vector). Which is not a problem at all. As in the other case you can also interpret that matrix as sending $P$ from local to global frame. Again, for a rotation matrix, its transpose is equal to its inverse $M^{-1} = M^T$, so the inverse operation is:
$$P^T = P'^T M^T$$
As expected. Finally, if you multiply two row-major matrices $M_1$ and $M_2$ the reaulting matrix $M_3 = M_1 M_2$ will apply the two transformations in the following order (opposite to the column-major order):
$$P'^T = P^T M_3 = P^T (M_1 M_2) = (P^T M_1) M_2$$
Which might be interpreted as more natural order for some authors.
Note that we should not mix row-major and column-major matrices. Having said that, you might see some authors doing an abuse of notation which is very confusing. In any case the proper way to mix them is thinking about one of them as being transposed. For instance you might see several software packages in which they multiply a row-major matrix $M$ with the column vector $P$ on the right side (instead of on the left side as in previous discussion):
$$P'' = M P = (P^T M^T)^T$$
We can see that they are actually multiplying the transpose of $M$ with $P$ and then taking the transpose of the result. So the result of that operation is not $P'$ as in the other samples, it is something else.
