Chapter 3 Two Dimensional Transformation
Chapter 3 Two Dimensional 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
• 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:
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)
• 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
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