title: Direct3D Rotation Matrix from Vector and vice-versa
body: <p>I need to compute a rotation matrix from a direction vector,
  and a direction vector from a rotation matrix.</p>
  
  <p>The up direction should correspond to the z-axis,
  forward is y and right is x;</p>
  
  <pre><code>    D3DXMATRIX m; // the rotation matrix
      D3DXVECTOR3 v; // this is the direction vector wich is given
      D3DXVECTOR3 r; // resulting direction vector
  
      float len = D3DXVec3Length(&amp;v); // length of the initial direction vector
  
      // compute matrix
      D3DXMatrixLookAtLH(&amp;m, &amp;v, &amp;D3DXVECTOR3(0,0,0), &amp;D3DXVECTOR3(0,0,1));
  
      // use the matrix on a vector { 0, len, 0 }
      D3DXVec3TransformCoord(&amp;r, &amp;D3DXVECTOR3(0,len,0), &amp;m);
  </code></pre>
  
  <p>Now, the vector <em>r</em> should be equal to <em>v</em>, but it isnt.
  What exactly do I have to do to get the results I need?</p>