Eigen: Convert rotaion matrix to vector

  c++, eigen, eigen3, python

I am looking for the same functionality of Scipy for converting a 3×3 rotation matrix to a vector but in C++ (Eigen), that is:

from scipy.spatial.transform import Rotation as R
M = np.array([[-0.69492056,  0.71352099,  0.08929286],
              [-0.19200697, -0.30378504,  0.93319235],
              [ 0.69297817,  0.6313497 ,  0.34810748]]
R.from_matrix(M).as_rotvec()

which returns:

array([-0.67925191, -1.35850382, -2.03775573])

However in c++ Eigen I am not sure how to obtain this functionality. I know however the reverse of it that gives the matrix:

Eigen::Vector3d rotVec(-0.67925191, -1.35850382, -2.03775573);
Eigen::AngleAxisd rotAA(rotVec.norm(), rotVec.normalized());
Eigen::Matrix3d rotationMatrix = rotAA.matrix();

Source: Windows Questions C++

LEAVE A COMMENT