proper rotation about a vector

Started by
0 comments, last by LilBudyWizer 18 years, 6 months ago
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;


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.
Keys to success: Ability, ambition and opportunity.

This topic is closed to new replies.

Advertisement