title: Convert OpenGL 4-matrix into VRML T*R*S
body: <p>I am trying to export a scene from a direct-mode OpenGL program to VRML.</p>
  
  <p>In both OpenGL and VRML, faces can be grouped into objects with their own translation, rotation and scale relative to the scene origin.</p>
  
  <p>In OpenGL these are stored as a 4-matrix representing a translation and a rotation/scale in one matrix <a href="http://www.songho.ca/opengl/gl_transform.html" rel="nofollow">[1]</a>. In VRML these must be represented as separate translation, rotation and scaling vectors <a href="http://graphcomp.com/info/specs/sgi/vrml/spec/part1/concepts.html#CoordinateSystems" rel="nofollow">[2]</a><a href="http://graphcomp.com/info/specs/sgi/vrml/spec/part1/nodesRef.html#Transform" rel="nofollow">[3]</a>.</p>
  
  <p>How can I decompose an arbitrary 4-matrix in this way?</p>
  
  <p>I would prefer to use a library function to do this, to minimise the code I have to maintain and to reduce the chance of errors. I am using C# on Windows and can access any CLR or windows native DLL.</p>