# Matrix transformations

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

## Recommended Posts

Quick question about matrix transformations. I currently have a scene node with a single matrix as a transformation node. I was wondering, when you end up with the final matrix for a transformation, and you have a matrix for rotation, translation and scaling, does it matter which you multiply and in which order? So, if I already had a transformation matrix and I decided I wanted to rotate it some more, can I do that? Eg. can you do rotation * translation * rotation * scaling * translation and still get a perfectly valid matrix that will get you the transformation you intended?

##### Share on other sites
Yes it does, but only in the case of using translation and rotation at the same time.

If you go:

D3DXMATRIXA16 world, translation, rotation;D3DXMatrixIdentity( &world );D3DXMatrixMultiply( &world, &world, &translation );D3DXMatrixMultiply( &world, &world, &rotation);

The object will be shifted into position and then rotated on the spot.

However if you do this:

D3DXMATRIXA16 world, translation, rotation;D3DXMatrixIdentity( &world );D3DXMatrixMultiply( &world, &world, &rotation);D3DXMatrixMultiply( &world, &world, &translation );

The object will be rotated and then translated into position.

All of the other tranformation types can happen anywhere and in any order, it is only the order if these two that alter the output of the transformation. Multiplying by rotation twice into the world matrix will just screw things around and shouldn't be done unless you know exactly why you are doing it.

Hope that helps.

ace

##### Share on other sites
So, if I wanted to make sure that everything went fine, would I have to keep 3 matrices in the tranformation scene node?

Like, one for rotation, one for scaling, and one for translations? So, if someone wanted to add a rotation, they could do that, and the rotation matrix would get multiplied, but, when the time to actually render the objects, I would have to do the three multiplications to get the final transformation matrix, and then the final multiplication to multiply by the world matrix.

Something like that?

##### Share on other sites
I guess you could, but im not expert on rendering engines and the like. I know about matrices though [smile].

Maybe someone else can help with that,

ace

1. 1
2. 2
Rutin
15
3. 3
4. 4
5. 5

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

• Total Topics
633269
• Total Posts
3011154
• ### Who's Online (See full list)

There are no registered users currently online

×