Re: Extracting The Scaling Component Of A Matrix

Lawrence D'Oliveiro <[email protected]>
Newsgroups gmane.comp.lib.cairo
Organization Geek Central
Message-ID <[email protected]>
On Sat, 12 Dec 2015 12:15:17 +0100, Behdad Esfahbod wrote:

> On 15-12-11 01:51 AM, Lawrence D'Oliveiro wrote:
>
> > 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 wouldn't do what you think it does for general matrices.  Or
> maybe I don't understand what you are trying to do.  Are you only
> interested in non-skewed matrices?

    import sys
    from qahirah import \
        Matrix, \
        Vector

    for \
        mat \
    in \
        (
            Matrix.scale(3),
            Matrix.skew((0, 1)) * Matrix.scale(3),
            Matrix.scale(3) * Matrix.skew((1, 0)),
            Matrix.skew((1, 1)),
            Matrix.skew((1, -1)) * Matrix.scale(3),
            Matrix.scale(3) * Matrix.skew((-1, 1)),
        ) \
    :
        sys.stdout.write \
          (
            "scaling part of {} = {}\n"
            .format
              (
                mat,
                mat.mapdelta(Vector(1, 1))
              )
          )
    #end for

    ...

    scaling part of Matrix(3, 0, 0, 3, 0, 0) = Vector(3, 3)
    scaling part of Matrix(3, 3, 0, 3, 0, 0) = Vector(3, 6)
    scaling part of Matrix(3, 0, 3, 3, 0, 0) = Vector(6, 3)
    scaling part of Matrix(1, 1, 1, 1, 0, 0) = Vector(2, 2)
    scaling part of Matrix(3, -3, 3, 3, 0, 0) = Vector(6, 0)
    scaling part of Matrix(3, 3, -3, 3, 0, 0) = Vector(0, 6)

Hmmm ...
-- 
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.