The rotation of the three-dimensional space can be represented by Euler's angle, rotation vector, rotation matrix, and four-dollar number.
The first is the Euler angle notation, which we can use to rotate around an axis.
A rotational vector is a rotating axis and a rotational angle to represent rotation.
The rotation matrix uses a matrix to represent the rotational transformation relationships in the space.
The four-dollar number uses 4 variables to denote rotation (adding a latitude) to avoid the phenomenon of gimbal locking.
The specific conversion formula can refer to the book "Visual Slam 14".
The following program transforms using the Eigen library.
(1) rotation vector-> rotation matrix
(2) rotational vector-> four yuan number
(3) Rotation vector-> Euler angle
#include <iostream> #include <fstream> #include <vector> #include < eigen/core> #include <Eigen/Dense> #include <Eigen/Geometry> #include <Eigen/StdVector> using
namespace Std; int main () {//1.rotation vector to rotation matrix EIGEN::ANGLEAXISD rotationvector M_pi/4,eigen::vector3d (0,0,1
));
Eigen::matrix3d rotationmatrix=eigen::matrix3d::identity ();
Rotationmatrix=rotationvector.torotationmatrix ();
cout<< "Rotationmatrix \" <<rotationMatrix<<endl;
2.rotation vector to Quaterniond eigen::quaterniond q=eigen::quaterniond (rotationvector);
cout<< "rotation quaternion \ n" <<q.coeffs () <<endl;
3.rotaion vector to Eulerangles eigen::vector3d Eulerangle=rotationvector.matrix (). Eulerangles (0,1,2);
cout<< "Eulerangle roll pitch yaw\n" <<180*eulerAngle/M_PI<<endl;
return 0; }