【Linux/Eigen】学习笔记(3):写一个Rotz函数
机器人运动学中,绕坐标轴旋转算子是常用的工具,具体结果形式是一个3*3的矩阵,可表示机器人的姿态。最近在学Eigen库,简单写一个绕Z轴旋转的算子,Rotz(theta)。如下所示:
#include <Eigen/Dense>
#include <iostream>
using namespace std;
Eigen::Matrix3d Rotz(double theta)
{
Eigen::Matrix3d r;
r << cos(theta), -sin(theta), 0, sin(theta), cos(theta), 0, 0, 0, 1;
return r;
}
int main()
{
Eigen::Matrix3d mat3d4 = Rotz(M_PI / 3);
cout << mat3d4 << endl;
return 1;
}
运行结果为:

绕X轴和Y轴是类似的,按照如下公式编程即可:

浙公网安备 33010602011771号