Jump to content
  • Advertisement
Sign in to follow this  
HalcyonX

clarification about matrices

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
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)
Well, for homogenous matrices...

Share this post


Link to post
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 this post


Link to post
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 * 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.
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!