Based on CSS3 transform spec:
http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
It also describes decomposing 2d matrix.
While we are at it, maybe support composing matrices given its component parts (translation, rotation, skew, perspective, etc).
Chromium also has an implementation in C++:
https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc