Eigen中几何模块数据演示

一、旋转向量

1.0 初始化旋转向量:旋转角为alpha,旋转轴为(x,y,z)

Eigen::AngleAxisd rotation_vector(alpha,Vector3d(x,y,z))

1.1 旋转向量转旋转矩阵

Eigen::Matrix3d rotation_matrix;rotation_matrix=rotation_vector.matrix();

Eigen::Matrix3d rotation_matrix;rotation_matrix=rotation_vector.toRotationMatrix();

1.2 旋转向量转欧拉角(Z-Y-X,即RPY)

Eigen::Vector3d eulerAngle=rotation_vector.matrix().eulerAngles(2,1,0);

1.3 旋转向量转四元数

Eigen::Quaterniond quaternion(rotation_vector);

Eigen::Quaterniond quaternion;Quaterniond quaternion;

Eigen::Quaterniond quaternion;quaternion=rotation_vector;

二、旋转矩阵

2.0 初始化旋转矩阵

Eigen::Matrix3d rotation_matrix;rotation_matrix<

2.1 旋转矩阵转旋转向量

Eigen::AngleAxisd rotation_vector(rotation_matrix);

Eigen::AngleAxisd rotation_vector;rotation_vector=rotation_matrix;

Eigen::AngleAxisd rotation_vector;rotation_vector.fromRotationMatrix(rotation_matrix);

2.2 旋转矩阵转欧拉角(Z-Y-X,即RPY)

Eigen::Vector3d eulerAngle=rotation_matrix.eulerAngles(2,1,0);

2.3 旋转矩阵转四元数

Eigen::Quaterniond quaternion(rotation_matrix);

Eigen::Quaterniond quaternion;quaternion=rotation_matrix;

三、欧拉角

3.0 初始化欧拉角(Z-Y-X,即RPY)

Eigen::Vector3d eulerAngle(yaw,pitch,roll);

3.1 欧拉角转旋转向量

Eigen::AngleAxisd rollAngle(AngleAxisd(eulerAngle(2),Vector3d::UnitX()));
Eigen::AngleAxisd pitchAngle(AngleAxisd(eulerAngle(1),Vector3d::UnitY()));
Eigen::AngleAxisd yawAngle(AngleAxisd(eulerAngle(0),Vector3d::UnitZ()));

Eigen::AngleAxisd rotation_vector;rotation_vector = yawAngle* pitchAngle * rollAngle;

3.2 欧拉角转旋转矩阵

Eigen::AngleAxisd rollAngle(AngleAxisd(eulerAngle(2),Vector3d::UnitX()));
Eigen::AngleAxisd pitchAngle(AngleAxisd(eulerAngle(1),Vector3d::UnitY()));
Eigen::AngleAxisd yawAngle(AngleAxisd(eulerAngle(0),Vector3d::UnitZ()));

Eigen::Matrix3d rotation_matrix;rotation_matrix = yawAngle* pitchAngle * rollAngle;

3.3 欧拉角转四元数

Eigen::AngleAxisd rollAngle(AngleAxisd(eulerAngle(2),Vector3d::UnitX()));
Eigen::AngleAxisd pitchAngle(AngleAxisd(eulerAngle(1),Vector3d::UnitY()));
Eigen::AngleAxisd yawAngle(AngleAxisd(eulerAngle(0),Vector3d::UnitZ()));

Eigen::Quaterniond quaternion;quaternion=yawAnglepitchAnglerollAngle;

四、四元数

4.0 初始化四元数

Eigen::Quaterniond quaternion(w,x,y,z);

4.1 四元数转旋转向量

Eigen::AngleAxisd rotation_vector(quaternion);

Eigen::AngleAxisd rotation_vector;rotation_vector=quaternion;

4.2 四元数转旋转矩阵

Eigen::Matrix3d rotation_matrix;rotation_matrix=quaternion.matrix();

Eigen::Matrix3d rotation_matrix;rotation_matrix=quaternion.toRotationMatrix();

4.4 四元数转欧拉角(Z-Y-X,即RPY)

Eigen::Vector3d eulerAngle=quaternion.matrix().eulerAngles(2,1,0);

五、欧式变换矩阵

Isometry3d T = Isometry3d::Identity(); //虽然为3d,实际上是4*4矩阵

T.rotate(rotation_matrix);
T.pretranslate(Vector3d(1, 2, 3));

你可能感兴趣的:(视觉SLAM)