title: Eigen: convert Matrix3d rotation to Quaternion
body: <p>I'm trying to convert a <code>Matrix3d</code> rotation to a <code>Quaternion&lt;double&gt;</code>, but I got only weird compiler errors so far. The code I'm using is:</p>
  
  <pre><code>Quaternion&lt;double&gt; getQuaternionFromRotationMatrix(const Matrix3d&amp; mat)
  {
      AngleAxisd aa; 
      aa = mat;
      Quaternion&lt;double&gt; q = aa;// conversion error
  
      return q;
  }
  </code></pre>
  
  <p>And the compiler errors:</p>
  
  <pre><code>path/src/Utils.cpp: In function ‘Eigen::Quaternion&lt;double&gt; Utils::getQuaternionFromRotationMatrix(const Matrix3d&amp;)’:
  path/src/Utils.cpp:55:26: error: conversion from ‘Eigen::AngleAxisd {aka Eigen::AngleAxis&lt;double&gt;}’ to non-scalar type ‘Eigen::Quaternion&lt;double&gt;’ requested
  In file included from /usr/local/include/eigen3/Eigen/Core:283:0,
                   from /usr/local/include/eigen3/Eigen/Dense:1,
                   from path/include/Utils.h:4,
                   from path/src/Utils.cpp:1:
  /usr/local/include/eigen3/Eigen/src/Core/Assign.h: In member function ‘Derived&amp; Eigen::DenseBase&lt;Derived&gt;::lazyAssign(const Eigen::DenseBase&lt;OtherDerived&gt;&amp;) [with OtherDerived = Eigen::Matrix&lt;double, 3, 1&gt;, Derived = Eigen::Block&lt;Eigen::Matrix&lt;double, 4, 4&gt;, 4, -0x00000000000000001, true, true&gt;]’:
  /usr/local/include/eigen3/Eigen/src/Core/Assign.h:534:123:   instantiated from ‘static Derived&amp; Eigen::internal::assign_selector&lt;Derived, OtherDerived, false, false&gt;::run(Derived&amp;, const OtherDerived&amp;) [with Derived = Eigen::Block&lt;Eigen::Matrix&lt;double, 4, 4&gt;, 4, -0x00000000000000001, true, true&gt;, OtherDerived = Eigen::Matrix&lt;double, 3, 1&gt;]’
  /usr/local/include/eigen3/Eigen/src/Core/Assign.h:574:89:   instantiated from ‘Derived&amp; Eigen::MatrixBase&lt;Derived&gt;::operator=(const Eigen::DenseBase&lt;OtherDerived&gt;&amp;) [with OtherDerived = Eigen::Matrix&lt;double, 3, 1&gt;, Derived = Eigen::Block&lt;Eigen::Matrix&lt;double, 4, 4&gt;, 4, -0x00000000000000001, true, true&gt;]’
  path/src/Utils.cpp:34:20:   instantiated from here
  /usr/local/include/eigen3/Eigen/src/Core/Assign.h:504:3: error: static assertion failed: "YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES"
  </code></pre>
  
  <p>Does someone know how to convert between both representations?</p>