   Calculating Orientation from a Vector Set
  Hello all. Well here is the situation:I have 3 Vectors an Up, Front and Right. I use these for some of the movement and rotation of objects. So the usual yaw,pitch roll etc. I need to calculate the offset rotation about another set of vectors a standard position and orientation set of axii. Ie I need to calculat the amount rotated from the x axis, the amount rotated from the y axis, the amount rotated from the z axis. Any suggestions? ThankDaemien wrath 
  When u r rotating a point around another point, u must first change the axis origin to the point of rotation and then perform the rotaion. Say u have a point say at origin P(0,0,0)Now u want to move it around a vactor say Q(0,10,0)So u will perform the computations below then ....1. translate P(0,0,0) to the point (0,10,0)2. perform the rotation3. negate the translation... so move back to (0,0,0)So now point P(0,0,0) has rotated around the point Q(0,10,0)I suppose this helped u.... ;  Here is the Code I am using for this object. I just need to calculate the rotation values for d3dvecMeshRotate object. This is the rotational orientation of the mesh which is dependent on the Front,up and Right vectors#include "graphics3DObject.h"//------------------------------------------------------------------//Graphics 3D Object Constructor function//Desc:Creates the 3D Object//Inputs:Device - The Direct 3D Device//Filename - This is the .x file name//Returns:None//------------------------------------------------------------------graphics3DObject::graphics3DObject(LPDIRECT3DDEVICE9 Device, char * XFilename){_pd3dDevice = Device;HRESULT hr;_id3dbAdjBuffer = 0;_id3dbMtrlBuffer = 0;_dwNumMaterials = 0;_strXFileName = XFilename;//Load the mesh filehr = D3DXLoadMeshFromX(_strXFileName._Myptr(),D3DXMESH_MANAGED,_pd3dDevice,&_id3dbAdjBuffer,&_id3dbMtrlBuffer,0,&_dwNumMaterials,&_pd3dMesh);if(!FAILED(hr)){//Load the materialsif(_id3dbMtrlBuffer != 0 && _dwNumMaterials != 0){D3DXMATERIAL * mtrls = (D3DXMATERIAL*) _id3dbMtrlBuffer->GetBufferPointer();for(int i = 0; i < _dwNumMaterials; i++){mtrls.MatD3D.Ambient = mtrls.MatD3D.Diffuse;<br><br>_vecMaterials.push_back(mtrls.MatD3D);<br><br>if(mtrls.pTextureFilename != 0)<br>{<br>//Load the textures<br>LPDIRECT3DTEXTURE9 tex = 0;<br>D3DXCreateTextureFromFile( _pd3dDevice, mtrls.pTextureFilename, &tex);<br>_vecTexture.push_back(tex);<br>}<br>else<br>{<br>_vecTexture.push_back(0);<br>}<br>}<br>}<br><br>//Set its position to the center of the wordl<br>_pd3dDevice->GetTransform(D3DTS_WORLD, &_d3dmatWorld);<br>_d3dvecMeshPos = D3DXVECTOR3(0.0f,0.0f,0.0f);<br>_d3dvecMeshScale = D3DXVECTOR3(1.0f,1.0f,1.0f);<br>_d3dvecMeshFront = D3DXVECTOR3(0.0f,0.0f,1.0f);<br>_d3dvecMeshTop = D3DXVECTOR3(0.0f,1.0f,0.0f);<br>_d3dvecMeshRight = D3DXVECTOR3(1.0f,0.0f,0.0f);<br>_d3dvecMeshRotate  = D3DXVECTOR3(0.0f,0.0f,0.0f);<br>}<br>}<br><br>//——————————————————————<br>//Graphics 3D Object Desstructor function<br>//Desc:Destroys the 3D Object<br>//Inputs:None<br>//Returns:None<br>//——————————————————————<br>graphics3DObject::~graphics3DObject()<br>{<br>}<br><br>//——————————————————————<br>//Graphics 3D Object Draw function<br>//Desc:Draws the 3D Object<br>//Inputs:None<br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::Draw(void)<br>{<br>//Check if device is still valid<br>if (_pd3dDevice)<br>{<br>//Get the transforms <br>D3DMATRIX orignal;<br>CalculateWorldMatrix(&_d3dmatWorld);<br>_pd3dDevice->GetTransform(D3DTS_WORLD, &orignal);<br>_pd3dDevice->SetTransform(D3DTS_WORLD, &_d3dmatWorld);<br><br>//Render subsets<br>for(int i = 0; i < _vecMaterials.size(); i++)<br>{<br>_pd3dDevice->SetMaterial(&_vecMaterials);<br>_pd3dDevice->SetTexture(0, _vecTexture);<br>_pd3dMesh->DrawSubset(i);<br>}<br><br>//Set back to original transform<br>_pd3dDevice->SetTransform(D3DTS_WORLD, &orignal);<br><br>}<br><br>}<br><br>//——————————————————————<br>//Graphics 3D Object Reset function<br>//Desc:Resets the 3D Object if the D3DDevice is Lost<br>//Inputs:Device - The new Device<br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::Reset(LPDIRECT3DDEVICE9 Device)<br>{<br><br>}<br>//——————————————————————<br>//Graphics 3D Object CalculateWorldMatrix function<br>//Desc:Calculates and returns the world matrix<br>//Inputs:Device - The new Device<br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::CalculateWorldMatrix(D3DXMATRIX * view)<br>{<br>D3DXVec3Normalize( &_d3dvecMeshFront, & _d3dvecMeshFront);<br><br>D3DXVec3Cross( &_d3dvecMeshTop, &_d3dvecMeshFront, &_d3dvecMeshRight);<br>D3DXVec3Normalize( &_d3dvecMeshTop, &_d3dvecMeshTop);<br><br>D3DXVec3Cross( &_d3dvecMeshRight, &_d3dvecMeshTop, &_d3dvecMeshFront);<br>D3DXVec3Normalize( &_d3dvecMeshRight, &_d3dvecMeshRight);<br><br>float x = D3DXVec3Dot(& _d3dvecMeshRight, & _d3dvecMeshPos);<br>float y = D3DXVec3Dot(& _d3dvecMeshTop, & _d3dvecMeshPos);<br>float z = D3DXVec3Dot(& _d3dvecMeshFront, & _d3dvecMeshPos); <br><br>(*view)(0,0) = _d3dvecMeshRight.x;<br>(*view)(0,1) = _d3dvecMeshTop.x;<br>(*view)(0,2) = _d3dvecMeshFront.x;<br>(*view)(0,3) = 0.0f;<br><br>(*view)(1,0) = _d3dvecMeshRight.y;<br>(*view)(1,1) = _d3dvecMeshTop.y;<br>(*view)(1,2) = _d3dvecMeshFront.y;<br>(*view)(1,3) = 0.0f;<br><br>(*view)(2,0) = _d3dvecMeshRight.z;<br>(*view)(2,1) = _d3dvecMeshTop.z;<br>(*view)(2,2) = _d3dvecMeshFront.z;<br>(*view)(2,3) = 0.0f;<br><br>(*view)(3,0) = x;<br>(*view)(3,1) = y;<br>(*view)(3,2) = z;<br>(*view)(3,3) = 1.0f; <br><br>D3DXVECTOR3 mRot;<br>CalcRotate(); <br>D3DXMATRIX matRoll, matPitch, matRotate, matScale, matTranslate;<br>D3DXMatrixRotationZ( &matRoll, _d3dvecMeshRotate.z );<br>    D3DXMatrixRotationY( &matRotate, _d3dvecMeshRotate.y  );<br>    D3DXMatrixRotationX( &matPitch, _d3dvecMeshRotate.x  );<br>    D3DXMatrixScaling( &matScale, _d3dvecMeshScale.x, _d3dvecMeshScale.y, _d3dvecMeshScale.z );<br>    D3DXMatrixTranslation( &matTranslate, _d3dvecMeshPos.x, _d3dvecMeshPos.y, _d3dvecMeshPos.z );<br>    D3DXMatrixMultiply( view, &matScale, &matTranslate );<br>    D3DXMatrixMultiply( view, &matRotate, view );<br><br><br>}<br><br>//——————————————————————<br>//Graphics 3D Object Forward function<br>//Desc:Moves the mesh forward<br>//Inputs:Distance - The Distance to move<br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::ForwardBack(float Distance)<br>{<br>_d3dvecMeshPos += _d3dvecMeshFront * Distance;<br>}<br><br>//——————————————————————<br>//Graphics 3D Object CalcRotate function<br>//Desc:Calculates the Rotation vector<br>//Inputs:None<br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::CalcRotate(void)<br>{<br>float xRot, yRot, zRot;<br>float xF, yF, zF;<br>float h;<br><br>}<br><br>//——————————————————————<br>//Graphics 3D Object Strafe function<br>//Desc:Moves the mesh left and right<br>//Inputs:Distance - The Distance to move<br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::Strafe(float Distance)<br>{<br>_d3dvecMeshPos += _d3dvecMeshRight * Distance;<br>}<br><br>//——————————————————————<br>//Graphics 3D Object RiseFall function<br>//Desc:Moves the mesh Up and Down<br>//Inputs:Distance - The Distance to move<br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::RiseFall(float Distance)<br>{<br>_d3dvecMeshPos += _d3dvecMeshTop * Distance;<br>}<br><br>//——————————————————————<br>//Graphics 3D Object Pitch function<br>//Desc:Rotates a Mesh about its Right Axis<br>//Inputs:Angle - Angle in Radians to rotate<br>//Returns:None<br>//——————————————————————<br>void graphics3DObject:<img src="tongue.gif" width=15 height=15 align=middle>itch(float Angle)<br>{<br>if(Angle != 0.0f)<br>{<br>D3DXMATRIX T;<br>//Rotate Along axis<br>D3DXMatrixRotationAxis(&T, & _d3dvecMeshRight, Angle);<br><br>//Move the other axii<br>D3DXVec3TransformCoord( &_d3dvecMeshTop, &_d3dvecMeshTop, &T);<br>D3DXVec3TransformCoord( &_d3dvecMeshFront, &_d3dvecMeshFront, &T);<br><br><br>}<br>}<br><br>//——————————————————————<br>//Graphics 3D Object Yaw function<br>//Desc:Rotates a Mesh about its Top Axis<br>//Inputs:Angle - Angle in Radians to rotate<br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::Yaw(float Angle)<br>{<br>if(Angle != 0.0f)<br>{<br>D3DXMATRIX T;<br><br>D3DXMatrixRotationAxis(&T, &_d3dvecMeshTop, Angle);<br><br>D3DXVec3TransformCoord( &_d3dvecMeshRight, &_d3dvecMeshRight, &T);<br>D3DXVec3TransformCoord( &_d3dvecMeshFront, &_d3dvecMeshFront, &T);<br><br><br>}<br>}<br><br>//——————————————————————<br>//Graphics 3D Object Roll function<br>//Desc:Rotates a Mesh about its Front Axis<br>//Inputs:Angle - Angle in Radians to rotate<br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::Roll(float Angle)<br>{<br>if(Angle != 0.0f)<br>{<br>D3DXMATRIX T;<br><br>D3DXMatrixRotationAxis(&T, &_d3dvecMeshFront, Angle);<br>D3DXVec3TransformCoord( &_d3dvecMeshRight, &_d3dvecMeshRight, &T);<br>D3DXVec3TransformCoord( &_d3dvecMeshTop, &_d3dvecMeshTop, &T);<br><br><br>}<br>}<br><br>//——————————————————————<br>//Graphics 3D Object Set Position function<br>//Desc:Sets a Mesh''s position<br>//Inputs:x,y,z - Position in float<br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::SetPosition(float x, float y, float z)<br>{<br>_d3dvecMeshPos = D3DXVECTOR3(x,y,z);<br>}<br><br>void graphics3DObject::SetRotation(float xR, float yR, float zR)<br>{<br>D3DXMATRIX T;<br><br>_d3dvecMeshFront = D3DXVECTOR3(0.0f,0.0f,1.0f);<br>_d3dvecMeshTop = D3DXVECTOR3(0.0f,1.0f,0.0f);<br>_d3dvecMeshRight = D3DXVECTOR3(1.0f,0.0f,0.0f);<br><br>//X Axis Rotation<br>D3DXMatrixRotationX(&T, xR);<br><br>D3DXVec3TransformCoord( &_d3dvecMeshTop, &_d3dvecMeshTop, &T);<br>D3DXVec3TransformCoord( &_d3dvecMeshFront, &_d3dvecMeshFront, &T);<br><br>D3DXMatrixRotationY(&T, yR);<br>    <br>D3DXVec3TransformCoord( &_d3dvecMeshRight, &_d3dvecMeshRight, &T);<br>D3DXVec3TransformCoord( &_d3dvecMeshFront, &_d3dvecMeshFront, &T);<br><br>D3DXMatrixRotationZ(&T, zR);<br><br>D3DXVec3TransformCoord( &_d3dvecMeshRight, &_d3dvecMeshRight, &T);<br>D3DXVec3TransformCoord( &_d3dvecMeshTop, &_d3dvecMeshTop, &T);<br>}<br><br>//——————————————————————<br>//Graphics 3D Object Set Scale function<br>//Desc:Sets a Mesh''s Scale<br>//Inputs:x,y,z- Scale <br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::SetScale(float x, float y, float z)<br>{<br>_d3dvecMeshScale = D3DXVECTOR3(x,y,z);<br>}<br><br>//——————————————————————<br>//Graphics 3D Object Refresh function<br>//Desc:Refreshes the world Matrix<br>//Inputs:None <br>//Returns:None<br>//——————————————————————<br>void graphics3DObject::Refresh()<br>{<br>CalculateWorldMatrix(&_d3dmatWorld);<br>}<br> </pre>   </i>  ;  What you would like is to know the new yaw, pitch, roll etc of the objects in your new coordinate center (the second set of vector) is that right ?Using matrix, you can''t do so (if what I rode in a gamedev article about quaternion was right) But you can try to do so with quaternions.If what you''re looking for is the object coordinates in the second coordinate center, it can be done with matrix but you should use matrix at each step.Try to reformulate your query 