[cairo] Cairo transformations. Old bug that has been solved?
dov.grobgeld at gmail.com
Sun Oct 9 09:46:07 PDT 2011
I forgot to mention that my versions are:
running under Fedora 14.
On Sun, Oct 9, 2011 at 17:21, Dov Grobgeld <dov.grobgeld at gmail.com> wrote:
> I'm trying to understand the affine transformations in cairo and I'm
> currently quite confused. I don't get the same result when using
> matrix_multiply() as I get when doing the matrix multiplications "manually"
> through numpy:
> Consider the following python code:
> import cairo
> import numpy as np
> # routine to convert a cairo transformation to a numpy matrix
> def c2n(c):
> return np.matrix([[c,c,c], [c,c,c], [0,0,1]])
> # Create two cairo matrices for rotation and translation
> mr = cairo.Matrix() ; mr.rotate(np.pi/6)
> mt = cairo.Matrix() ; mt.translate(1,1)
> # Multiply these together and print the result
> print mt.multiply(mr) # Yields cairo.Matrix(0.866025, 0.5, -0.5,
> 0.866025, 0.366025, 1.36603)
> # Multiply these together using numpy. Note order change corresponding to
> first applying mr and then mt
> print c2n(mr)*c2n(mt) # Yields matrix([[ 0.8660254, 0.5 ,
> # [-0.5 , 0.8660254,
> # [ 0. , 0. , 1.
> Note that the x0 and the y0 values of the result is swapped in the cairo
> input compared to the numpy output.
> What is even more confusing to me is that the c-source code in git seems to
> be ok.
> I can see several possible reasons:
> 1. From looking at this problem for too long I'm making a wrong
> 2. The c-code has recently been updated to fix a bug that I have in my
> cairo version.
> 3. There is a bug in the python binding.
> Before I probe this further, does someone have any idea of what is going
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cairo