|
| Matrix2D (double a=1, double b=0, double c=0, double d=1, double h=0, double v=0) |
|
| Matrix2D (const Matrix2D &m) |
|
Matrix2D & | operator= (const Matrix2D &m) |
|
void | Set (double a, double b, double c, double d, double h, double v) |
|
void | Concat (double a, double b, double c, double d, double h, double v) |
|
Matrix2D & | operator*= (const Matrix2D &m) |
|
Matrix2D | operator* (const Matrix2D &m) const |
|
bool | operator== (const Matrix2D &m) const |
|
bool | operator!= (const Matrix2D &m) const |
|
PDF::Point | Mult (const PDF::Point &pt) const |
|
void | Mult (double &in_out_x, double &in_out_y) const |
|
Matrix2D | Inverse () const |
|
void | Translate (double h, double v) |
|
void | PreTranslate (double h, double v) |
|
void | PostTranslate (double h, double v) |
|
void | Scale (double h, double v) |
|
2D Matrix
A Matrix2D object represents a 3x3 matrix that, in turn, represents an affine transformation. A Matrix2D object stores only six of the nine numbers in a 3x3 matrix because all 3x3 matrices that represent affine transformations have the same third column (0, 0, 1).
Affine transformations include rotating, scaling, reflecting, shearing, and translating. In PDFNet, the Matrix2D class provides the foundation for performing affine transformations on vector drawings, images, and text.
A transformation matrix specifies the relationship between two coordinate spaces. By modifying a transformation matrix, objects can be scaled, rotated, translated, or transformed in other ways.
A transformation matrix in PDF is specified by six numbers, usually in the form of an array containing six elements. In its most general form, this array is denoted [a b c d h v]; The following table lists the arrays that specify the most common transformations:
- Translations are specified as [1 0 0 1 tx ty], where tx and ty are the distances to translate the origin of the coordinate system in the horizontal and vertical dimensions, respectively.
- Scaling is obtained 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 produced by [cos(A) sin(A) -sin(A) cos(A) 0 0], which has the effect of rotating the coordinate system axes by an angle 'A' counterclockwise.
- Skew is specified by [1 tan(A) tan(B) 1 0 0], which skews the x axis by an angle A and the y axis by an angle B.
Matrix2D elements are positioned as follows : | m_a m_b 0 | | m_c m_d 0 | | m_h m_v 1 |
A single Matrix2D object can store a single transformation or a sequence of transformations. The latter is called a composite transformation. The matrix of a composite transformation is obtained by multiplying (concatenating) the matrices of the individual transformations. Because matrix multiplication is not commutative-the order in which matrices are multiplied is significant. For example, if you first rotate, then scale, then translate, you get a different result than if you first translate, then rotate, then scale.
For more information on properties of PDF matrices please refer to PDF Reference Manual (Sections 4.2 'Coordinate Systems' and 4.2.3 'Transformation Matrices')
* The following sample illustrates how to use
Matrix2D in order to position
* an image on the page. Note that PDFNet uses the same convention of matrix
* multiplication used in PostScript and OpenGL.
*
* Element element = eb.CreateImage(Image(...));
* double deg2rad = 3.1415926535 / 180.0;
*
* mtx *=
Matrix2D(300, 0, 0, 200, 0, 0);
* element.GetGState().SetTransform(mtx);
* writer.WritePlacedElement(element);
*
* The following sample sample illustrates how to use
Matrix2D in order to calculate
* absolute positioning for the text on the page.
* ...
*
Matrix2D text_mtx = text_element.GetTextMatrix();
* double x, y;
*
for (
CharIterator itr = text_element.GetCharIterator(); itr.HasNext(); itr.Next()) {
* x = itr.Current().x;
* y = itr.Current().y;
*
*
*
*
*
* mtx.Mult(x, y);
* }
*
Definition at line 103 of file Matrix2D.h.