Creating a rotation matrix with pitch, yaw, roll using Eigen

Caesar picture Caesar · Jan 28, 2014 · Viewed 28.2k times · Source

How do I create a rotation matrix using pitch, yaw, roll with Eigen library?

Answer

Caesar picture Caesar · Jan 28, 2014

Seeing as how I couldn't find a prebuilt 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();