Nov 4 2009

The math behind extracting EULER VALUES from a 4×4 transform matrix

This little snippet of code was given to my by my buddy Scott Parrish, who’s a fellow creature TD at ILM.

global proc float[] matrixExtractRot (matrix $aMatrix)
{
  float $result[3];
  $result[0] = rad_to_deg(atan2($aMatrix[1][2], $aMatrix[2][2]));
  $result[1] = rad_to_deg(-asin ($aMatrix[0][2]));
  $result[2] = rad_to_deg(atan2($aMatrix[0][1], $aMatrix[0][0]));
  return $result;
}

Leave a Reply