 Max 5 API Reference

# JGraphics Matrix Transformations [JGraphics]

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:
 x The t_jmatrix.
 void jgraphics_matrix_init_rotate ( t_jmatrix * x, double radians )

Initialize a t_jmatrix to rotate (offset) a point.

Parameters:
 void jgraphics_matrix_init_scale ( t_jmatrix * x, double sx, double sy )

Initialize a t_jmatrix to scale (offset) a point.

Parameters:
 x The t_jmatrix. sx The horizontal scale factor. sy The 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:
 x The t_jmatrix. tx The amount of x-axis translation. ty The amount of y-axis translation.
 void jgraphics_matrix_invert ( t_jmatrix * x )

Invert an existing matrix.

Parameters:
 x The 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:
 result The resulting product t_jmatrix. a The first operand. b The second operand.
 void jgraphics_matrix_rotate ( t_jmatrix * x, double radians )

Apply a rotation to an existing matrix.

Parameters:
 void jgraphics_matrix_scale ( t_jmatrix * x, double sx, double sy )

Apply a scaling to an existing matrix.

Parameters:
 x The t_jmatrix. sx The horizontal scale factor. sy The 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:
 matrix The t_jmatrix. x The address of the variable holding the x coordinate. y The 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:
 x The t_jmatrix. tx The amount of x-axis translation. ty The amount of y-axis translation.