Creation of a rotation matrix with a step, yaw, roll using Eigen

How to create a rotation matrix using a step, yaw, roll with an Eigen library?

+8
c ++ math matrix rotation eigen
source share
4 answers

Seeing how I could not find a previously created function that does this, I built one, and here it is in case someone finds this question in the future

Eigen::AngleAxisd rollAngle(roll, Eigen::Vector3d::UnitZ()); Eigen::AngleAxisd yawAngle(yaw, Eigen::Vector3d::UnitY()); Eigen::AngleAxisd pitchAngle(pitch, Eigen::Vector3d::UnitX()); Eigen::Quaternion<double> q = rollAngle * yawAngle * pitchAngle; Eigen::Matrix3d rotationMatrix = q.matrix(); 
+18
source share

How to create a rotation matrix using a step, yaw, roll with an Eigen library?

There are 48 ways to do this. Which one do you want? Here are the factors:

  • Inner verus intrinsic.
    Are rotations around the axes of a fixed system (external) or related to rotating axes (internal)?

  • Rotation versus transformation.
    Do you want to represent a matrix that physically rotates some object or do you want to represent a matrix that converts vectors from one reference frame to another?

  • Astronomical sequences.
    There are six fundamental astronomical sequences. The canonical Euler sequence includes a rotation around the z axis, followed by rotation around the (rotated) x axis, followed by a third rotation around (turning again) the z axis. In addition to this canonical zxz sequence, there are five more such astronomical-style sequences (xyx, xzx, yxy, yzy and zyz).

  • Aerospace sequences.
    To add to the confusion, there are six fundamental aerospace sequences. For example, a yaw-pitch sequence compared to an edge yaw sequence. While the astronomy community has pretty much settled in the zxz sequence, the aerospace community cannot be said. Somewhere along the way, you find people who use each of the six possible sequences. The six sequences in this group are xyz, xzy, yzx, yxz, zxy and zyx.
+7
source share

Caesar's answer is fine, but as David Hamman says, it depends on your application. For me (a submarine or an air vehicle) a winning combination:

 Eigen::Quaterniond euler2Quaternion( const double roll, const double pitch, const double yaw ) { Eigen::AngleAxisd rollAngle(roll, Eigen::Vector3d::UnitX()); Eigen::AngleAxisd pitchAngle(pitch, Eigen::Vector3d::UnitY()); Eigen::AngleAxisd yawAngle(yaw, Eigen::Vector3d::UnitZ()); Eigen::Quaterniond q = yawAngle * pitchAngle * rollAngle; return q; } 
+6
source share

All you need to create a rotational matrix is ​​a step, yaw, roll and the ability to perform matrix multiplication.

First create three rotational matrices, one for each axis of rotation (i.e. one for pitch, one for yaw, one for roll). These matrices will have values:

Pitch Matrix:

 1, 0, 0, 0, 0, cos(pitch), sin(pitch), 0, 0, -sin(pitch), cos(pitch), 0, 0, 0, 0, 1 

Yaw Matrix:

 cos(yaw), 0, -sin(yaw), 0, 0, 1, 0, 0, sin(yaw), 0, cos(yaw), 0, 0, 0, 0, 1 

Roller Matrix:

 cos(roll), sin(roll), 0, 0, -sin(roll), cos(roll), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 

Then, multiply everything together. The order is important here. For normal rotations, you first want to multiply the Roll matrix by the Yaw matrix, and then multiply the product by the pitch matrix. However, if you try to β€œreverse” a rotation by reversing, you will want to multiply in the reverse order (in addition to angles with opposite values).

+5
source share

All Articles