Extracting The Scaling Component Of A Matrix

Lawrence D'Oliveiro <[email protected]>
Newsgroups gmane.comp.lib.cairo
Organization Geek Central
Message-ID <[email protected]>
I just updated my “faux 3D ball” example
<https://github.com/ldo/python_pixman_examples/blob/master/faux_3d_ball>
to work with different resolutions just by changing a single parameter.
To do this, I had to properly size the convolution matrices in device
coordinates, when their sizes are given in user coordinates. Here’s how
I construct a matrix that implements just the scaling component of the
CTM in the Cairo context “ctx”:

    scaling = Matrix.scale(ctx.user_to_device_distance(Vector(1, 1)))

This can be easily adapted to extracting the scaling component of a
given matrix “mat”:

    scaling = Matrix.scale(mat.mapdelta(Vector(1, 1)))

Exercise: can you come up with a similarly simple expression for
extracting the angle of the rotation component of a matrix?
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.