This topic is 4847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Is it possible to combine multiple rotation and translation matrices in a specific order? For instance, say i want to first rotate, then translate, then rotate again, and then translate again. How do i do that? Can i take the first rotation matrix, add to it the first translation matrix, then multiply by the 2nd rotation matrix, then add the 2nd translation, and then multiply the coordinate matrix by the resulting matrix? Or do i need to apply each matrix seperately to the coordinates i want to transform (ie. (((coordMatrix * rot1)+trans1)*rot2)+trans2)? Thanks.

##### Share on other sites
Say u want to apply matrices A, B, and C to some pt P ... (in the order C,B,A)

newPt = A * (B * (C * P))

Due to the associative nature of matrix multiplication we can multiply all the matrices together first...

T = A * B * C;newPt = T * P;

##### Share on other sites
ooooh... i see my mistake now. So if you have some matrix, and you want to add a translation to it, you would multiply it by a translation matrix, instead of just adding the translation values to the 4th row? So just to confirm, say you have the following 2 matrices:

A:
1 0 0 0
0 cos(A) -sin(A) 0
0 sin(A) cos(A) 0
0 0 0 1

and

B:
1 0 0 T1
0 1 0 T2
0 0 1 T3
0 0 0 1

if you want to do the above rotation, then the translation, it would be B * A, and not just:

1 0 0 T1
0 cos(A) -sin(A) T2
0 sin(A) cos(A) T3
0 0 0 1

right?

edit: ack.. try to pretend that the columns of the matrices are lined up =P

[Edited by - HalcyonX on August 6, 2005 3:53:07 AM]

##### Share on other sites
Yep, but if you do the multiplication then you will find out that B*A actually equals the same thing as just putting the translation values in the 4th column. [smile] Whereas A*B would give you something different (aswell as a different transform)

##### Share on other sites
mm i see. Ok, thanks a lot!

##### Share on other sites
Quote:
 Original post by KuladusYep, but if you do the multiplication then you will find out that B*A actually equals the same thing as just putting the translation values in the 4th column. [smile] Whereas A*B would give you something different (aswell as a different transform)
Well, for homogenous matrices...

##### Share on other sites
Woah !! you mixed everything! To apply a matrix to a point you need to multiply the point by the matrix and not the oposite! For instance if you want to do A, B, c (in this order) to point p you should do: newP = P * A * B * C or, T = A * B * C, newP = P * T
How can you multiply a matrix by a point?? look:
Matrix (4X4)
Point (1X4)
Matrix * Point is legal only when the number columns in the Matrix (4) == Number of rows in the Point (1), which is illegal because 4 != 1, but the oposite is.

##### Share on other sites
Quote:
 Woah !! you mixed everything! To apply a matrix to a point you need to multiply the point by the matrix and not the oposite! For instance if you want to do A, B, c (in this order) to point p you should do: newP = P * A * B * C or, T = A * B * C, newP = P * THow can you multiply a matrix by a point?? look:Matrix (4X4)Point (1X4)Matrix * Point is legal only when the number columns in the Matrix (4) == Number of rows in the Point (1), which is illegal because 4 != 1, but the oposite is.
You can do it either way. Both p' = p*M and p' = M*p are valid - you just have to make sure your matrices are set up appropriately. The former is row-vector notation (1x4, like in D3D), and the latter is column-vector notation (4x1, like in OpenGL).

##### Share on other sites
I was thinking

[a b c d] [x][e f g h] [y][i j k l] [z][m n o p] [w]

as per jyk's post.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633302
• Total Posts
3011272
• ### Who's Online (See full list)

There are no registered users currently online

×