[cairo] Projective transforms

Maarten Bosmans mkbosmans at gmail.com
Thu Aug 12 01:24:32 PDT 2010


2010/8/11 Andrea Canciani <ranma42 at gmail.com>:
> On Wed, Aug 11, 2010 at 10:16 PM, Maarten Bosmans <mkbosmans at gmail.com> wrote:
> [snip]
>> The SVG 1.1 spec only defines affine transformations. A proposed
>> extension to include projective transformations is a working draft:
>> http://www.w3.org/TR/2009/WD-SVG-Transforms-20090320/
>> That page nicely lays out the use of homogeneous coordinates in 2D and
>> 3D and how the conversion works. It could be used as a guide for
>> implementing in pixman and of course also for the cairo svg surface.
> That document describes 3D (homogeneous) transformations.
> Pixman works on 2D images (and already implements homogeneous 2D
> transformations).
> What would be the benefit of using 3D transformations?

Ah, yes. I see. Indeed no need to go 3D, a 3x3 matrix for 2D
homogeneous coordinates will suffice.

>> If the general outline of implementing such a thing in cairo (and
>> pixman?) becomes clear, I can certainly try to whip up some patches.
>> My main motivation would be to enable the rendering of animated text
>> in a projective plain, like the classic Star Wars prologue.
> That is possible using 2D projective transformations:
> x' = x
> y' = y
> w' = 1 + y
> would become
> x'' = x/(1+y)
> y'' = y/(1+y)
> Of course you will actually have to choose appropriate constants.
> Andrea

So the main thing would be to let Cairo respect the third coordinate
of a vector and don't assume it is always 1.

What I could not find in Pixman is a function that operates on a
matrix and adjusts the bottom row [0, 0, 1], such that the first two
elements aren't zero. Is the current way of getting a projective
transform only to set the elements manually, like matrix[2][1] = 0.1;?

Maarten


More information about the cairo mailing list