# A small question

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

## Recommended Posts

Hi, I want to translate the object along X and Y direction. For that I construct a translation matrix and Multiply It to World Matrix. D3DXMatrixTranslation(&matTrans, xDist, yDist, 0); D3DXMatrixMultiply (&matWorld, &matWorld, &matTrans); This works fine. Next,I want to rotate by object around world origin along Z direction. For that I construct a Rotation matrix and Multiply It to World Matrix. D3DXMatrixRotationZ(&matRotZ, zAngle*0.0174); D3DXMatrixMultiply (&matWorld, &matWorld, &matRotZ); This rotates the object and its axes also. Next I want to translate again. This causes the translation to happen along the direction of rotated X,Y axes caused due to the previous rotation. But I want the object to always translate along the World's X and Y direction not to translate along the object's axes. What should I do for this? Can Any one help? Expecting help. [Edited by - tinu on June 15, 2007 10:48:02 PM]

##### Share on other sites
The order of the transformations is important. Do the rotations first, and translate after the rotations. This way, you move the already rotated object in world XYZ.

##### Share on other sites
But if Change the order of rotation the rotation around world origin does not happen.

It changes into rotation about object's origin

##### Share on other sites
By your last post, I thought you wanted to rotate first, and then translate.

Anyhow, if you want to combine an "orbital" rotation and and ordinary rotation, do the following:

-First rotate the object around its own center (which is the world center also).
-Then translate the object to the orbit.
-Finally, rotate the object around the world center.

All of these steps can be combined into one matrix by multiplying them together in the above order.

##### Share on other sites
Basically, I wanted to develop an application which on pressing particular keys should rotate around the world origin and translate whenever the corresponding keys are pressed.

##### Share on other sites
All that matters is that the transforms are in correct order, no matter what result you want.

Think about what each individual transform actually does. Remember that the object coordinate system does not get transformed; rather, the object vertices themselves are transformed with regard to the object's origin, which can be thought as always being at [0,0,0].

##### Share on other sites
To rotate the object around its own center,I use

D3DXMatrixRotationZ(&matRotZ, zAngle*0.0174);
D3DXMatrixMultiply (&matWorld, &matWorld, &matRotZ);

How to rotate the object around the world center when the object centre and the world centre are not the same?

##### Share on other sites
It's "Question", not "Doubt"!

A "Doubt" is something about yourself only.
A "Question" is something you ask others.

You need to rebuild the desired matrix again from scratch every time by rotating and multiplying by the respactive cumulative amounts.

##### Share on other sites
If I first Rotate and then translate, the consecutive rotation happens around the objects origin and not the world origin and the translation happens fine.

If I first translate and then rotate,the consecutive translation happens along the rotated axes and the rotation happens fine around the world origin.

So What should I do to combine both the effects of rotation around world origin along Z direction and Translate along the World X,Y directions?

Can any one help?

[Edited by - tinu on June 16, 2007 5:46:13 AM]

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 11
• 9
• 38
• 16
• ### Forum Statistics

• Total Topics
634128
• Total Posts
3015693
×