0% found this document useful (0 votes)
76 views27 pages

Chapter 3 Two Dimensional Transformation

Uploaded by

Noel Girma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views27 pages

Chapter 3 Two Dimensional Transformation

Uploaded by

Noel Girma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Chapter 3 :

Two Dimensional Transformations


Transformation
Changing Position, shape, size, or orientation of an object on display is known as
transformation.
 
Basic Transformation
 Basic transformation includes three transformations Translation, Rotation, and
Scaling.
 These three transformations are known as basic transformation because with
combination of these three transformations we can obtain any transformation
Translation
 It is a transformation that used to reposition the object
along the straight line path from one coordinate location
to another.
 It is rigid body transformation (moves objects without
deformation) so we need to translate whole object.
 We translate two dimensional point by adding
translation distance 𝒕𝒙 and 𝒕𝒚 to the original coordinate
position (𝒙, 𝒚) to move at new position (𝒙', 𝒚′) as:
𝒙′ = 𝒙 + 𝒕𝒙 &
𝒚′ = 𝒚 + 𝒕𝒚
 Translation distance pair (𝒕𝒙,𝒕𝒚) is called a Translation
Vector or Shift Vector.
We can represent it into single matrix equation in column vector as;

𝑷′ = 𝑷 + 𝑻

We can also represent it in row vector form as:


𝑷′ = 𝑷 + 𝑻
Example: Translate the triangle [A (10, 10), B (15, 15), C (20, 10)] 2 unit in x
direction and 1 unit in y direction.
It is a transformation that used to alter the size of an object.
It expands or compresses the dimensions of an object.
This operation is carried out by multiplying coordinate value (𝒙, 𝒚) with scaling factor
(𝒔𝒙, 𝒔𝒚) respectively.

 So equation for scaling is given by:


𝒙′ = 𝒙 ∙ 𝒔𝒙
𝒚′ = 𝒚 ∙ 𝒔𝒚
 These equation can be represented in column vector
matrix equation as:
Any positive value can be assigned to(𝒔𝒙, 𝒔𝒚).
 Values less than 1 reduce the size while values greater than 1 enlarge the size of
object, and object remains unchanged when values of both factor is 1.
 Same values of 𝒔𝒙 and 𝒔𝒚 will produce Uniform Scaling. And different values of 𝒔𝒙 and
𝒔𝒚 will produce Differential Scaling
 Objects transformed with above equation are both scale and repositioned.
 Scaling factor with value less than 1 will move object closer to origin, while scaling factor
with value greater than 1 will move object away from origin.
 We can control the position of object after scaling by keeping one position fixed called Fix
point (𝒙𝒇, 𝒚𝒇) that point will remain unchanged after the scaling transformation.

Equation for scaling with fixed point position as (𝒙𝒇, 𝒚𝒇) is:
A polygon is scaled relative to the fixed point by scaling the distance from each
vertex to the fixed point:
𝒙′ = 𝒙𝒇 + (𝒙 − 𝒙𝒇)𝒔𝒙 𝒚′ = 𝒚𝒇 + (𝒚 − 𝒚𝒇)𝒔𝒚
𝒙′ = 𝒙𝒇 + 𝒙𝒔𝒙 − 𝒙𝒇𝒔𝒙 𝒚′ = 𝒚𝒇 + 𝒚𝒔𝒚 − 𝒚𝒇𝒔𝒚
𝒙′ = 𝒙𝒔𝒙 + 𝒙𝒇(𝟏 − 𝒔𝒙) 𝒚′ = 𝒚𝒔𝒚 + 𝒚𝒇(𝟏 − 𝒔𝒚)
Rotation
 It is a transformation that used to reposition the object
along the circular path in the XY - plane.
 To generate a rotation we specify a rotation
angle 𝜽 and the position of the Rotation Point
(Pivot Point) (𝒙𝒓,𝒚𝒓) about which the object is to be
rotated.
 Positive value of rotation angle defines counter
clockwise rotation and negative value of rotation
angle defines clockwise rotation.
 We first find the equation of rotation when pivot point
is at coordinate origin(𝟎, 𝟎).
From figure we can write.
𝒙 = 𝒓 𝐜𝐨𝐬 ∅
𝒚 = 𝒓 𝐬𝐢𝐧 ∅
and
𝒙′ = 𝒓 𝐜𝐨𝐬(𝜽 + ∅) = 𝒓 𝐜𝐨𝐬 ∅ 𝐜𝐨𝐬 𝜽 − 𝒓 𝐬𝐢𝐧 ∅ 𝐬𝐢𝐧 𝜽
𝒚′ = 𝒓 𝐬𝐢𝐧(∅ + 𝜽) = 𝒓 𝐜𝐨𝐬 ∅ 𝐬𝐢𝐧 𝜽 + 𝒓 𝐬𝐢𝐧 ∅ 𝐜𝐨𝐬 𝜽
 Now replace 𝒓 𝐜𝐨𝐬 ∅ with 𝒙 and 𝒓 𝐬𝐢𝐧 ∅ with 𝒚 in above
equation.
𝒙′ = 𝒙 𝐜𝐨𝐬 𝜽 − 𝒚 𝐬𝐢𝐧 𝜽
𝒚′ = 𝒙 𝐬𝐢𝐧 𝜽 + 𝒚 𝐜𝐨𝐬 𝜽
 We can write it in the form of column vector matrix equation
as;
𝑷′ = 𝑹 ∙ 𝑷
Transformation equation for rotation of a point
about pivot point (𝒙𝒓,𝒚𝒓) is:
𝒙′ = 𝒙𝒓 + (𝒙 − 𝒙𝒓) 𝐜𝐨𝐬 𝜽 − (𝒚 − 𝒚𝒓) 𝐬𝐢𝐧 𝜽
𝒚′ = 𝒚𝒓 + (𝒙 − 𝒙𝒓) 𝐬𝐢𝐧 𝜽 + (𝒚 − 𝒚𝒓) 𝐜𝐨𝐬 𝜽
Homogenous Coordinates
• Many graphics applications involve sequences of geometric transformations
• An animation, for example, might require an object to be translated and rotated
at each increment of the motion
• In design and picture construction applications, we perform translations,
rotations, and scalings to fit the picture components into their proper positions
• Here we consider how the matrix representations discussed in the previous
sections can be reformulated so that such transformation sequences can be
efficiently processed

• To express any two-dimensional transformation as a matrix


multiplication, we represent each Cartesian coordinate position (x, y)
with the homogeneous coordinate triple (xh, yh, h), where:
x= , y=

• For two-dimensional geometric transformations, we can choose the homogenous parameter h to be any nonzero
value
• Thus, there is an infinite number of equivalent homogeneous representations for each coordinate point (x, y)
• A convenient choice is simply to set h = 1
• Expressing positions in homogeneous coordinates allows us to represent all geometric transformation equations as
matrix multiplications
• Coordinates are represented with three-element column vectors, and transformation operations are written as 3 by 3
matrices
• For translation, we have:

• Which we can write in abbreviated form


P' = T(tx, ty) Pwith T(tx, ty) as the 3 by 3 translation matrix in equation
rotation transformation equations about the coordinate origin are now written as:

or as

P' = R(θ) P

• The rotation transformation operator R(θ) is the 3 by 3 matrix in equation with rotation parameter θ.
We get the inverse rotation matrix when θ is replaced with –θ
• a scaling transformation relative to the coordinate origin is now expressed as the matrix multiplication

or
P' = S(sx, sy) P (4.22)

where S(sx, sy) is the 3 by 3 matrix in equation with parameters


sx and sy

• Matrix representations are standard methods for implementing transformations in graphics systems
Composite Transformations
• With the matrix representations of the previous section, we can set up a matrix for any
sequence of transformations as a composite transformation matrix by calculating the
matrix product of the individual transformations
• Forming products of transformation matrices is often referred to as a concatenation,
or composition, of matrices
• For column-matrix representation of coordinate positions, we form composite
transformations by multiplying matrices in order from right to left
• That is, each successive transformation matrix premultiplies the product of the
preceding transformation matrices
Translations
• If two successive translation vectors (tx1, ty1) and (tx2, ty2) are applied to a
coordinate position P, the final transformed location P' is calculated as:
P' = [T(tx2, ty2) T(tx1, ty1) ]P
= [T(tx2, ty2) T(tx1, ty1)] P
where P and P' are represented as homogeneous-coordinate column vectors
• We can verify this result by calculating the matrix product for the two
associative groupings.

• Also, the composite transformation matrix for this sequence of translations is:
or
T(tx2, ty2) T(tx1, ty1) = T(tx1 + tx2, ty1 + ty2 )
= which demonstrates that two successive translation are
additive
• Since addition is commutative, two successive translations
are commutative.
Rotations
• Two successive rotations applied to point P produce the transformed position

P' = R(θ2) {R(θ1) P}


= {R(θ2) R(θ1)} P
• By multiplying the two rotation matrices, we can verify that two successive rotations are additive:
R(θ2) R(θ1) = R(θ2+ θ1)
• So that the final rotated coordinates can be calculated with the composite rotation matrix as
P' = R(θ2+ θ1) P
Other Transformations
• Reflection
• A reflection is a transformation that produces a mirror image of an
object
• Reflection is a kind of rotation where the angle of rotation is 180
degree.
• The reflected object is always formed on the other side of mirror.
• The size of reflected object is same as the size of original object.
• Reflection about the line y = 0, the x axis:

x’= x
y’=-y

• This transformation keeps x values the same, but "flips" the y values of coordinate positions

• A reflection about the y axis flips x coordinates while keeping y coordinates the same. The matrix for this
transformation is:

x’= -x
y’= y
• If we chose the reflection axis as the diagonal line y = x , the reflection matrix is

x’=y
Y’=x
• Reflections about any line y = mx + b in the xy plane can be accomplished with a
combination of translate- rotate-reflect transformation
• In general, we first translate the Line so that it passes through the origin.
T(0,-b)
• Then we can rotate the line onto one of the coordinate axes and reflect about that
axis.
R(-tan-1m)
Refl(x-axis)
• Finally, we restore the line to its original position with the inverse rotation and
translation transformations
R(tan-1m)
T(0,b)
Shearing:
Shearing deals with changing the shape and size of the 2D object along
x-axis and y-axis.
In a two dimensional plane, the object size can be changed along X
direction as well as Y direction.
x-Shear :
In x shear, the y co-ordinates remain the same but the x co-ordinates changes. If
P(x, y) is the point then the new points will be P’(x’, y’) given as –

x'=x+Shx * y
y'=y
The homogeneous matrix for shearing in the x-direction is
shown below:
y-Shear :
In y shear, the x co-ordinates remain the same but the y co-ordinates changes. If P(x, y) is
the point then the new points will be P’(x’, y’) given as –
x'=x; y'=y+Shy * x
The homogeneous matrix for shearing in the y-direction is shown below:
x-y Shear :
• In x-y shear, both the x and y co-ordinates changes. If P(x, y) is the point then the
new points will be P’(x’, y’) given as –

x'= x+Shx * y

y'=y+Shy * x

The homogeneous matrix for shearing in the x-y-direction is shown below:


Example :
Given a triangle with points (1, 1), (0, 0) and (1, 0).
Find out the new coordinates of the object along x-axis, y-axis, xy-axis.
(Applying shear parameter 4 on X-axis and 1 on Y-axis.).

You might also like