我需要从方向向量计算旋转矩阵,从旋转矩阵计算方向向量。
向上方向应对应z轴,向前为y,向右为x;
D3DXMATRIX m; // the rotation matrix
D3DXVECTOR3 v; // this is the direction vector wich is given
D3DXVECTOR3 r; // resulting direction vector
float len = D3DXVec3Length(&v); // length of the initial direction vector
// compute matrix
D3DXMatrixLookAtLH(&m, &v, &D3DXVECTOR3(0,0,0), &D3DXVECTOR3(0,0,1));
// use the matrix on a vector { 0, len, 0 }
D3DXVec3TransformCoord(&r, &D3DXVECTOR3(0,len,0), &m);
现在,向量r应该等于v,但它不是。我到底要做什么才能得到我需要的结果?