#### Archived

This topic is now archived and is closed to further replies.

# Rotations

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

## Recommended Posts

Hi ! these are some triangle vertices : D3DVECTOR Vec1( 0.0f, 0.0f, 0.0f); D3DVECTOR Vec2( 1.0f,-1.0f, 0.0f); D3DVECTOR Vec3(-1.0f,-1.0f, 0.0f); now , how can i avoid that when i rotate this triangle lets say , aroud the z -axis , the triangle will not rotate around the world origin?? i want it to be rotated around the local origin. why when i change Vec1 to D3DVECTOR Vec1( 0.0f, 1.0f, 0.0f); , it is rotated around the local origin? Thanks a lot!. Posted By Xeno. Kobe Bryant - "Just believe in yourself"

##### Share on other sites
hmmm.... somebody?

Thanks .

Posted By Xeno.
Kobe Bryant - "Just believe in yourself"

##### Share on other sites
When you set the world matrix to a rotation matrix your triangle is rotated around its origin, which just happens to coincide with the worlds origin since you don''t translate it.

If you change Vec1 to (0,1,0) the origin of the triangle is still (0,0,0).

But if what you wanted to ask is how to rotate the around its meanpoint, then you must first translate the triangle so that the meanpoint coincides with (0,0,0) then rotate it and finally translate it back to where it was before.

D3DMATRIX World = Translate(-MeanPoint)*Rotate(Angle)*Translate(MeanPoint);
pD3DDev->SetTransform(D3DTRANSFORMSTATE_WORLD, &World);

The function Translate() above returns a D3DMATRIX that are set as a translation matrix. Rotate() returns a rotationmatrix. You can do the same with D3DX functions or the functions found in the D3DFramework.

- WitchLord

• 22
• 24
• 9
• 15
• 60