AFFINE is a geometric transformation operation involving MATRICES, covering both, 2D and 3D environment.
Transformations are often used in linear algebra and computer graphics.
In geometric transformations of images, the pixel coordinate is mapped.
This means that, each pixel is localized by two coordinates, in the rectangular domain of the image.
Without going into more details about pixel mapping, let's get to what really matters: the AFFINE transformations.
There are several classes of pixel mapping, one is called "affine".
Affine transformations include: scaling, rotation, shearing and translation.
PHP 5.5.0+, like "libart", uses ARRAYS of six floating-point elements to do the job.
The AFFINE ARRAY, is defined like,
$affine = [ a0, a1, b0, b1, a2, b2 ];
where,
a0, a1, b0, b1, a2, b2 are floating-point values.
represented by equations,
x' = a0x + a1y + a2
y' = b0x + b1y + b2
a ) IDENTITY, no change made in the path of points,
$affine = [ 1, 0, 0, 1, 0, 0 ];
equations remapping,
x' = 1x + 0y + 0 = x
y' = 0x + 1y = 0 = y
b ) TRANSLATION,
$affine = [ 1, 0, 0, 1, H, V ];
equations remapping,
x' = 1x + 0y + H = x + H
y' = 0x + 1y = V = y + V
Each point is moved H units horizontaly and V units verticaly.
c ) SCALE,
$affine = [ i, 0, j, 1, 0, 0 ];
equations remapping,
x' = Mx + 0y + 0 = Mx
y' = 0x + Ny = 0 = Ny
Each point will stretch or compress its path, horizontally or vertically, according M and N; negative or positive values.
d ) SHEARING, parallel to x axis,
$affine = [ 1, K, 0, 1, 0, 0 ];
equations remapping,
x' = 1x + Ky + 0 = x + Ky
y' = 0x + 1y = 0 = y
SHEARING, parallel to y axis,
$affine = [ K, 0, 0, 1, 0, 0 ];
equations remapping,
x' = 1x + 0y + 0 = x
y' = Kx + 1y = 0 = y + Kx
e ) ROTATION, clockwise,
$affine = [ cos Ø, sin Ø, -sin Ø, cos Ø, 0, 0 ];
equations remapping,
x' = x cos Ø + y sin Ø + 0 = x cos Ø + y sin Ø
y' = -x sin Ø + y cos Ø = 0 = y cos Ø - x sin Ø
ROTATION, conterclockwise,
$affine = [ cos Ø, -sin Ø, sin Ø, cos Ø, 0, 0 ];
equations remapping,
x' = x cos Ø - y sin Ø + 0 = x cos Ø - y sin Ø
y' = x sin Ø + y cos Ø = 0 = y sin Ø - x cos Ø