Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Module-2
2D TRANSFORMATIONS
Basic Transformations
Matrix representations, homogeneous coordinates
Composite Transformations
2D Transformations
Geometric Transformation
The geometrical change of an object from a current state to
modified state.
To manipulate the initially created object and to alter and display
the modified object without having to redraw it.
Eg : designing, animation
Two types
Object Transformation
Changes orientation, size and shape of object
Alter the coordinates descriptions an object
Translation, rotation, scaling, shear, reflection, etc.
Coordinate system unchanged
Coordinate transformation
Produce a different coordinate system
Matrix Representation
Column-vector representation for a point.
pre-multiplication of the transformation it appears
before the point to be transformed in the equation.
A B x Ax By
C
D y Cx Dy
Advantages of matrix
More convenient organization of data
More efficient processing
Enable the combination of various concatenations
2D Translation
A translation moves all points in an
object along the same straight-line
path from original position (x, y) to
new position (x, y)
The translation distance pair (tx , ty),
P ?
is called translation or shift vector.
Translation equations are:
x' = x + tx ty=4
P
y' = y + ty
(2, 2) tx = 6
or in matrix form:
P' = P + T
x x tx
y = y + t
y
2D Translation
A translation is a rigid body transformation that moves objects
without deformation. That is every point on the object is translated
by the same amount.
y = x sin + y cos
2D Rotation
Rotation equations:
x = x cos y sin
y= x sin + y cos
or in matrix form:
P(x, y)
P' = R P
x ' cos sin x
y ' sin cos y
y
Rotation matrix P(x,y)
cos
sin r y
R
sin
cos x
x
For a rotation matrix transpose
is got by simply changing sign
of sine terms
2D Rotation
y
Rotation in angle about a
x, y P Pr R P Pr
xr , yr x cos
R
sin
sin cos
2D Rotation
Example - Find the transformed point, P, caused by rotating
P= (5, 1) about the origin through an angle of 90.
cos
sin
x
x
cos
y
sin
sin
cos
y
x
sin
y
cos
5cos
901sin
90
5sin
901cos
90
5011
5110
1
5
2D Scaling
Scaling alters the size of an object
and involves two scale factors, sx
and sy for the x and y coordinates
P
respectively.
Scales are about the origin (0,0).
Scaling equations:
x' = sx x
y' = sy y P
or in matrix form:
P' = S P
Scale matrix as:
sx 0
S
0 sy
Scaling
If the scale factors are in between 0
and 1 the points will be moved
closer to the origin the object will
be smaller.
Example :
P(2, 5), Sx = 0.5, Sy = 0.5
P(2, 5)
Find P ?
P
Scaling
If the scale factors are in between 0
and 1 the points will be moved
P
closer to the origin the object will
be smaller.
Example :
P(2, 5), Sx = 0.5, Sy = 0.5
P(2, 5)
Find P ?
If the scale factors are larger than 1
the points will be moved away from P
Example :
P(2, 5), Sx = 2, Sy = 2
Find P ?
2D Scaling
Uniform scaling
- scale factors are the same, Sx = Sy
P
- only change in size (previous example)
Differential scaling.
- scale factors are different, Sx Sy
- change in size and shape
- Example : square rectangle
P(1, 3), Sx = 2, Sy = 5 , P ? P(1, 3)
Unit Scaling
- scale factors are both 1, Sx = Sy = 1
- size and shape unchanged
2D Scaling
y y s y y f 1 s y
x f , yf
P P S P f 1 - S
x
Note: the additive terms xf (1-Sx) and yf (1-Sy) are constants for
all points in the object
Combining Transformations
General transformation of a point:
P' = M1 P + M2
P' and P - column matrix (2 x 1) of new and original coordinates
M1 - 2 x 2 matrix for scaling and rotation
M2 - column matrix (2 x 1) for translation
For scaling or rotation, we set M2 as the additive identity.
For translation, we set M1 is the multiplicative identity.
To combine multiple transformations, we must explicitly compute
each transformed point. It is better to use the same matrix operation
all the time, so have to combine multiplication and addition into a
single matrix representation by expanding 2x2 to 3x3 matrices
Cartesian coordinate (x, y) replaced by homogeneous coordinate
triplet (xh ,yh, h) equal to (x.h, y.h, h) where x = xh/ h, y = yh / h
Homogeneous representation allows to represent all geometric
transformation equations as concatenated matrix multiplications
Homogeneous Coordinates
y y
w
x
x
Let point (x, y) in 2D be represented by point (x, y, 1) in the new
space. Scaling our new point by any value a puts us somewhere
along a particular line: (ax, ay, a).
A point in 2D can be represented in many ways in the new space.
(2, 4) (8, 16, 4) or (6, 12, 3) or (2, 4, 1) or etc.
We can always map back to the original 2D point by dividing by the
last coordinate (15, 6, 3) (5, 2)
Since all the points along each line can be mapped back to the same
point in 2D this coordinate system > homogeneous coordinates
Homogeneous Transform Advantages
x cos sin 0 x
y sin cos 0 y , P R P
2D
Rotation
1 0 0 1 1
x S x 0 0 x
y 0 S 0 y , P S S , S P
2D
Scaling y x y
1 0 0 1 1
19
Homogeneous Coordinates
Inverse transformations:
1 0 t x cos sin 0 1 S x 0 0
T1 0 1 t y , R 1 sin cos 0 , S 1 0 1 S y 0
0 0 1 0 0 1 0 0 1
Composite Transformations:
P M2 M1 P M2 M1 P M P
Composite Translation:
P T t2 x , t2 y T t1x , t1 y P T t2 x , t2 y T t1x , t1 y P
1 0 t2 x 1 0 t1x 1 0 t1x t2 x
0 1 t 0 1 t 0 1 t t
2y 1y 1y 2y
0 0 1 0 0 1 0 0 1
T t2 x , t2 y T t1x , t1 y T t1x t2 x , t1 y t2 y
20
Homogeneous Coordinates
Composite Rotation:
P R 2 R 1 P R 2 R 1 P
R 2 R 1 R 1 2
P R 1 2 P
Composite Scaling:
S2 x 0 0 S1x 0 0 S1x S2 x 0 0
0 S2 y 0 0 S1 y 0 0 S1 y S2 y 0
0 0 1 0 0 1 0 0 1
S S2 x , S2 y S S1x , S1 y S S1x S2 x , S1 y S2 y
April 2010 21
General Pivot Point 2D Rotation
0 0 1 0 0 1 0 0 1
3. Translate pivot point back
to original position cos sin xr 1 cos yr sin
sin cos yr 1 cos xr sin
0
22
0 1
General Fixed Point 2D Scaling
1 0 x f S x 0 0 1 0 x f S x 0 x f 1 S x
0 1 y 0 S 0 0 1 y 0 S y 1 S
f y f y f y
0 0 1 0 0 1 0 0 1 0 0
1
T(xf , yf ) . S (sx , sy . T(- xf , - yf ) = S ( xf , yf , sx , sy )
2D Scaling Steps
1. Translate object such that fixed point moves to origin
2. Scale object about origin
April 2010 23
3. Translate fixed point back to original position
2D Directional Scaling
x S2
R 1 S S1 , S2 R
x x
1 0 0 1 0 0 1 0 0
0 1 0 0 1 0 0 1 0
0 0 1 0 0 1 0 0 1
Reflection about line y = 0 Reflection about line x = 0 Reflection about origin
25
(x - axis) (y - axis) (xy - axis)
2D Reflections
yx y x
0 1 0 0 1 0
1 0 0 1 0 0
0 0 1 0 0 1
Reflection about line y = x Reflection about line y = - x
Clockwise Rotation by 450 Clockwise Rotation by 450
Reflection about X-axis Reflection about Y-axis
- Clockwise Rotation by 450
April 2010
Counter 450
Counter - Clockwise Rotation by 26
2D Shear
A shear is a transformation that distorts the shape of an object such
that the transformed shape appears as if the object was composed of
internal layers that had been caused to slide over each other.
Two common shearing transformations are those that shift coordinate
x values and those that shift coordinate y values y
Equations 1
x x shx ( y yref )
1 x
y y yref = -1
Matrix form y
y 0 1 0 y 1 2 3 x
1 0 0 1
1 yref = -1
shx = , yref =28-1
2D Shear
Y-direction shear relative to y-axis (x=0)
shifts the points in the y-direction proportional
to the x-coordinate. But x-coordinate of points y
are unaffected.
1
Eg. Square converted to a parallelogram
Equations 1 x
x x Initial object
y y shy x y
3
Matrix form 2
x 1 0 0 x 1
y shy 1 0 y 1 x
1 0 0 1 shy = 2
1 29
2D Shear
Y-direction shear relative to reference lines (x=xref )
Eg. Square converted to vertically shifted parallelogram
y
Equations
x x 1
y y shy ( x xref )
xref = -1 1 x
Matrix form
y
x 1 0 0 x 2
y shx 1 shy xref y
1
1 0 0 1
1 xref = -1 1 x
shy = , xref = -1 30
Transformations between 2D Coordinate Systems
y0
x0 x
M xy , xy R( ) T ( x0 , y0 )
32
Order of Transformations
y y
x x
Object first translated in the x Object first rotated 90 and then
direction and then rotated 90 translated in the x direction
33
Composite Transformation
We can represent any sequence of transformations
as a single matrix.
No special cases when transforming a point matrix vector.
Composite transformations matrix matrix.
Composite transformations:
Rotate about an arbitrary point translate, rotate, translate
Scale about an arbitrary point translate, scale, translate
Change coordinate systems translate, rotate, scale