title: Given 3D rotation matrix and 3D direction vector finding angular difference
body: <p>In my current project I need to find the angular distance of direction vector from a 3D rotation matrix. </p>
  
  <p>The legacy code which suppose to do that is buggy and is not working. Even it is buggy I want to share it because it may help understanding my problem. </p>
  
  <pre><code>double angularDiff( bool isSideAngle, const Matrix&amp; in3DRotationMatrix, const Vector&amp; in3DDirection )
  {
      // Unit vector convertion
      in3DDirection.Normalize();
  
      // Simple matrix vector multiplication 
      Vector newDir = in3DRotationMatrix*in3DDirection;
  
      // Code suppose to find side angle difference 
      // or forward angle difference according to boolean parameter
      if ( isSideAngle )
          result = atan2(newDir[1],  newDir[0]);
      else 
          result = atan2(newDir[2],  newDir[0]);
  
      return result;    
  }
  </code></pre>
  
  <p>Is what is missing in the method above something simple or should I change my approach totally? Given a direction vector what is the best method to find angular distance in X and Y directions from a rotation matrix? </p>