title: Rotate object from one coordinate system to another
body: <p>Using the <code>glm</code> library for the calculations. I have a mesh located in a local coordinate system where the axis are:</p>
  
  <pre><code>meshUp =      glm::vec3(0, 1, 0);
  meshForward = glm::vec3(0, 0, -1);
  meshRight =   glm::vec3(1, 0, 0);
  </code></pre>
  
  <p>and I need a matrix that will rotate its vertices to any other new coordinate system with 3 given axis, fx:</p>
  
  <pre><code>newUp =       glm::vec3(-0.85, 0.51, -0.08);
  newForward =  glm::vec3(0.45, 0.65, -0.61);
  newRight =    glm::vec3(-0.26, -0.56, -0.79);
  </code></pre>
  
  <p>No translation needed, the coordinate systems share origin. I can get halfway there, like this:</p>
  
  <pre><code>glm::vec3 rotationVecForUpAxis = glm::normalize(glm::cross(meshUp, newUp));
  float rotationRadiansForUpAxis = acos(glm::dot(meshUp, newUp));
  
  glm::mat4 rotationMatrix = glm::rotate(glm::mat4(), 
                                         rotationRadiansForUpAxis,
                                         rotationVecForUpAxis);
  </code></pre>
  
  <p>This works and rotates the mesh, so it's up axis aligns with the <code>newUp</code> axis. However, the mesh still needs to be rotated around the <code>newUp</code> axis, before the mesh's <code>meshForward</code> axis aligns with the <code>newForward</code> axis. </p>
  
  <p>Does anyone know how to do this? </p>