JGraphics Matrix Transformations

The t_jmatrix is one way to represent a transformation. More...

+ Collaboration diagram for JGraphics Matrix Transformations:

Data Structures

struct  t_jmatrix
 An affine transformation (such as scale, shear, etc). More...

Functions

void jgraphics_matrix_init (t_jmatrix *x, double xx, double yx, double xy, double yy, double x0, double y0)
 Set a t_jmatrix to an affine transformation.
void jgraphics_matrix_init_identity (t_jmatrix *x)
 Modify a matrix to be an identity transform.
void jgraphics_matrix_init_translate (t_jmatrix *x, double tx, double ty)
 Initialize a t_jmatrix to translate (offset) a point.
void jgraphics_matrix_init_scale (t_jmatrix *x, double sx, double sy)
 Initialize a t_jmatrix to scale (offset) a point.
void jgraphics_matrix_init_rotate (t_jmatrix *x, double radians)
 Initialize a t_jmatrix to rotate (offset) a point.
void jgraphics_matrix_translate (t_jmatrix *x, double tx, double ty)
 Apply a translation to an existing matrix.
void jgraphics_matrix_scale (t_jmatrix *x, double sx, double sy)
 Apply a scaling to an existing matrix.
void jgraphics_matrix_rotate (t_jmatrix *x, double radians)
 Apply a rotation to an existing matrix.
void jgraphics_matrix_invert (t_jmatrix *x)
 Invert an existing matrix.
void jgraphics_matrix_multiply (t_jmatrix *result, const t_jmatrix *a, const t_jmatrix *b)
 Multiply two matrices: resulting matrix has effect of first applying a and then applying b.
void jgraphics_matrix_transform_point (const t_jmatrix *matrix, double *x, double *y)
 Transform a point using a t_jmatrix transormation.

Detailed Description

The t_jmatrix is one way to represent a transformation.

You can use the t_jmatrix in the call to jgraphics_transform(), jgraphics_setmatrix(), and jgraphics_pattern_set_matrix for specifying transformations.


Function Documentation

void jgraphics_matrix_init ( t_jmatrix x,
double  xx,
double  yx,
double  xy,
double  yy,
double  x0,
double  y0 
)

Set a t_jmatrix to an affine transformation.

Parameters:
x
xx
yx
xy
yy
x0
y0
Remarks:
given x,y the matrix specifies the following transformation:
    xnew = xx * x + xy * y + x0; 
    ynew = yx * x + yy * y + y0;
void jgraphics_matrix_init_identity ( t_jmatrix x)

Modify a matrix to be an identity transform.

Parameters:
xThe t_jmatrix.
void jgraphics_matrix_init_rotate ( t_jmatrix x,
double  radians 
)

Initialize a t_jmatrix to rotate (offset) a point.

Parameters:
xThe t_jmatrix.
radiansThe angle or rotation in radians.
void jgraphics_matrix_init_scale ( t_jmatrix x,
double  sx,
double  sy 
)

Initialize a t_jmatrix to scale (offset) a point.

Parameters:
xThe t_jmatrix.
sxThe horizontal scale factor.
syThe vertical scale factor.
void jgraphics_matrix_init_translate ( t_jmatrix x,
double  tx,
double  ty 
)

Initialize a t_jmatrix to translate (offset) a point.

Parameters:
xThe t_jmatrix.
txThe amount of x-axis translation.
tyThe amount of y-axis translation.
void jgraphics_matrix_invert ( t_jmatrix x)

Invert an existing matrix.

Parameters:
xThe t_jmatrix.
void jgraphics_matrix_multiply ( t_jmatrix result,
const t_jmatrix a,
const t_jmatrix b 
)

Multiply two matrices: resulting matrix has effect of first applying a and then applying b.

Parameters:
resultThe resulting product t_jmatrix.
aThe first operand.
bThe second operand.
void jgraphics_matrix_rotate ( t_jmatrix x,
double  radians 
)

Apply a rotation to an existing matrix.

Parameters:
xThe t_jmatrix.
radiansThe angle or rotation in radians.
void jgraphics_matrix_scale ( t_jmatrix x,
double  sx,
double  sy 
)

Apply a scaling to an existing matrix.

Parameters:
xThe t_jmatrix.
sxThe horizontal scale factor.
syThe vertical scale factor.
void jgraphics_matrix_transform_point ( const t_jmatrix matrix,
double *  x,
double *  y 
)

Transform a point using a t_jmatrix transormation.

Parameters:
matrixThe t_jmatrix.
xThe address of the variable holding the x coordinate.
yThe address of the variable holding the y coordinate.
void jgraphics_matrix_translate ( t_jmatrix x,
double  tx,
double  ty 
)

Apply a translation to an existing matrix.

Parameters:
xThe t_jmatrix.
txThe amount of x-axis translation.
tyThe amount of y-axis translation.