坐标系转换 之 欧拉角转旋转矩阵 [opencv / Eigen]版本对比

11 篇文章 1 订阅
                Eigen::Matrix3d rotation;
                cv::Vec3d theta(1, 2, 3);
                cv::Mat R_x = (cv::Mat_<double>(3,3) << 1, 0, 0, 0, cos(theta[0]), -sin(theta[0]), 0, sin(theta[0]), cos(theta[0]) );
                cv::Mat R_y = (cv::Mat_<double>(3,3) << cos(theta[1]), 0, sin(theta[1]), 0, 1, 0, -sin(theta[1]), 0, cos(theta[1]) );
                cv::Mat R_z = (cv::Mat_<double>(3,3) << cos(theta[2]), -sin(theta[2]), 0, sin(theta[2]), cos(theta[2]), 0, 0, 0, 1);
                cv::Mat R = R_z * R_y * R_x;
                cv2eigen(R, rotation);

                cout << rotation << endl;

                Eigen::Vector3d eular_angle(1, 2, 3);
                rotation = Eigen::AngleAxisd(eular_angle[2], Eigen::Vector3d::UnitZ())
                         * Eigen::AngleAxisd(eular_angle[1], Eigen::Vector3d::UnitY())
                         * Eigen::AngleAxisd(eular_angle[0], Eigen::Vector3d::UnitX());

                cout << rotation << endl;

以上分别使用了cv::Mat 和 Eigen实现了欧拉角转旋转矩阵

两个最后输出是完全相同的

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值