5
$\begingroup$

For column-major rotation matrices (right up forward in columns) do you right-multiply (post-multiply?) a row vector or left-multiply (pre-multiply) a column vector to result in a correct/valid transformation? Or are both "valid" but just transform different spaces?

In case I'm getting my terminology wrong, suppose we have 3x3 column-major matrix R. Is it R * V for column-major matrix, where V is 3x1? Or is it V * R for column-major matrix, where V is 1x3? What about for row-major?

Thanks so much for the help!

Edit: I believe my question needs further clarification. I am more confused about whether a vector, regardless if it's a row or column, is multiplied to the left or right of a row specific majored matrix. And vice versa for column-majored matrix, but it would be implied by answering either which one. I do understand the concept that transposing a matrix will just mean you have to transpose the vector and flip the order of multiplication, which will result in the same thing because you're multiplying the same elements the other way around. That is not the concern of my question (though thanks for those who answered that part). When I say row specific (or column), I'm talking about the way the right up forward vectors are positioned in the matrix. Though at this point, I think I already have figured out my answer just by typing this, but will leave it open for answers.

My question is simply this: (sorry, I don't know how to format things here)

I have the following matrix composed of Right Up and Forward vectors:

Rx Ry Rz

Ux Uy Uz

Fx Fy Fz

This is a row-majored, orthonormal rotation matrix. Now I have a vector V as {V1 V2 V3} as either a 3x1 or 1x3 (right side or left side respectively, else the multiplication doesn't even work out). Is it R * V or V * R in this case of a row-major matrix? Again, not asking about 1x3 on left or 3x1 on right, but rather for a row-specific matrix, which way would produce a valid or meaningful transformation?

{V1*Rx + V2*Ry + V3*Rz, V1*Ux + V2*Uy + V3*Uz, V1*Fx + V2*Fy + V3*Fz} ?

OR

{V1*Rx + V2*Ux + V3*Fx, V1*Ry + V2*Uy + V3*Fy, V1*Rz + V2*Uz + V3*Fz} ?

I'm guessing the second, but would like clarification/confirmation. Thank you again!

$\endgroup$
3
  • $\begingroup$ You can actually try it and see if it results in a expected result or not. Note that matrix multiplication is only valid for the column vector comig after the matrix and row coming before due to the way matrix multiplication is defined. But you can allways transpose the vector resulting in the same thing (if the matrix chain is computed first) $\endgroup$
    – joojaa
    Jun 13, 2017 at 19:47
  • $\begingroup$ Also note that for a pure rotation matrix the inverse is a transpose. $\endgroup$
    – joojaa
    Jun 14, 2017 at 5:56
  • $\begingroup$ Rather than the 3x3 matrix, I think it'd be more instructive to use a 4x4 so as to include a translation part. That way you should get a clearer understanding of ordering etc. $\endgroup$
    – Simon F
    Jun 14, 2017 at 10:56

2 Answers 2

1
$\begingroup$

TL;DR

Let $M=\Biggl[\begin{matrix} Rx & Ux & Fx\\ Ry & Uy & Fy\\ Rz & Uz & Fz\\ \end{matrix}\Biggl], V = \Biggl(\begin{matrix}Vx\\ Vy\\ Vz \end{matrix}\Biggl)$

The correct multiplication is: $V' = M V$ or $V'^T = V^TM^T$

Now to the proper explanation:

Whenever we define a coordinate in $R^{3}$ space that coordinate must be in respect to a basis. When one state that an arbitrary point in $R^{3}$ is $(x, y, z)$ it is implicit that this is in respect to the standard basis. Let's call $\vec{r}, \vec{u}, \vec{f}$ the axes that define an arbitrary basic $B$ in $R^{3}$. An arbitrary point $P$ can be defined as $$P = x * \vec{r} + y * \vec{u} + z * \vec{f}$$

Expanding we have:

$$P_x = x * \vec{r_x} + y * \vec{u_x} + z * \vec{f_x}$$ $$P_y = x * \vec{r_y} + y * \vec{u_y} + z * \vec{f_y}$$ $$P_z = x * \vec{r_z} + y * \vec{u_z} + z * \vec{f_z}$$

In matrix form we can write that as: $$\Biggl(\begin{matrix}P_x\\ P_y\\ P_z\\ \end{matrix}\Biggl)=\Biggl[\begin{matrix} \vec{r_x} & \vec{u_x} & \vec{f_x}\\ \vec{r_y} & \vec{u_y} & \vec{f_y}\\ \vec{r_z} & \vec{u_z} & \vec{f_z}\\ \end{matrix}\Biggl]\Biggl(\begin{matrix} x\\ y\\ z\\ \end{matrix}\Biggl)$$

Another easy way to check this is to think about what is a rotation matrix. The matrix $$R_z = \Biggl[\begin{matrix} cos(\theta) & -sin(\theta) & 0\\ sin(\theta) & cos(\theta) & 0\\ 0 & 0 & 1\\ \end{matrix}\Biggl]$$ rotates a vector $\vec{v}$ by $\theta^{\circ}$ around $z$ axis or, to think in another way, represents $\vec{v}$ in a basis that is rotated $\theta^{\circ}$ from the standard basis. If you compute the axes of this new rotated basis you'll see that the new $\vec{r}, \vec{u}, \vec{f}$ of this rotated matrix are the columns of $R_z$ matrix.

$\endgroup$
2
  • $\begingroup$ Great answer, and thanks for a thorough explanation. I believe this is exactly what I'm looking for, though I'll need to reread your answer several more times to get it through in my head haha. But please fix your original M matrix to include z. Thank you again, good sir! $\endgroup$
    – Matthew L
    Jun 19, 2017 at 18:28
  • $\begingroup$ Thanks @MatthewL for noticing that error. Just fixed it now! $\endgroup$ Jun 20, 2017 at 15:54
3
$\begingroup$

Okay let us start by pointing out that a colmun major matrix is the same as a transposed row major matrix. So:

$$ {M_{cm}}^{T} = M_{rm} \tag{1} $$

Then notice that matrixes have following properties. Matrix multiplication is associative (2a) and that the distribution of transpose reverses computation order (2b).

$$ A(BC) = (AB)C \tag{2a} $$ $$ (AB)^T = B^TA^T \tag{2b} $$

From these follow that the chain of multiplication events can be as long as one likes and all transpose does is inverse the computation. So given that we can conclude

$$ {T_1}\ {T_2}\ \ldots\ {T_n}\ \vec{v} = \vec v\,^T\ {T_n}^T\ \ldots\ {T_2}^T\ {T_1}^T, \tag{3} $$

so calculating in column major order is the same calculation as calculating in row major orientation. The difference is that the order of computation is reversed. An interpretation of this is that the difference is the same as looking at the object from the outside or looking at the situation from the object out.

Formula 3 should provide you the insight. Just one more thing a column vector is the same as a transpose of a row vector.

Note: You are allowed to mix and match the computations as much as you like. All you have do is remember is that the other approach is just transposed.

$\endgroup$
1
  • $\begingroup$ Thank you so much for sharing your knowledge. Please read my clarification edit. Thanks again. $\endgroup$
    – Matthew L
    Jun 13, 2017 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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