Eigen, rotation vector, rotation matrix, conversion of four __slam

Source: Internet
Author: User

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; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.