Cga Unit 2
Cga Unit 2
Chennai
UNIT - II
2D TRANSFORMATIONS
Prepared by
Mr. S.Prabu
Mrs.G.Bhargavi
Assistant Professor(CTech)
SRMIST-KTR
UNIT-2
TOPICS
Other Transformations:
4. Reflection
5. Shearing
UNIT-2
2D TRANSFORMATION
• Translation
T(tx, ty) : Translation distances
• Scale
S(Sx,Sy) : Scale factors
• Rotation
R( Ø) : Rotation angle
Here 𝑷 ′ and 𝑷 are column vector of final and initial point coordinate
respectively.
This concept can be extended for any number of successive
translations.
UNIT-2
COMPOSITE ROTATION
Two successive Rotations are performed as
UNIT-2
COMPOSITE ROTATION
Here 𝑷 ′ and 𝑷 are column vector of final and initial point coordinate
respectively.
This concept can be extended for any number of successive rotations
UNIT-2
COMPOSITE SCALING
Two successive Scalings are performed as
UNIT-2
COMPOSITE SCALING
Here 𝑷 ′ and 𝑷 are column vector of final and initial point coordinate
respectively.
This concept can be extended for any number of successive scaling
UNIT-2
OTHER TRANSFORMATION
1. Reflection
2. Shear
UNIT-2
REFLECTION
A reflection is a transformation that produces a mirror image of
an object.
The mirror image for a two –dimensional reflection is generated
relative to an axis of reflection by rotating the object 180o about
the reflection axis.
Reflection gives image based on position of axis of reflection.
Transformation matrix for few positions are discussed here
UNIT-2
REFLECTION About an X axis
For reflection about the line
𝒚 = 𝟎 , 𝒕𝒉𝒆 𝒙 𝒂𝒙𝒊𝒔
Transformation matrix:
This transformation keeps 𝑥 values are same, but flips (Change the
sign) 𝑦 values of coordinate positions.
UNIT-2
REFLECTION About an Y axis
For reflection about the line
x = 𝟎 , 𝒕𝒉𝒆 y 𝒂𝒙𝒊𝒔
Transformation matrix:
This transformation keeps 𝑦 values are same, but flips (Change the
sign) 𝑥 values of coordinate positions.
UNIT-2
REFLECTION About Origin
Steps:
Get the minimum and maximum coordinates of both viewing pane.
Get the coordinates for a point.
Check whether given input lies between minimum and maximum
coordinate of viewing pane.
If yes display the point which lies inside the region otherwise
discard it.
UNIT-2
POINT CLIPPING
"To determine whether a point lies inside or outside a specific region or boundary”
Conditions to be checked
x ≤ xmax
x ≥ xmin
y ≤ ymax
y ≥ ymin
UNIT-2
LINE CLIPPING
Definition:
"The process of removing (clipping) lines or portions of lines outside
an area of interest (a viewport)"
Steps:
Check the line completely inside the clipping window.
If no, Check the line completely outside the clipping window.
if both are no, perform intersection calculations with one or more
clipping boundaries.
UNIT-2
LINE CLIPPING
UNIT-2
COHEN SOUTHERLAND LINE CLIPPING
• It divides a two-dimensional space into 9 regions and then
efficiently determines the lines and portions of lines that are inside
the given rectangular area.
Steps:
Check the line completely inside the clipping window.
If no, Check the line completely outside the clipping window.
if both are no, perform intersection calculations with one or more
clipping boundaries.
UNIT-2
COHEN SOUTHERLAND LINE CLIPPING
UNIT-2
COHEN SOUTHERLAND LINE CLIPPING
Region Code
• Every line endpoint in a picture is assigned a four digit binary
code called a region code.
• The central part is the viewing region or window, all the lines which
lie within this region are completely visible.
1 0 0 1
Bit 1 : Left
Bit 2 : Right
Bit 3 : Bottom
Bit 4 : Top
UNIT-2
COHEN SOUTHERLAND LINE CLIPPING
tpk <= qk
UNIT-2
LIANG-BARSKY LINE CLIPPING
• Where, parameter p & q are defined as :
p1 = -∆x q1 = x1 – xwmin
p2 = ∆x q2 = xwmax – x1
p3 = -∆y q3 = y1 – ywmin
p4 = ∆y q4 = ywmax – y1
UNIT-2
LIANG-BARSKY LINE CLIPPING
• Following observations can be:
• pk = 0 ; Line is parallel to the window.
• qk < 0 ; Line is completely outside the window.
• pk < 0 ; Line is proceeds from outside to inside the window.
• pk > 0 ; Line is proceeds from inside to outside the window.
• Regions are name in such a way that name in which region p2 falls
is gives the window edge which intersects the line.
• At the first step, lines can be clipped against the bounding rectangle.
• If the square of this distance for both endpoints of a line is less than
or equal to the radius squared, we can save the entire line.