Skip to main content
GameDev.net gamedev.net
🔒 Locked

Matrix transformations

Started by Endar Sep 10, 2005 at 4:35 AM 2 replies 450+ views
Original Post
Endar
Endar
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?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
dave
dave
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
Endar
Endar
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?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
dave
dave
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.