1
$\begingroup$

I have taken a linear algebra course however now that I have a project involving it I find myself extremely confused by two things. You see the class taught me that AB is not the same as BA but what it didnt help me out with is the ordering.

Yes, I can write out a list of what I need to do to a point but I am confused by which matrix goes on the left or the right. For example if I wanted to take a vector v in a screen space, scale it with matrix S then rotate it with matrix R then translate it with matrix X would the correct operation be v * S * R * X or (S * R * X) * v or S * R * X * v furthermore what is the ordering of these multiplications?

To calculate v * S * R * X can I do it like this (((v * S) * R) * X) or would it need to be like this (v * (S * (R * X))) or something completely different like v * (S * (R * X)) which of these are even equivalent? How do I know?

On top of that confusion I am wondering if a certain property holds however I am having the hardest time testing it because I am not certain about all the ordering/steps stuff above.

Is (S * R * X)^-1 the same as S^-1 * R^-1 * X^-1 or X^-1 * R^-1 * X^-1 or none of the above? You can see how determining this would be difficult without firm footing on the steps.

Could you please help me clear up which above statements are correct and how I can put parenthesis in these statements without changing the meaning and whether the vector gets multiplied on the left or the right? Additionally does that inverse property hold at all?

If it helps I am working with 3x3 matrices exclusively. Technically I am transforming 2D points with 2D transformations however I have to extend my point to a vector (p.x, p.y, 1) in order to be able to do the transform calculations.

$\endgroup$
  • $\begingroup$ Fortunately, matrix multiplication is associative, so as long as you don't change the order, adding parentheses or not won't change the result. $\endgroup$ – Rylee Lyman Jan 28 '19 at 3:03
  • $\begingroup$ So based on that v * (S * R * X) would be different than (S * R * X) * v why is this though? If I assume that (S * R * X) results in a matrix that does transformation T. $\endgroup$ – J.Doe Jan 28 '19 at 3:06
0
$\begingroup$

When I do matrix operations, I typically will put the vector all the way on the right, and then for each operation I want to do, I'll add it to the left. So to take a vector $v$, and scale it with $S$, I would write $Sv$. To then rotate it via $R$, and then translate it with $T$, I would write $TRSv$.

The inverse of $TRS$ is $S^{-1}R^{-1}T^{-1}$. You can check this algebraically because when you write them next to each other, you can perform the cancellation without having to move anything—remember, because in general $AB \neq BA$, we should avoid swapping the order at all costs.

NB – What I described in the first paragraph is one convention. Since it is possible to multiply an $n\times n$ matrix and a vector on the left or on the right depending on whether you think of the vector as a $1\times n$ or $n\times 1$ matrix, you could write a consistent program using either standard. If you are working off of some preexisting structure, I would advise trying out both ways to get a feel for which is correct.

| cite | improve this answer | |
$\endgroup$

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.