[cairo] Adding cairo_shear and family
Bill Spitzak
spitzak at thefoundry.co.uk
Mon Jan 12 09:39:35 PST 2009
Paolo Bonzini wrote:
> Bill Spitzak wrote:
>> It might make more sense to make the call do the composite operation
>> that preserves area:
>>
>> [1+sx*sy sx]
>> [sy 1+sx*sy]
>>
>> Note that if either sx or sy are zero then it is the same as the
>> proposed call.
>
> I like this. But the composite operation that preserves area is
>
> [sqrt(1+sx*sy) sx
> sy sqrt(1+sx*sy]
>
> whose determinant is 1. Your matrix has determinant sx^2 sy^2+sx sy+1.
>
> For example, with this matrix
>
> cairo_shear (cr, sin(a), -sin(a));
>
> would be the same as cairo_rotate (cr, a) for angle between -90 and 90:
>
> [sqrt(1-sin^2 a) sin a [cos a sin a
> -sin a sqrt(1-sin^2 a)] = -sin a cos a]
>
> Paolo
You are right. I just multiplied the x and y shear matrices together,
the idea being that shear(x,y) would be the same as shear(x,0) and
shear(0,y) one after the other. Since each step preserves area I thought
the result would preserve area as well. I then made a mistake in the
multiplication so that I thought the result was symmetric. The actual
result is:
[1+sx*sy sx]
[xy 1 ]
or transposed with 1+sx*sy in the lower-right, depending on the order of
the shear calls. That is not very useful because the xy order matters.
The area-preserving one with sqrt() looks pretty useful to me, however.
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
More information about the cairo
mailing list