# [cairo] Extracting The Scaling Component Of A Matrix

Tue Dec 15 00:39:02 PST 2015

```On Dec 14, 2015 10:30 PM, "Arjen Nienhuis" <a.g.nienhuis at gmail.com> wrote:
>
> > Yeah... You have to define what exactly you want.  A 2D matrix like the
ones
> > cairo uses can always be decomposed into a concatenation of the
following
> > matrices:
> >
> >   - transform
>
> transform is what cairo calls translate right?

Err.  Yes, I meant translate.

> >   - rotate
> >   - skew
> >   - scale
> >
> > This has many useful properties, and you can derive those four
transformations
> > from an arbitrary matrix easily.  Here's my derivation:
> >
> >
> >
> > This also describes the benefits of such decompositions:
> >
> >
http://research.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf
> >
> > If you transform a circle with a matrix, you get an ellipse.  If you are
> > interested in the major and minor axes of that ellipse, that's a
Singular
> > Value Decomposition of the 2D matrix.  I've put code here for doing
that:
> >
> >
> >
> > Cheers,
> >