• Advertisement
Sign in to follow this  

proper rotation about a vector

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

hopefully this will be quick and painless... I have 2 vectors one is a "target" and the other is a "position" what i want to do is to have the "position" rotate about the "target"... I have my rotating working but i can only get is to rotate around (0,0,0) i know i some how need to incorporate the "target" im just not sure where / how here is what i got / have...

D3DXMATRIX matRot, matTrans;
D3DXMatrixRotationYawPitchRoll(&matRot, y, x, z);
D3DXVec3TransformCoord(&m_pos, &m_pos, &matRot);

// locks the camera to a distance
m_pos =  m_pos - m_target;
D3DXVec3Normalize(&m_pos, &m_pos);
m_pos = m_pos * m_targetDistance;


Share this post


Link to post
Share on other sites
Advertisement
If I follow what you're asking then rotations are always about an axis passing through the origin. If you want a rotation about an axis that doesn't pass through the origin then you need a translation so that a point on the axis is the origin, do the rotation then translate it back.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement