# Matrix

Group: Affine Matrix

Summary

Matrix | Group: Affine Matrix
Functions |
gdAffineApplyToPointF | Applies an affine transformation to a point (floating point gdPointF)
gdAffineInvert | Find the inverse of an affine transformation.
gdAffineFlip | Flip an affine transformation horizontally or vertically.
gdAffineConcat | Concat (Multiply) two affine transformation matrices.
gdAffineIdentity | Set up the identity matrix.
gdAffineScale | Set up a scaling matrix.
gdAffineRotate | Set up a rotation affine transform.
gdAffineShearHorizontal | Set up a horizontal shearing matrix || becomes \\.
gdAffineShearVertical | Set up a vertical shearing matrix, columns are untouched.
gdAffineTranslate | Set up a translation matrix.
gdAffineRectilinear | Determines whether the affine transformation is axis aligned.
gdAffineEqual | Determines whether two affine transformations are equal.

### Functions

### gdAffineApplyToPointF

> int gdAffineApplyToPointF ( |  | gdPointFPtr | dst,
> | const | gdPointFPtr | src,
> | const | double | affine[6] | )

Applies an affine transformation to a point (floating point gdPointF)

#### Parameters

dst | Where to store the resulting point
affine | Source Point
flip_horz | affine matrix

#### Returns

GD_TRUE if the affine is rectilinear or GD_FALSE

### gdAffineInvert

> int gdAffineInvert ( |  | double | dst[6],
> | const | double | src[6] | )

Find the inverse of an affine transformation.

All non-degenerate affine transforms are invertible. Applying the inverted matrix will restore the original values. Multiplying <src> by <dst> (commutative) will return the identity affine (rounding error possible).

#### Parameters

dst | Where to store the resulting affine transform
src_affine | Original affine matrix
flip_horz | Whether or not to flip horizontally
flip_vert | Whether or not to flip vertically

#### See also

gdAffineIdentity

#### Returns

GD_TRUE on success or GD_FALSE on failure

### gdAffineFlip

> int gdAffineFlip ( |  | double | dst[6],
> | const | double | src[6],
> | const | int | flip_h,
> | const | int | flip_v | )

Flip an affine transformation horizontally or vertically.

Flips the affine transform, giving GD_FALSE for <flip_horz> and <flip_vert> will clone the affine matrix. GD_TRUE for both will copy a 180° rotation.

#### Parameters

dst | Where to store the resulting affine transform
src_affine | Original affine matrix
flip_h | Whether or not to flip horizontally
flip_v | Whether or not to flip vertically

#### Returns

GD_TRUE on success or GD_FALSE

### gdAffineConcat

> int gdAffineConcat ( |  | double | dst[6],
> | const | double | m1[6],
> | const | double | m2[6] | )

Concat (Multiply) two affine transformation matrices.

Concats two affine transforms together, i.e. the result will be the equivalent of doing first the transformation m1 and then m2. All parameters can be the same matrix (safe to call using the same array for all three arguments).

#### Parameters

dst | Where to store the resulting affine transform
m1 | First affine matrix
m2 | Second affine matrix

#### Returns

GD_TRUE on success or GD_FALSE

### gdAffineIdentity

> int gdAffineIdentity ( | double | dst[6] | )

Set up the identity matrix.

#### Parameters

dst | Where to store the resulting affine transform

#### Returns

GD_TRUE on success or GD_FALSE

### gdAffineScale

> int gdAffineScale ( |  | double | dst[6],
> | const | double | scale_x,
> | const | double | scale_y | )

Set up a scaling matrix.

#### Parameters

scale_x | X scale factor
scale_y | Y scale factor

#### Returns

GD_TRUE on success or GD_FALSE

### gdAffineRotate

> int gdAffineRotate ( |  | double | dst[6],
> | const | double | angle | )

Set up a rotation affine transform.

Like the other angle in libGD, in which increasing y moves downward, this is a counterclockwise rotation.

#### Parameters

dst | Where to store the resulting affine transform
angle | Rotation angle in degrees

#### Returns

GD_TRUE on success or GD_FALSE

### gdAffineShearHorizontal

> int gdAffineShearHorizontal( |  | double | dst[6],
> | const | double | angle | )

Set up a horizontal shearing matrix || becomes \\.

#### Parameters

dst | Where to store the resulting affine transform
angle | Shear angle in degrees

#### Returns

GD_TRUE on success or GD_FALSE

### gdAffineShearVertical

> int gdAffineShearVertical( |  | double | dst[6],
> | const | double | angle | )

Set up a vertical shearing matrix, columns are untouched.

#### Parameters

dst | Where to store the resulting affine transform
angle | Shear angle in degrees

#### Returns

GD_TRUE on success or GD_FALSE

### gdAffineTranslate

> int gdAffineTranslate ( |  | double | dst[6],
> | const | double | offset_x,
> | const | double | offset_y | )

Set up a translation matrix.

#### Parameters

dst | Where to store the resulting affine transform
offset_x | Horizontal translation amount
offset_y | Vertical translation amount

#### Returns

GD_TRUE on success or GD_FALSE

### gdAffineRectilinear

> int gdAffineRectilinear ( | const | double | m[6] | )

Determines whether the affine transformation is axis aligned. A tolerance has been implemented using GD_EPSILON.

#### Parameters

m | The affine transformation

#### Returns

GD_TRUE if the affine is rectilinear or GD_FALSE

### gdAffineEqual

> int gdAffineEqual ( | const | double | m1[6],
> | const | double | m2[6] | )

Determines whether two affine transformations are equal. A tolerance has been implemented using GD_EPSILON.

#### Parameters

m1 | The first affine transformation
m2 | The first affine transformation

#### Returns

GD_TRUE on success or GD_FALSE

> int gdAffineApplyToPointF ( |  | gdPointFPtr | dst,
> | const | gdPointFPtr | src,
> | const | double | affine[6] | )

Applies an affine transformation to a point (floating point gdPointF)

> int gdAffineInvert ( |  | double | dst[6],
> | const | double | src[6] | )

Find the inverse of an affine transformation.

> int gdAffineFlip ( |  | double | dst[6],
> | const | double | src[6],
> | const | int | flip_h,
> | const | int | flip_v | )

Flip an affine transformation horizontally or vertically.

> int gdAffineConcat ( |  | double | dst[6],
> | const | double | m1[6],
> | const | double | m2[6] | )

Concat (Multiply) two affine transformation matrices.

> int gdAffineIdentity ( | double | dst[6] | )

Set up the identity matrix.

> int gdAffineScale ( |  | double | dst[6],
> | const | double | scale_x,
> | const | double | scale_y | )

Set up a scaling matrix.

> int gdAffineRotate ( |  | double | dst[6],
> | const | double | angle | )

Set up a rotation affine transform.

> int gdAffineShearHorizontal( |  | double | dst[6],
> | const | double | angle | )

Set up a horizontal shearing matrix || becomes \\.

> int gdAffineShearVertical( |  | double | dst[6],
> | const | double | angle | )

Set up a vertical shearing matrix, columns are untouched.

> int gdAffineTranslate ( |  | double | dst[6],
> | const | double | offset_x,
> | const | double | offset_y | )

Set up a translation matrix.

> int gdAffineRectilinear ( | const | double | m[6] | )

Determines whether the affine transformation is axis aligned.

> int gdAffineEqual ( | const | double | m1[6],
> | const | double | m2[6] | )

Determines whether two affine transformations are equal.
Close