eigen 四元数

摘要:
四元数的初始特征::四元数q1(w,x,y,z)//第一种方法特征::Quaternionq2(Vector4d(x,y、z,w))//第二种方法特征值::Quaterionq2

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

免责声明:文章转载自《eigen 四元数》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Gradle添加本地jar包,Maven添加本地jar包Jmeter 正则表达式提取Response Headers,Response Body里的值下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

(转)C++ bitset用法

今天做题发现要用到bitset,找到一篇介绍的巨好的文章。 转载自:https://www.cnblogs.com/magisk/p/8809922.html C++的 bitset 在 bitset 头文件中,它是一种类似数组的结构,它的每一个元素只能是0或1,每个元素仅用1bit空间。 下面是具体用法 构造函数 bitset常用构造函数有四种,如下...

C++枚举变量与switch

转载:https://www.cnblogs.com/banmei-brandy/p/11263927.html 枚举类型和变量如何定义,下篇博客讲得十分详细: https://blog.csdn.net/bruce_0712/article/details/54984371 有几个需要注意的点: (1)在不进行强制类型转换的前提下,枚举量只能由枚举类型赋...

c++之find()函数

c++之find()函数 在数组或者向量中,找到一个数,返回它的下标 #include <iostream> // std::cout #include <algorithm> // std::find #include <vector> // std::vector int main ()...

c++矩阵运算库Eigen

因为在看PCA,看到了矩阵运算库Engine。 官网教程:http://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html  Eigen简单上手使用要实现相应的功能只需要包含头相应的头文件即可: Core #include <Eigen/Core> Matrix and Arra...

求伪逆矩阵c++代码(Eigen库)

非方阵的矩阵的逆矩阵  pseudoInverse 伪逆矩阵是逆矩阵的广义形式,广义逆矩阵 matlab中是pinv(A)--》inv(A)。 #include "stdafx.h" #include<iostream> #include<Eigen/Core> #include<Eigen/SVD>...

eigen Matrix详解

Eigen Matrix 详解 在Eigen中,所有的matrices 和vectors 都是模板类Matrix 的对象,Vectors 只是一种特殊的矩阵,行或者列为1. Matrix的前三个模板参数 Matrix 类有6个模板参数,现在我们了解前三个足够。剩下的三个参数都有默认值,后面会探讨,现在不管他。Matrix 的三个强制的模板参数: Matri...