Public Member Functions | Public Attributes

gfxMatrix Struct Reference

A matrix that represents an affine transformation. More...

#include <gfxMatrix.h>

List of all members.

Public Member Functions

 gfxMatrix ()
 Initializes this matrix as the identity matrix.
 gfxMatrix (gfxFloat a, gfxFloat b, gfxFloat c, gfxFloat d, gfxFloat tx, gfxFloat ty)
 Initializes the matrix from individual components.
const gfxMatrixoperator*= (const gfxMatrix &m)
 Post-multiplies m onto the matrix.
gfxMatrix operator* (const gfxMatrix &m) const
 Multiplies *this with m and returns the result.
const gfxMatrixReset ()
 Resets this matrix to the identity matrix.
const gfxMatrixInvert ()
 Inverts this matrix, if possible.
PRBool IsSingular () const
 Check if matrix is singular (no inverse exists).
const gfxMatrixScale (gfxFloat x, gfxFloat y)
 Scales this matrix.
const gfxMatrixTranslate (const gfxPoint &pt)
 Translates this matrix.
const gfxMatrixRotate (gfxFloat radians)
 Rotates this matrix.
const gfxMatrixMultiply (const gfxMatrix &m)
 Multiplies the current matrix with m.
const gfxMatrixPreMultiply (const gfxMatrix &m)
 Multiplies the current matrix with m.
gfxPoint Transform (const gfxPoint &point) const
 Transforms a point according to this matrix.
gfxSize Transform (const gfxSize &size) const
 Transform a distance according to this matrix.
gfxRect Transform (const gfxRect &rect) const
 Transforms both the point and distance according to this matrix.
gfxRect TransformBounds (const gfxRect &rect) const
gfxPoint GetTranslation () const
 Returns the translation component of this matrix.
PRBool HasNonIntegerTranslation () const
 Returns true if the matrix is anything other than a straight translation by integers.
PRBool HasNonTranslation () const
 Returns true if the matrix has any transform other than a straight translation.
PRBool HasNonTranslationOrFlip () const
 Returns true if the matrix has any transform other than a translation or a -1 y scale (y axis flip).
PRBool HasNonAxisAlignedTransform () const
 Returns true if the matrix has any transform other than a translation or scale; this is, if there is no rotation.
double Determinant () const
 Computes the determinant of this matrix.
gfxSize ScaleFactors (PRBool xMajor) const

Public Attributes

double xx
double yx
double xy
double yy
double x0
double y0

Detailed Description

A matrix that represents an affine transformation.

Projective transformations are not supported. This matrix looks like:

/ a b 0 \ | c d 0 | \ tx ty 1 /

So, transforming a point (x, y) results in:

/ a b 0 \ / a * x + c * y + tx \ T (x y 1) * | c d 0 | = | b * x + d * y + ty | \ tx ty 1 / \ 1 /


Constructor & Destructor Documentation

gfxMatrix::gfxMatrix (  )  [inline]

Initializes this matrix as the identity matrix.

gfxMatrix::gfxMatrix ( gfxFloat  a,
gfxFloat  b,
gfxFloat  c,
gfxFloat  d,
gfxFloat  tx,
gfxFloat  ty 
) [inline]

Initializes the matrix from individual components.

See the class description for the layout of the matrix.


Member Function Documentation

double gfxMatrix::Determinant (  )  const [inline]

Computes the determinant of this matrix.

gfxPoint gfxMatrix::GetTranslation (  )  const [inline]

Returns the translation component of this matrix.

PRBool gfxMatrix::HasNonAxisAlignedTransform (  )  const [inline]

Returns true if the matrix has any transform other than a translation or scale; this is, if there is no rotation.

PRBool gfxMatrix::HasNonIntegerTranslation (  )  const [inline]

Returns true if the matrix is anything other than a straight translation by integers.

PRBool gfxMatrix::HasNonTranslation (  )  const [inline]

Returns true if the matrix has any transform other than a straight translation.

PRBool gfxMatrix::HasNonTranslationOrFlip (  )  const [inline]

Returns true if the matrix has any transform other than a translation or a -1 y scale (y axis flip).

const gfxMatrix& gfxMatrix::Invert (  ) 

Inverts this matrix, if possible.

Otherwise, the matrix is left unchanged.

XXX should this do something with the return value of cairo_matrix_invert?

PRBool gfxMatrix::IsSingular (  )  const [inline]

Check if matrix is singular (no inverse exists).

const gfxMatrix& gfxMatrix::Multiply ( const gfxMatrix m  ) 

Multiplies the current matrix with m.

This is a post-multiplication, i.e. the transformations of m are applied _after_ the existing transformations.

XXX is that difference (compared to Rotate etc) a good thing?

gfxMatrix gfxMatrix::operator* ( const gfxMatrix m  )  const [inline]

Multiplies *this with m and returns the result.

const gfxMatrix& gfxMatrix::operator*= ( const gfxMatrix m  )  [inline]

Post-multiplies m onto the matrix.

const gfxMatrix& gfxMatrix::PreMultiply ( const gfxMatrix m  ) 

Multiplies the current matrix with m.

This is a pre-multiplication, i.e. the transformations of m are applied _before_ the existing transformations.

const gfxMatrix& gfxMatrix::Reset (  ) 

Resets this matrix to the identity matrix.

const gfxMatrix& gfxMatrix::Rotate ( gfxFloat  radians  ) 

Rotates this matrix.

The rotation is pre-multiplied onto this matrix, i.e. the translation takes place after the other transformations.

Parameters:
radians Angle in radians.
const gfxMatrix& gfxMatrix::Scale ( gfxFloat  x,
gfxFloat  y 
)

Scales this matrix.

The scale is pre-multiplied onto this matrix, i.e. the scaling takes place before the other transformations.

gfxSize gfxMatrix::ScaleFactors ( PRBool  xMajor  )  const [inline]
gfxPoint gfxMatrix::Transform ( const gfxPoint point  )  const

Transforms a point according to this matrix.

gfxSize gfxMatrix::Transform ( const gfxSize size  )  const

Transform a distance according to this matrix.

This does not apply any translation components.

gfxRect gfxMatrix::Transform ( const gfxRect rect  )  const

Transforms both the point and distance according to this matrix.

gfxRect gfxMatrix::TransformBounds ( const gfxRect rect  )  const
const gfxMatrix& gfxMatrix::Translate ( const gfxPoint pt  ) 

Translates this matrix.

The translation is pre-multiplied onto this matrix, i.e. the translation takes place before the other transformations.


Member Data Documentation

double gfxMatrix::x0
double gfxMatrix::xx
double gfxMatrix::xy
double gfxMatrix::y0
double gfxMatrix::yx
double gfxMatrix::yy

The documentation for this struct was generated from the following file: