Click or drag to resize

FS_MATRIX Class

Represents the transformation matrices
Inheritance Hierarchy
SystemObject
  Patagames.PdfFS_MATRIX

Namespace: Patagames.Pdf
Assembly: Patagames.Pdf (in Patagames.Pdf.dll) Version: 4.94.2704
Syntax
public class FS_MATRIX

The FS_MATRIX type exposes the following members.

Constructors
 NameDescription
Public methodFS_MATRIX Initialize a new instance of FS_MATRIX class
Public methodFS_MATRIX(PdfTypeBase) Initializes a new instance of the FS_MATRIX structure with the specified array.
Public methodFS_MATRIX(Double, Double, Double, Double, Double, Double) Initialize a new instance of FS_MATRIX class
Public methodFS_MATRIX(Single, Single, Single, Single, Single, Single) Initialize a new instance of FS_MATRIX class
Top
Methods
 NameDescription
Public methodConcat Multiplies this matrix by the matrix specified in the matrix parameter, and in the order specified in the prepended parameter.
Public methodConcatInverse Inverts the matrix specified in the matrix parameter and than multiplies this matrix by the inverted matrix, and in the order specified in the prepended parameter.
Public methodGetReverse Inverts this Matrix, if it is invertible and return as a new Matrix.
Public methodGetUnitArea Get unit area
Public methodGetXUnit Get x unit
Public methodGetYUnit Get y unit
Public methodIs90Rotated Gets a value indicating whether this Matrix is rotated.
Public methodIsIdentity Gets a value indicating whether this Matrix is the identity matrix.
Public methodIsInvertible Gets a value indicating whether this Matrix is invertible.
Public methodIsScaled Gets a value indicating whether this Matrix is scaled.
Public methodRotate(Single, Boolean) Applies a clockwise rotation of an amount specified in the angle parameter, around the origin (zero x and y coordinates) for this Matrix.
Public methodRotate(Single, Single, Single, Boolean) Applies a clockwise rotation about the specified point to this Matrix in the specified order.
Public methodScale Applies the specified scale vector (sx and sy) to this Matrix using the specified order.
Public methodSetIdentity Initializes this instance of the FS_MATRIX class as the identity matrix.
Public methodSetReverse Inverts this matrix, if it is invertible.
Public methodSetReverse(FS_MATRIX) Inverts the specified matrix, if it is invertible and set it to this matrix.
Public methodShear Applies the specified shear vector to this Matrix in the specified order.
Public methodToArray Returns a PdfTypeArray representation of the matrix.
Public methodTransformDistance(Single) Applies the geometric transform represented by this Matrix to a distance.
Public methodTransformDistance(Int32, Int32) Applies the geometric transform represented by this Matrix to a distance.
Public methodTransformDistance(Single, Single) Applies the geometric transform represented by this Matrix to a distance.
Public methodTransformPoint(Int32, Int32) Applies the geometric transform represented by this Matrix to a specified point.
Public methodTransformPoint(Single, Single) Applies the geometric transform represented by this Matrix to a specified point.
Public methodTransformRect Applies the geometric transform represented by this Matrix to a specified rectangle.
Public methodTransformVector Applies only the scale and rotate components of this Matrix to the specified point.
Public methodTransformXDistance(Int32) Applies the geometric transform represented by this Matrix to a x-coordinate of the distance vector.
Public methodTransformXDistance(Single) Applies the geometric transform represented by this Matrix to a x-coordinate of the distance vector.
Public methodTransformYDistance(Int32) Applies the geometric transform represented by this Matrix to a y-coordinate of the distance vector.
Public methodTransformYDistance(Single) Applies the geometric transform represented by this Matrix to a y-coordinate of the distance vector.
Public methodTranslate(Int32, Int32, Boolean) Applies the specified translation vector to this Matrix in the specified order.
Public methodTranslate(Single, Single, Boolean) Applies the specified translation vector to this Matrix in the specified order.
Top
Fields
 NameDescription
Public fielda Coefficient a.
Public fieldb Coefficient b.
Public fieldc Coefficient c.
Public fieldd Coefficient d.
Public fielde Coefficient e.
Public fieldf Coefficient f.
Top
Remarks
To understand the mathematics of coordinate transformations in PDF, it is vital to remember two points:
  • Transformations alter coordinate systems, not graphics objects. All objects painted before a transformation is applied are unaffected by the transformation. Objects painted after the transformation is applied are interpreted in the transformed coordinate system.
  • Transformation matrices specify the transformation from the new (transformed) coordinate system to the original (untransformed) coordinate system. All coordinates used after the transformation are expressed in the transformed coordinate system. PDF applies the transformation matrix to find the equivalent coordinates in the untransformed coordinate system.
Note  Note
Many computer graphics textbooks consider transformations of graphics objects rather than of coordinate systems. Although either approach is correct and selfconsistent, some details of the calculations differ depending on which point of view is taken.

PDF represents coordinates in a two-dimensional space. The point (x, y) in such a space can be expressed in vector form as [x y 1]. The constant third element of this vector (1) is needed so that the vector can be used with 3-by-3 matrices in the calculations described below.

The transformation between two coordinate systems is represented by a 3-by-3 transformation matrix written as follows:

            |a b 0|
            |c d 0|
            |e f 1|
            

Because a transformation matrix has only six elements that can be changed, it is usually specified in PDF as the six-element array [a b c d e f ].

Coordinate transformations are expressed as matrix multiplications:

                                       |a b 0|
            [ x′ y′ 1 ] =  [ x y 1 ] x |c d 0|
                                       |e f 1|
            

Because PDF transformation matrices specify the conversion from the transformed coordinate system to the original (untransformed) coordinate system, x′ and y′ in this equation are the coordinates in the untransformed coordinate system, and x and y are the coordinates in the transformed system. The multiplication is carried out as follows:

            x′ = a × x + c × y + e
            y′ = b × x + d × y + f
            

If a series of transformations is carried out, the matrices representing each of the individual transformations can be multiplied together to produce a single equivalent matrix representing the composite transformation

Matrix multiplication is not commutative — the order in which matrices are multiplied is significant. Consider a sequence of two transformations: a scaling transformation applied to the user space coordinate system, followed by a conversion from the resulting scaled user space to device space. Let Ms be the matrix specifying the scaling and Mc the current transformation matrix, which transforms user space to device space. Recalling that coordinates are always specified in the transformed space, the correct order of transformations must first convert the scaled coordinates to default user space and then the default user space coordinates to device space. This can be expressed as

            Xd = Xu × Mc  = (Xs × Ms) × Mc = Xs × (Ms × Mc)
            
where
            Xd denotes the coordinates in device space
Xu denotes the coordinates in default user space
Xs denotes the coordinates in scaled user space

This shows that when a new transformation is concatenated with an existing one, the matrix representing it must be multiplied before (premultiplied with) the existing transformation matrix.

This result is true in general for PDF: when a sequence of transformations is carried out, the matrix representing the combined transformation (M′) is calculated by premultiplying the matrix representing the additional transformation (Mt) with the one representing all previously existing transformations (M):

            M′ = Mt × M
            
Note  Note
When rendering graphics objects, it is sometimes necessary for an application to perform the inverse of a transformation—that is, to find the user space coordinates that correspond to a given pair of device space coordinates. Not all transformations are invertible, however. For example, if a matrix contains a, b, c, and d elements that are all zero, all user coordinates map to the same device coordinates and there is no unique inverse transformation. Such noninvertible transformations are not very useful and generally arise from unintended operations, such as scaling by 0. Use of a noninvertible matrix when painting graphics objects can result in unpredictable behavior.
See Also