2D Geometric
Transformations
Topic – I : Basic Transformation
Basic Transformation
• We can reposition and resize two-dimensional
objects by applying :
– Translation
– Rotation
– Scaling
Translation
• A translation is applied to an object by
repositioning it along a straight-line path from
one coordinate location to another.
• To translate a two-dimensional point by adding
translation distances, tx and ty, to the original
coordinate position (x, y) to move the point to a
new position (x', y').
x' = x + tx, y' = y + ty
• pair (tx, ty) is translation vector or shift vector.
X
Y
P
P'
T
Translation (cont.)
• We can express the translation
equations as a single matrix
equation by using column vectors
to represent coordinate positions
and the translation vector :
• Also: P' = P + T



















y
x
t
t
y'
x'
',
y
x
TPP
Rotation
• A two-dimension rotation is applied to
an object by repositioning it along a
circular path in the xy plane.
• To generate a rotation, we specify a
rotation angle θ and the position (xr, yr)
of the rotation point (or pivot point)
about which the object is to be rotated.
• Positive values for the rotation angle
define counterclockwise rotations about
the pivot point.
• Negative values rotate objects in the
clock direction.
Rotation (cont.)
• The original coordinates of the point in polar
coordinates are :
x = r cos φ, y = r sin φ
• We can express the transformed coordinates in terms
of angles θ and φ as:
x' = r cos (φ + θ) = r cos φ cos θ - r sin φ sin θ
y' = r cos (φ + θ) = r cos φ sin θ + r sin φ cos θ
• Then
x' = x cos θ - y sin θ; y' = x sin θ + y cos θ
(OR)
P' = R * P, where 




 

θθ
θθ
cossin
sincos
R
Scaling
• A scaling transformation alters the size of an
objects.
• This operation can be carried out for polygons
by multiplying the coordinate values (x, y) of
each vertex by scaling factors sx and sy to
produce the transformed coordinates (x', y'):
x' = x * sx, y' = y * sy
• Scaling factor sx scales objects in the x direction,
and sy in the y direction.
Scaling (cont.)
• Any positive numeric values can
assigned to the scaling factor sx and sy.
• Values <1, reduce the size of object.
• Values >1, enlarge the size of object.
• Both values =1, unchanged size.
• When sx and sy are assigned the same
value, it is uniform scaling.
• Unequal values for sx and sy is,
differential scaling.
2D Geometric
Transformations
Topic – II :
Matrix Representation &
Homogeneous Coordinates
Matrix Representation &
Homogeneous Coordinates
• The basic transformations can be expressed in the
general matrix form:
– With coordinate positions P and P' represented as column
vector.
– M1 is a 2x2 array matrix containing multiplicative factor,
– M2 is two-element column matrix containing translational
terms.
– For translation, M1 is the identity matrix.
– For rotation or scaling, M2 contains the translational terms
associated with the pivot point or scaling fixed point.
21' MPMP 
Cont.
• It produce a sequence of transformations with
equation, such as scaling followed by rotation then
translation.
• A more efficient approach would be to combine the
transformations so that the final coordinate position are
obtained directly from the initial coordinates. It
eliminates intermediate coordinates.
• We can combine the multiplicate and translational
terms for 2D geometric transformations into a single
matrix representation by expanding 2x2 matrix to 3x3.
Cont.
• To express any 2D transformation as a matrix
multiplication, we represent each Cartesian coordinate
position (x, y) with the homogeneous coordinate triple
(xh, yh, h).
• Can also be written as (h.x, h.y, h).
– h to be any nonzero value.
– There is infinite number of equivalent homogeneous
representations for each coordinate point (x, y).
– A convenient choice is simply to set h=1. then,
homogeneous coordinates (x, y, 1).
h
y
y,
h
x
x
hh

Cont.
• Expressing positions in homogeneous
coordinates allow us to represent all geometric
transformation equations as matrix
multiplications.
• Coordinates are represented with three-element
column vector, and transformation operations
are written as 3x3 matrices.
For Translation
• The inverse of the translation matrix is obtained
by replacing the translation parameters tx and ty
with –tx and –ty.
PttTP
OR
y
x
t
t
y
x
yx
y
x

































),('
)(
1100
10
01
1
1
1

For Rotation
• The inverse of the rotation matrix θ is replaced
by – θ.
PRP
OR
y
x
y
x





















 











)('
)(
1100
0cossin
0sincos
1
1
1




For Scaling
• The inverse scaling matrix is replacing sx and sy by
1/sx and 1/sy.
PssSP
OR
y
x
s
s
y
x
yx
y
x

































),('
)(
1100
00
00
1
1
1

Computer graphics basic transformation

Computer graphics basic transformation

  • 1.
  • 2.
    Basic Transformation • Wecan reposition and resize two-dimensional objects by applying : – Translation – Rotation – Scaling
  • 3.
    Translation • A translationis applied to an object by repositioning it along a straight-line path from one coordinate location to another. • To translate a two-dimensional point by adding translation distances, tx and ty, to the original coordinate position (x, y) to move the point to a new position (x', y'). x' = x + tx, y' = y + ty • pair (tx, ty) is translation vector or shift vector.
  • 4.
    X Y P P' T Translation (cont.) • Wecan express the translation equations as a single matrix equation by using column vectors to represent coordinate positions and the translation vector : • Also: P' = P + T                    y x t t y' x' ', y x TPP
  • 5.
    Rotation • A two-dimensionrotation is applied to an object by repositioning it along a circular path in the xy plane. • To generate a rotation, we specify a rotation angle θ and the position (xr, yr) of the rotation point (or pivot point) about which the object is to be rotated. • Positive values for the rotation angle define counterclockwise rotations about the pivot point. • Negative values rotate objects in the clock direction.
  • 6.
    Rotation (cont.) • Theoriginal coordinates of the point in polar coordinates are : x = r cos φ, y = r sin φ • We can express the transformed coordinates in terms of angles θ and φ as: x' = r cos (φ + θ) = r cos φ cos θ - r sin φ sin θ y' = r cos (φ + θ) = r cos φ sin θ + r sin φ cos θ • Then x' = x cos θ - y sin θ; y' = x sin θ + y cos θ (OR) P' = R * P, where         θθ θθ cossin sincos R
  • 7.
    Scaling • A scalingtransformation alters the size of an objects. • This operation can be carried out for polygons by multiplying the coordinate values (x, y) of each vertex by scaling factors sx and sy to produce the transformed coordinates (x', y'): x' = x * sx, y' = y * sy • Scaling factor sx scales objects in the x direction, and sy in the y direction.
  • 8.
    Scaling (cont.) • Anypositive numeric values can assigned to the scaling factor sx and sy. • Values <1, reduce the size of object. • Values >1, enlarge the size of object. • Both values =1, unchanged size. • When sx and sy are assigned the same value, it is uniform scaling. • Unequal values for sx and sy is, differential scaling.
  • 9.
    2D Geometric Transformations Topic –II : Matrix Representation & Homogeneous Coordinates
  • 10.
    Matrix Representation & HomogeneousCoordinates • The basic transformations can be expressed in the general matrix form: – With coordinate positions P and P' represented as column vector. – M1 is a 2x2 array matrix containing multiplicative factor, – M2 is two-element column matrix containing translational terms. – For translation, M1 is the identity matrix. – For rotation or scaling, M2 contains the translational terms associated with the pivot point or scaling fixed point. 21' MPMP 
  • 11.
    Cont. • It producea sequence of transformations with equation, such as scaling followed by rotation then translation. • A more efficient approach would be to combine the transformations so that the final coordinate position are obtained directly from the initial coordinates. It eliminates intermediate coordinates. • We can combine the multiplicate and translational terms for 2D geometric transformations into a single matrix representation by expanding 2x2 matrix to 3x3.
  • 12.
    Cont. • To expressany 2D transformation as a matrix multiplication, we represent each Cartesian coordinate position (x, y) with the homogeneous coordinate triple (xh, yh, h). • Can also be written as (h.x, h.y, h). – h to be any nonzero value. – There is infinite number of equivalent homogeneous representations for each coordinate point (x, y). – A convenient choice is simply to set h=1. then, homogeneous coordinates (x, y, 1). h y y, h x x hh 
  • 13.
    Cont. • Expressing positionsin homogeneous coordinates allow us to represent all geometric transformation equations as matrix multiplications. • Coordinates are represented with three-element column vector, and transformation operations are written as 3x3 matrices.
  • 14.
    For Translation • Theinverse of the translation matrix is obtained by replacing the translation parameters tx and ty with –tx and –ty. PttTP OR y x t t y x yx y x                                  ),(' )( 1100 10 01 1 1 1 
  • 15.
    For Rotation • Theinverse of the rotation matrix θ is replaced by – θ. PRP OR y x y x                                   )(' )( 1100 0cossin 0sincos 1 1 1    
  • 16.
    For Scaling • Theinverse scaling matrix is replacing sx and sy by 1/sx and 1/sy. PssSP OR y x s s y x yx y x                                  ),(' )( 1100 00 00 1 1 1 