DynaPDF Manual - Page 552

Previous Page 551 Index Next Page 553

Function Reference

Page 552 of 777

on the page it is used. Similarly, if a pattern is used within a template, the pattern

matrix maps pattern space to the template's default user space (that is, the template

coordinate space at the time the template is painted). A pattern may be used within

another pattern; the inner pattern’s matrix defines its relationship to the pattern space

of the outer pattern.

Working with Transformation Matrices

Coordinate transformations in PDF are achieved with so called Affine Transformations. Affine

transformations can represent any linear mapping from one coordinate system to another.

Affine transformations work with transformation matrices which consist of 6 real numbers. A

transformation matrix describes the coordinate origin, scaling factors of the x- and y-axis, as well as

the rotation angle of the coordinate system. A transformation matrix represents essentially a

coordinate space in which graphical objects can be drawn. Two coordinate spaces can easily be

concatenated by multiplying the corresponding transformation matrices.

Coordinates of objects which use their own coordinate space, such a text, templates, or patterns,

must be transformed to user space before the coordinates can be used. How this must be done is

described later.

Transformation matrices in DynaPDF are stored in the structure TCTM that is defined as follows:

struct TCTM

{

double a;

double b;

double c;

double d;

double x;

double y;

};

The identity matrix is [1, 0, 0, 1, 0, 0] (a, b, c, d, x, y).

The following overview lists the most important matrix manipulations:

• Translations are specified as [1, 0, 0, 1, tx, ty] where tx and ty represent the distances to

translate the origin of the coordinate system in horizontal and vertical dimensions,

respectively.

• Scaling is achieved by [sx, 0, 0, sy, 0, 0]. This scales the coordinates so that 1 unit in the

horizontal and vertical dimensions of the new coordinate system is the same size as sx and sy

units, respectively, in the previous coordinate system.

• Rotations are achieved by [cos α, sin α, -sin α, cos α, 0, 0], which has the effect of rotating the

coordinate system axes by an angle α (measured in radians) counter clockwise.

• Skew is specified by [1, tan α, tan β, 1, 0, 0], which skews the x-axis by an angle α, and the y-

axis by an angle β (measured in radians).

Previous topic: Coordinate Spaces

Next topic: Helper Functions