glm - Decompose mat4 into translation and rotation?

Silverlan picture Silverlan · Jul 29, 2013 · Viewed 20.8k times · Source

For purposes of lerping I need to decompose a 4x4 matrix into a quaternion and a vec3. Grabbing the quaternion is simple, as you can just pass the matrix into the constructor, but I can't find a way to grab the translation. Surely there must be a way?

Answer

kerim picture kerim · Oct 18, 2013

glm::vec3(m[3]) is the position vector(assuming m is glm::mat4)