🔒 Locked
🎮 Unity
clarification about matrices
Advertisement
Original Post
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.
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]
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]
Quote:Well, for homogenous matrices...
Original post by Kuladus
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)
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.
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.
Quote: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).
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement