Rotation quaternion + translation vector representation of rigid transformation applied using glMultMatrix()

Alec Jacobson

October 07, 2013

weblog/

There's likely a better way to do this, but suppose you have a 3d rigid transformation stored as a quaternion for the rotation and a vector for the translation using Eigen:

Eigen::Quaterniond q;
Eigen::Vector3d t;

Then you can apply this to your current OpenGL matrix using

glMultMatrixd((Translation3d(t) * q).matrix().data());

which is the same as:

glTranslated(t(0),t(1),t(2));
glMultMatrixd(Affine3d(q).matrix().data());