[cairo] API Shakeup: cairo_current_matrix
Bill Spitzak
spitzak at d2.com
Tue Feb 15 17:45:39 PST 2005
This is equivalent to describing the matrix and transforms by it this way:
|X| | xx xy x0 | |x|
|Y| = | yx yy y0 | x |y|
|1| | 0 0 1 | |1|
where X,Y is the device position and x,y is the user position.
In this syntax a transformation such as rotation is done by
pre-multiplication:
[new_current_matrix] = [rotation_matrix] x [current_matrix]
Note that some Postscript and OpenGL documentation trasposes the matrix,
describe the vectors as rows instead of columns, and transform by
post-multiply. This is mathematically the same, however it appears the
above syntax is much more popular nowadays. (And to further confuse
things OpenGL does transformations completely opposite the way
PostScript does, by post-multiply in the above syntax. Translate
followed by rotate in OpenGL rotates about the real origin, not the
translated point. I find this very confusing and like the PostScript
method much better!)
I suspect you have xy and yx swapped in either your description of the
structure or in your functions. If you meant to order them in the same
way PostScript does it is xx,yx,xy,yy,x0,y0, ie. by column in the above
diagram.
Carl Worth wrote:
> /*
> x_device = x_user * matrix.xx + y_user * matrix.xy + matrix.x0;
> y_device = x_user * matrix.yx + y_user * matrix.yy + matrix.y0;
> */
>
> typedef struct _cairo_matrix {
> double xx;
> double xy;
> double yx;
> double yy;
> double x0;
> double y0;
> };
More information about the cairo
mailing list