I am writing a program to create PDF file directly from my Program. I have used the PDF Reference manual and managed to figure out everything except for 1 thing. The Text Matrix
[x, y, 1]
This is a one dimensional vector (array) which places the point at the coordinates x and y. 1 is not needed to specify the point location, but it is helpful for the calculation of the location of a point in a different coordination system, like from device independent pixels to device depended pixels.
x_new = a*x + c*y + e;
y_new = b*x + d*y + f;
Written as matix, the calculation looks like this:
A translation moves a point.
[1, 0, 0, 1, tx, ty]
x_new = 1*x + 0*y + tx;
y_new = 0*x + 1*y + ty;
or
x_new = x + tx;
y_new = y + ty;
[cos(theta), sin(theta), -sin(theta), cos(theta), 0, 0]
x_new = cos(theta)*x - sin(theta)*y + 0;
y_new = sin(theta)*x + cos(theta)*y + 0;
0 degree rotation, cos(0)=1, sin(0)=0: [1, 0, -0, 1, 0, 0]
x_new = 1*x + 0*y + 0;
y_new = 0*x + 1*y + 0;
or
x_new = x;
y_new = y;
90 degree rotation, cos(90)=0, sin(90)=1: [0, 1, -1, 0, 0, 0]
x_new = 0*x + -1*y + 0;
y_new = 1*x + 0*y + 0;
or
x_new = -y;
y_new = x;
180 degree rotation, cos(180)=-1, sin(180)=0: [-1, 0, -0, -1, 0, 0]
x_new = -1*x + 0*y + 0;
y_new = 0*x + -1*y + 0;
or
x_new = -x;
y_new = -y;
270 degree rotation, cos(270)=0, sin(270)=-1: [0, -1, 1, 0, 0, 0]
x_new = 0*x + 1*y + 0;
y_new = -1*x + 0*y + 0;
or
x_new = y;
y_new = -x;
[0 1 -1 0 07 07]
0 1 -1 0: Rotation by 90 degrees 07 07: Translation (offset) by 7 in each x and y direction