zoukankan      html  css  js  c++  java
  • eigen 四元数

    Eigen中四元数Quaterniond的初始

    Eigen::Quaterniond q1(w, x, y, z);// 第一种方式
    Eigen::Quaterniond q2(Vector4d(x, y, z, w));// 第二种方式
    Eigen::Quaterniond q2(Matrix3d(R));// 第三种方式
    #include <iostream>
    
     
    #include <Eigen/Core>
    #include <Eigen/Geometry>
    #define PI (3.1415926535897932346f)
    
    int main(int argc, char **argv) 
    {
    
        using ::std::cout;
        using ::std::endl;
        double yaw = PI/3,pitching = PI/4,droll = PI/6;
    
       
          //EulerAngles to RotationMatrix
        ::Eigen::Vector3d ea0(yaw,pitching,droll);
        ::Eigen::Matrix3d R;
    
        R = ::Eigen::AngleAxisd(ea0[0], ::Eigen::Vector3d::UnitZ())
    
            * ::Eigen::AngleAxisd(ea0[1], ::Eigen::Vector3d::UnitY())
    
            * ::Eigen::AngleAxisd(ea0[2], ::Eigen::Vector3d::UnitX());
    
        cout << R << endl << endl;
    
    
        //RotationMatrix to Quaterniond
        ::Eigen::Quaterniond q; 
        q = R;    
    
        cout << q.x() << endl << endl;
        cout << q.y() << endl << endl;
        cout << q.z() << endl << endl;
        cout << q.w() << endl << endl;
    
        //Quaterniond to RotationMatrix
    
        ::Eigen::Matrix3d Rx = q.toRotationMatrix();
    
        cout << Rx << endl << endl;
    
       
        //RotationMatrix to EulerAngles
        ::Eigen::Vector3d ea1 = Rx.eulerAngles(2,1,0);     
        cout << ea1/PI*180 << endl << endl;
    
        std::cin.ignore();
    
        return 0;
    }
  • 相关阅读:
    模拟测试69
    模拟测试68
    模拟测试66
    NOIP模拟测试15
    NOIP模拟测试14
    Gekoo's checker
    NOIP模拟测试13
    替罪羊树模板
    KDTree笔记
    NOIP模拟测试12
  • 原文地址:https://www.cnblogs.com/lovebay/p/13820750.html
Copyright © 2011-2022 走看看