[cairo] [patch] enable projective transformations
Andrea Canciani
ranma42 at gmail.com
Mon Aug 16 22:27:55 PDT 2010
On Tue, Aug 17, 2010 at 1:24 AM, Bill Spitzak <spitzak at gmail.com> wrote:
> Maarten Bosmans wrote:
>>
>> This is a first attempt to add projective transformations to Cairo. It
>> is far from complete, but mostly meant to get the discussion going
>> about how such a feature should be implemented.
>
> I believe if you want to concatenate transforms you need to keep 12 numbers
> (a 4x3 matrix) around. Otherwise not enough information is remembered so
> that two "rotate about the y axis by 10 degrees" can produce the same result
> as one "rotate about the y axis by 20 degrees". The 8 number cannot
> distinguish such a rotation from a horizontal scale by 1-sin(10 degrees).
A 2D projective transform is 3x3 (it is a linear transform in the
associated homogeneous space), so requires only 9 elements.
Or are you suggesting that using 3D transformations would be better?
Do you have any use case (where 2D projective transform would not be
enough and 3D would be needed)?
>
> Treating these as 3 rows (or columns) of a 4x4 matrix will allow you to
> multiply them. The last row/column will be [0,0,0,1] always, similar to the
> current Cairo matrix.
>
> Perspective can be a single number 'D' that basically says "z makes the
> image this much smaller". This value goes in the 3rd number of that extra
> row/column. Objects at z are scaled to be 1/(1+Dz) in size.
>
> If you don't want the vanishing point to be forced to be at 0,0 then you
> need to apply transforms before and after the perspective matrix. If you
> place non-zero at that location in the matrix and multiply, the result can
> have values different than the identity in all 16 locations. So it looks
> like all 16 numbers must be stored.
>
> The SVG paper does correctly conclude that the final rendering does not
> require a 4x4 matrix if the source object is a flat plane with everything at
> z = 0. Since z = 0 an entire column of the matrix is ignored, and since the
> output z is not relevant (only the w is) an entire row is ignored. Deleting
> this row and column and get a 3x3 matrix that translates x,y,1 into wx,wy,w.
> However this matrix is useless for concatenating transforms. Still it might
> be the API to pixman.
Why should it be useless for concatenating transforms?
>
> In conclusion:
>
> I think the internal matrix may have to be 4x4 with all 16 numbers unknown
> so that Cairo can remain transform-independent.
>
> Final rendering only requires 9 of the 16 numbers in the CTM if the objects
> are actually "2D".
>
> I do like the SVG/CSS spec of just saying "perspective" with one number.
> Would prefer to directly specify it as zero means "flat".
>
>
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
More information about the cairo
mailing list