# Rotation matrices

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

## Recommended Posts

Hi All, I am trying to smoothly rotate and translate a 3D object from one position to other.for that I have : 3 Transformation matrices. Original transform where the object residing initially. Current transform - to where I rotate or translate the object Desired Transform - to where I want to place the object finally.. Now I can smoothly move to the desired position from the current position using some translation path calculations. I calculate the middle position(say mid) of current and desired again the middle position of current and mid,mid and desired and so on... this gives me a set of translation path between those two transforms, and can translate some what smoothly from current to desired. Like that I want a smooth rotation from the current to desired. How can I find the correct rotation matrices between the current and desired positions? Is there any way to find the transformation matrices between these two transforms instead of calculating the translation and rotation matrices separatly? Please help me.. Thanks in Advance.. Regal

##### Share on other sites
// convert matrices to quats and position vectorsQuat qDesired  = Desired.ToQuat();Quat qOriginal = Original.ToQuat();Vec3 vDesired  = Vec3(Desired.m30,Desired.m31,Desired.m32);Vec3 vOriginal = Vec3(Original.m30,Original.m31,Original.m32);// vary between 0 and 1 to between the original and desired Transformsfloat tControl = 0;// lerp between the start and endQuat qCurrent = Slerp(qOriginal,qDesired,tControl);Vec3 vCurrent = Lerp(vOriginal,vDesired,tControl);// convert Quat and Vec3 back to matrixMat Current = qCurrent.ToMatrix();Current.m30 = vCurrent.x;Current.m31 = vCurrent.y;Current.m32 = vCurrent.z;

##### Share on other sites
Thanks Rob,
I will try this code..Hope this will work for me..

##### Share on other sites
Hi Rob.. Thanks a lot... thats working..
But again a problem.. The rotation is not around the object center..
I have to correct that.. Any Suggestions??

##### Share on other sites
Wrap the rotation by 2 translations: First translate the object so that the desired center is moved to zero, then rotate, then translate the object back.