# Rotating Object

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

## Recommended Posts

Hi everyone. Just imagine i have an object in 10.0f,10.0f,10.0f coordinates and i want to rotate this object itself not around the origin. I couldn't find any function about it? How can i solve this problem?

##### Share on other sites
Translate the object to the origin, perform the rotation and then translate the object back.

##### Share on other sites
Quote:
 Original post by SiCraneTranslate the object to the origin, perform the rotation and then translate the object back.

D3DXMATRIX * D3DXMatrixRotationAxis(  D3DXMATRIX *pOut,  CONST D3DXVECTOR3 *pV,  FLOAT Angle);[/sourceBuilds a matrix that rotates around an arbitrary axis.

##### Share on other sites
Quote:
Original post by XVincentX
Quote:
 Original post by SiCraneTranslate the object to the origin, perform the rotation and then translate the object back.

*** Source Snippet Removed ***
That has nothing to do with performing a rotation in different coordinate space, that rotates in the current coordinate space, around an arbitrary axis.

##### Share on other sites
Quote:
 Translate the object to the origin, perform the rotation and then translate the object back.

SiCrane is correct if the object vertices are constructed at (10,10,10).

If the object is constructed at (0,0,0), then just rotate it as desired, then translate it to (10,10,10).

##### Share on other sites
Hi everyone.
Thanks for the function.
But i still have some problems about it.
http://img501.imageshack.us/my.php?image=rotatepl7.jpg

There are many object with different coordinates and i want to rotate them in axis y but when i give these coordinates in this function they dont rotate correctly.

first objects coordinates
cans[0].center_x=-70.0f;
cans[0].center_y=35.0f;

first vector coordinates
Rotate[0].x=-69;
Rotate[0].y=35;

for(int say=0;say<16;say++)
{
D3DXMatrixRotationAxis(&matRotate[say],&Rotate[say],rotation+=0.01);
}

Any suggestion?

##### Share on other sites
I found that when i assign x and y coordinates for the function it rotates not only in y but also in x axis but i want it to rotate in only for axis y so i think that this function is useless for me.I also tried SiCranes solution but i couldnt succeed.Can anyone explain more about it?

##### Share on other sites
I solved it now
Thanks for everything.
By the way i used SiCrane's solution.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 9
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633717
• Total Posts
3013513
×