cairomm 1.18.0
|
A Transformation matrix. More...
#include <cairomm/matrix.h>
Public Member Functions | |
Matrix () | |
Creates an uninitialized matrix. More... | |
Matrix (double xx, double yx, double xy, double yy, double x0, double y0) | |
Creates a matrix Sets to be the affine transformation given by xx, yx, xy, yy, x0, y0. More... | |
void | translate (double tx, double ty) |
Applies a translation by tx, ty to the transformation in matrix. More... | |
void | scale (double sx, double sy) |
Applies scaling by sx, sy to the transformation in matrix. More... | |
void | rotate (double radians) |
Applies rotation by radians to the transformation in matrix. More... | |
void | invert () |
Changes matrix to be the inverse of it's original value. More... | |
void | multiply (Matrix & a, Matrix & b) |
Multiplies the affine transformations in a and b together and stores the result in this matrix. More... | |
void | transform_distance (double & dx, double & dy) const |
Transforms the distance vector (dx,dy) by matrix. More... | |
void | transform_point (double & x, double & y) const |
Transforms the point (x, y) by this matrix. More... | |
Related Functions | |
(Note that these are not member functions.) | |
Matrix | identity_matrix () |
Returns a Matrix initialized to the identity matrix. More... | |
Matrix | translation_matrix (double tx, double ty) |
Returns a Matrix initialized to a transformation that translates by tx and ty in the X and Y dimensions, respectively. More... | |
Matrix | scaling_matrix (double sx, double sy) |
Returns a Matrix initialized to a transformation that scales by sx and sy in the X and Y dimensions, respectively. More... | |
Matrix | rotation_matrix (double radians) |
Returns a Matrix initialized to a transformation that rotates by radians. More... | |
Matrix | operator* (const Matrix & a, const Matrix & b) |
Multiplies the affine transformations in a and b together and returns the result. More... | |
A Transformation matrix.
Cairo::Matrix is used throughout cairomm to convert between different coordinate spaces. A Matrix holds an affine transformation, such as a scale, rotation, shear, or a combination of these. The transformation of a point (x,y) is given by:
The current transformation matrix of a Context, represented as a Matrix, defines the transformation from user-space coordinates to device-space coordinates.
Cairo::Matrix::Matrix | ( | ) |
Creates an uninitialized matrix.
If you want a matrix initialized to a certain value, either specify the values explicitly with the other constructor or use one of the free functions for initializing matrices with specific scales, rotations, etc.
Cairo::Matrix::Matrix | ( | double | xx, |
double | yx, | ||
double | xy, | ||
double | yy, | ||
double | x0, | ||
double | y0 | ||
) |
Creates a matrix Sets to be the affine transformation given by xx, yx, xy, yy, x0, y0.
The transformation is given by:
xx | xx component of the affine transformation |
yx | yx component of the affine transformation |
xy | xy component of the affine transformation |
yy | yy component of the affine transformation |
x0 | X translation component of the affine transformation |
y0 | Y translation component of the affine transformation |
void Cairo::Matrix::invert | ( | ) |
Changes matrix to be the inverse of it's original value.
Not all transformation matrices have inverses; if the matrix collapses points together (it is degenerate), then it has no inverse and this function will throw an exception.
Multiplies the affine transformations in a and b together and stores the result in this matrix.
The effect of the resulting transformation is to first apply the transformation in a to the coordinates and then apply the transformation in b to the coordinates.
It is allowable for result to be identical to either a or b.
void Cairo::Matrix::rotate | ( | double | radians | ) |
Applies rotation by radians to the transformation in matrix.
The effect of the new transformation is to first rotate the coordinates by radians, then apply the original transformation to the coordinates.
radians | angle of rotation, in radians. The direction of rotation is defined such that positive angles rotate in the direction from the positive X axis toward the positive Y axis. With the default axis orientation of cairo, positive angles rotate in a clockwise direction. |
void Cairo::Matrix::scale | ( | double | sx, |
double | sy | ||
) |
Applies scaling by sx, sy to the transformation in matrix.
The effect of the new transformation is to first scale the coordinates by sx and sy, then apply the original transformation to the coordinates.
sx | scale factor in the X direction |
sy | scale factor in the Y direction |
void Cairo::Matrix::transform_distance | ( | double & | dx, |
double & | dy | ||
) | const |
Transforms the distance vector (dx,dy) by matrix.
This is similar to transform_point() except that the translation components of the transformation are ignored. The calculation of the returned vector is as follows:
Affine transformations are position invariant, so the same vector always transforms to the same vector. If (x1,y1) transforms to (x2,y2) then (x1+dx1,y1+dy1) will transform to (x1+dx2,y1+dy2) for all values of x1 and x2.
dx | X component of a distance vector. An in/out parameter |
dy | Y component of a distance vector. An in/out parameter |
void Cairo::Matrix::transform_point | ( | double & | x, |
double & | y | ||
) | const |
Transforms the point (x, y) by this matrix.
x | X position. An in/out parameter |
y | Y position. An in/out parameter |
void Cairo::Matrix::translate | ( | double | tx, |
double | ty | ||
) |
Applies a translation by tx, ty to the transformation in matrix.
The effect of the new transformation is to first translate the coordinates by tx and ty, then apply the original transformation to the coordinates.
tx | amount to translate in the X direction |
ty | amount to translate in the Y direction |
Multiplies the affine transformations in a and b together and returns the result.
The effect of the resulting transformation is to first apply the transformation in a to the coordinates and then apply the transformation in b to the coordinates.
It is allowable for result to be identical to either a or b.
|
related |
Returns a Matrix initialized to a transformation that rotates by radians.
radians | angle of rotation, in radians. The direction of rotation is defined such that positive angles rotate in the direction from the positive X axis toward the positive Y axis. With the default axis orientation of cairo, positive angles rotate in a clockwise direction. |
|
related |
Returns a Matrix initialized to a transformation that scales by sx and sy in the X and Y dimensions, respectively.
sx | scale factor in the X direction |
sy | scale factor in the Y direction |
|
related |
Returns a Matrix initialized to a transformation that translates by tx and ty in the X and Y dimensions, respectively.
tx | amount to translate in the X direction |
ty | amount to translate in the Y direction |