title: Calculating quaternion for transformation between 2 3D cartesian coordinate systems
body: <p>I have two cartesian coordinate systems with known unit vectors:</p>
  
  <p>System A(x_A,y_A,z_A)</p>
  
  <p>and</p>
  
  <p>System B(x_B,y_B,z_B)</p>
  
  <p>Both systems share the same origin (0,0,0). I'm trying to calculate a quaternion, so that vectors in system B can be expressed in system A.</p>
  
  <p>I am familiar with the mathematical concept of quaternions. I have already implemented the required math from here: <a href="http://content.gpwiki.org/index.php/OpenGL%3aTutorials%3aUsing_Quaternions_to_represent_rotation" rel="noreferrer">http://content.gpwiki.org/index.php/OpenGL%3aTutorials%3aUsing_Quaternions_to_represent_rotation</a></p>
  
  <p>One possible solution could be to calculate Euler angles and use them for 3 quaternions. Multiplying them would lead to a final one, so that I could transform my vectors:</p>
  
  <p>v(A) = q*v(B)*q_conj</p>
  
  <p>But this would incorporate Gimbal Lock again, which was the reason NOT to use Euler angles in the beginning.</p>
  
  <p>Any idead how to solve this?</p>