Eigen四元数初始化,对应wxyz的值

#include <iostream>
#include <Eigen/Geometry>

int main()
{

    Eigen::Quaternion q1(1, 2, 3, 4);

    Eigen::Vector3d pos = Eigen::Vector3d::Zero();
    Eigen::Quaterniond quat = Eigen::Quaterniond::Identity();

    double q_tmp[4] = {1,2,3,4};
    Eigen::Quaterniond q2(q_tmp);

    std::cout << "w x y z = " << q1.w() << q1.x() << q1.y() << q1.z() <<std::endl;
    std::cout << "w x y z = " << q2.w() << q2.x() << q2.y() << q2.z() <<std::endl;
    std::cout << "w x y z = " << quat.w() << quat.x() << quat.y() << quat.z() <<std::endl;

    return 0;
}

输出结果

w x y z = 1234
w x y z = 4123
w x y z = 1000

说明:
用数组或vector初始化时,w的值是最后一个值。
Eigen::Quaterniond::Identity() 是实部为1,虚部为0

posted @ 2024-03-06 17:28  水水滴答  阅读(15)  评论(0编辑  收藏  举报