SlideShare a Scribd company logo
1 of 72
Transformations contd.
Reflections
Initial
Object
Reflection about x
y =  y
x
y
Reflection about
origin
x =  x
y =  y
Reflection about y
x =  x
Reflection about x
Matrix Representations
Reflection about y
Reflection about
the Origin 

































































y
x
y
x
y
x
y
x
y
x
y
x
1
0
0
1
1
0
0
1
1
0
0
1
Reflections











1
0
0
0
1
0
0
0
1










1
0
0
0
1
0
0
0
1
Reflection about x axis:
Reflection about y axis:












1
0
0
0
1
0
0
0
1
Reflection about origin:
It is rotation matrix R(θ)
With θ = 180o
Reflection
• Reflection can be generalized to any reflection
point in xy-plane. This reflection is the same as a
180o rotation in the xy plane using the reflection
point as the pivot point.
• If we choose the reflection point as the diagonal
line x=y, the reflection matrix is










1
0
0
0
0
1
0
1
0
y
x
y=x
Reflection
• We can derive this matrix by concatenating a sequence of rotation and coordinate-
axis reflection matrices. One possible sequence is: a) clockwise rotation of 45o (b)
reflection about x-axis (c) counterclockwise rotation by 45o.
• To obtain a transformation matrix for reflection about the diagonal y = -x, we could
concatenate matrices for the transformation sequence: a) clockwise rotation of 45o (b)
reflection about y-axis (c) counterclockwise rotation by 45o. The resulting
transformation is:
• Reflections about any line y=mx + c in the xy plane can be accomplished with a
combination of translate-rotate-reflect transformations.












1
0
0
0
0
1
0
1
0
Shear
• A shearing affects an object in a particular direction (in 2D, it’s either in the x or in
the y direction)
• A shear transformation in the x-direction (along x) shifts the points in the x-
direction proportional to the y-coordinate.
•The y-coordinate of each point is unaffected.
y
y
y
h
x
x x





Shear along x
Matrix Representations
Shear along y
































































1
0
0
0
1
0
0
1
1
0
1
1
0
0
0
1
0
0
1
1
0
1
h
y
x
h
y
x
h
y
x
h
y
x
Shear along x (homogeneous coordinate)
Shear along y (homogeneous coordinate)
Shearing
• A shear in the x direction would be as follows:
x’ = x + h. y & y’ = y
h is shear parameter
• The quantity h specifies what fraction of the y-
coordinate should be added to the x-coordinate,
and may be positive or negative
• -ve values for h shifts coordinate positions to the
left
Shearing
Original points Transformed points
Shear by {g,h}
g =0, h=0.5
Original points Transformed points
Shear by {g,h}
g=0.5, h=0.5
• We generate x-direction shears relative to other reference lines with
• With coordinate positions transformed as
x’ = x + h(y- yref), y’ = y
• We generate y-direction shears relative to other reference lines (eg. x = xref) with
• With coordinate positions transformed as
x’ = x & y’ = h(x- xref) + y,









 
1
0
0
0
1
0
.
1 ref
y
h
h











1
0
0
.
1
0
0
1
ref
x
h
h
2D Viewing and Information
Visualization
2D Viewing Pipeline
Construct World Coordinate
Scene Using Model-
Coordinate Transformations
Convert World Coordinates to
Viewing Coordinates
Transform Viewing
Coordinates to Normalized
Coordinates
Map Normalized Coordinates
to Device Coordinates
Modeling coordinates
World coordinates
Viewing coordinates
Normalized coordinates
Device coordinates
From Computer Graphics by Hearn & Baker
Coordinate Systems
• Screen coordinates: the coordinate system used
to address the screen (device coordinates)
• World coordinates: a user defined application
specific coordinate system having its own units
of measure, axis, origin etc.
• Window: the rectangular region of the world
that is visible
• Viewport: the rectangular region of the screen
space that is used to display the window.
2D rendering pipeline
CLIPPING
max
min
max
min
y
y
y
x
x
x




For a point (x,y) to be inside the clip rectangle:
(xmin, ymin)
(xmax, ymax)
x = xmin x = xmax
y = ymin
y = ymax
clip
rectangle
Point Clipping
(xmin, ymin)
(xmax, ymax)
x = xmin x = xmax
y = ymin
y = ymax
(x1, y1)
clip
rectangle
max
min
max
min
y
y
y
x
x
x




For a point (x,y) to be inside the clip rectangle:
Point Clipping
clip
rectangle
Cases for clipping lines
Line Clipping
Cases for clipping lines
A
B
A
B
clip
rectangle
Line Clipping
Cases for clipping lines
D
A
B
C
D'
A
B
C
D'
clip
rectangle
Line Clipping
Cases for clipping lines
D
E
F
A
B
C
D'
A
B
C
D'
clip
rectangle
Line Clipping
Cases for clipping lines
D
E
F
A
B
C
D'
G
H
G'
H'
A
B
C
D'
G'
H'
clip
rectangle
Line Clipping
Cases for clipping lines
D
E
F
A
B
C
D'
G
H
G'
H'
I
J
I'
J'
A
B
C
D'
G'
H'
clip
rectangle
Line Clipping
Cohen-Sutherland Clipping
Basic Idea
– Encode the line endpoints
– Successively divide the line segments so
that they are completely contained in the
window or completely lies outside window
– Division occurs at the boundary of window
1000
0010
1010
0110
0100
0101
0001
1001
0000
left
right
bottom
top
Four Cases
– outcode1 = outcode2 = 0000 --> Accept all
– outcode1 OR outcode2 = 0000 --> Accept all
– outcode1 & outcode2 != 0000 --> Discard
– outcode1 != 0000 , outcode2 = 0000 (Vice versa)
--> Shorten
– outcode1 & outcode2 = 0000 --> Discard or Shorten
A
B
C
D
E
F
G
H
I
J
1. A line segment can be trivially accepted
if the outcodes of both the endpoints are
zero.
2. A line segment can be trivially rejected if
the logical AND of the outcodes of the
endpoints is not zero.
3. A key property of the outcode is that bits
that are set in nonzero outcode
correspond to edges crossed.
Cohen-Sutherland Algorithm
• The Cohen-Sutherland Line-Clipping Algorithm performs initial tests on a
line to determine whether intersection calculations can be avoided.
1. First, end-point pairs are checked for Trivial Acceptance.
2. If the line cannot be trivially accepted, region checks are done for
Trivial Rejection.
3. If the line segment can be neither trivially accepted or rejected, it is
divided into two segments at a clip edge, so that one segment can be
trivially rejected.
– These three steps are performed iteratively until what remains can be
trivially accepted or rejected.
Cohen-Sutherland Algorithm
clip
rectangle
A
B
C
D
E
An Example
Cohen-Sutherland Algorithm
An Example
clip
rectangle
B
C
D
E
Cohen-Sutherland Algorithm
An Example
clip
rectangle
B
C
D
Cohen-Sutherland Algorithm
An Example
clip
rectangle
B
C
Cohen-Sutherland Algorithm
For a line {(x1, y1), (x2, y2)}
The y coordinate of the intersection point
with the vertical boundary is
y=y1+m(x-x1)
Where x=xwmin or xwmax
m=(y2-y1)/(x2-x1)
Intersection with horizontal boundary
x= x1+(y-y1)/m
With y=ywmin or ywmax
(1) This is fundamentally different (from Cohen-
Sutherland algorithm) and generally more efficient
algorithm was originally published by Cyrus and
Beck.
(2) Liang and Barsky later independently developed a
more efficient algorithm that is especially fast in the
special cases of upright 2D and 3D clipping
regions.They also introduced more efficient trivial
rejection tests for general clip regions.
Parametric Line-Clipping
yo
Liang-Barsky Clipping
• The Liang-Barsky two-dimensional line
clipping algorithm uses the parametric
form of a line and the clipping window to
determine the clipping coordinates of lines
intersecting the clipping volume.
• This algorithm is significantly more
efficient than Cohen-Sutherland clipping.
Liang-Barsky Clipping
• To summarize, the Liang-Barsky clipping algorithm
consists of the following steps:
1. Define all line segments in parametric form.
2. Set the minimum and maximum values for u (umin = 0 and
umax = 1).
3. Calculate all the u values located between umin and umax.
4. Determine whether the arbitrary values of each parametric
line lie within the clipping window.
a. If the line intersects, shorten the line segment via a floating-point
division.
b. If the line doesn’t intersect the clipping window, discard it.
5. Display all clipped line segments.
Polygon clipping
Original
Polygon
Clip
Left
Clip
Right
Clip
Bottom
Clip
Top
P
S
S
P
I
S
P
P
S I
Save P
(a)
Save I
(b)
No Points
Saved
(c)
Save I, P
(d)
Sutherland-Hodgeman Polygon Clipping
1
2
3
4
5
6
1
2
3
4
5
Window
(a) (b)
Window
Before Clipping
After Clipping
Clipping Polygons
• Extending two-dimensional line clipping to
polygons involves the clipping of polygons
against a clipping rectangle or against other
polygons, as is the case with hidden surface
removal.
• Polygon clipping algorithms are derived from
simple line clipping algorithms.
• We can thus clip a polygon against the edges of
a clipping rectangle.
• There is, however, a problem with this approach
– clipping concave polygons can result in several
additional polygons as shown in Figure 12-19.
Clipping Polygons
Clipping Polygons
• The illustrated problem is not encountered when
working with convex polygons.
• The only solution to this problem is to consider
the clipped region as a single polygon or to
tessellate (divide) the polygon into a number of
convex polygons
Clipping Polygons
Sutherland-Hodgman Polygon Clipping
• Input each edge (vertex pair) successively.
• Output is a new list of vertices.
• Each edge goes through 4 clippers.
• The rule for each edge for each clipper is:
– If first input vertex is outside, and second is inside,
output the intersection and the second vertex
– If first both input vertices are inside, then just output
second vertex
– If first input vertex is inside, and second is outside,
output is the intersection
– If both vertices are outside, output is nothing
Sutherland-Hodgman Polygon Clipping:
Four possible scenarios at each clipper
outside inside
v1
v1’
v2
outside inside
v1
v2
outside inside
v1
v1’
v2
outside inside
v1
v2
Outside to inside:
Output: v1’ and v2
Inside to inside:
Output: v2
Inside to outside:
Output: v1’
Outside to outside:
Output: nothing
Sutherland-Hodgeman Algorithm:
Combination of the 4 Passes
Sutherland-Hodgeman Algorithm:
Example
Polygon Clipping
Input vertex P
First Point Yes
No
F=P
Does SP intersect
E?
No
Yes
Compute
Intersection Point
I
Output
vertex I
S=P
Is S on left
side of E?
Exit
NO
Yes
Output
vertex S
Close Polygon entry
Does SF
intersect E?
Compute
Intersection I
Yes
Output
vertex I
Exit
No
Text Clipping (1)
Text Clipping (2)
Text Clipping (3)
Week6.ppt

More Related Content

Similar to Week6.ppt (20)

Solving Quadratics
Solving QuadraticsSolving Quadratics
Solving Quadratics
 
Two dimensional geometric transformation
Two dimensional geometric transformationTwo dimensional geometric transformation
Two dimensional geometric transformation
 
UNIT2.pptx
UNIT2.pptxUNIT2.pptx
UNIT2.pptx
 
07 cie552 image_mosaicing
07 cie552 image_mosaicing07 cie552 image_mosaicing
07 cie552 image_mosaicing
 
Ch 7 c volumes
Ch 7 c  volumesCh 7 c  volumes
Ch 7 c volumes
 
Modeling Transformations
Modeling TransformationsModeling Transformations
Modeling Transformations
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
IMPROPER INTEGRALS AND APPLICATION OF INTEGRATION
IMPROPER  INTEGRALS AND  APPLICATION  OF INTEGRATIONIMPROPER  INTEGRALS AND  APPLICATION  OF INTEGRATION
IMPROPER INTEGRALS AND APPLICATION OF INTEGRATION
 
Calculas IMPROPER INTEGRALS AND APPLICATION OF INTEGRATION ppt
Calculas IMPROPER  INTEGRALS AND  APPLICATION  OF INTEGRATION pptCalculas IMPROPER  INTEGRALS AND  APPLICATION  OF INTEGRATION ppt
Calculas IMPROPER INTEGRALS AND APPLICATION OF INTEGRATION ppt
 
2d transformations
2d transformations2d transformations
2d transformations
 
AppsDiff3c.pdf
AppsDiff3c.pdfAppsDiff3c.pdf
AppsDiff3c.pdf
 
ppt on application of integrals
ppt on application of integralsppt on application of integrals
ppt on application of integrals
 
Cs8092 computer graphics and multimedia unit 3
Cs8092 computer graphics and multimedia unit 3Cs8092 computer graphics and multimedia unit 3
Cs8092 computer graphics and multimedia unit 3
 
A Tutorial on Computational Geometry
A Tutorial on Computational GeometryA Tutorial on Computational Geometry
A Tutorial on Computational Geometry
 
2 d transformation
2 d transformation2 d transformation
2 d transformation
 
ME Reference.pdf
ME Reference.pdfME Reference.pdf
ME Reference.pdf
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fill
 
Chapter 4 Integration
Chapter 4  IntegrationChapter 4  Integration
Chapter 4 Integration
 
curve one
curve onecurve one
curve one
 
Transforms UNIt 2
Transforms UNIt 2 Transforms UNIt 2
Transforms UNIt 2
 

Recently uploaded

Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 

Recently uploaded (20)

Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 

Week6.ppt

  • 2. Reflections Initial Object Reflection about x y =  y x y Reflection about origin x =  x y =  y Reflection about y x =  x
  • 3. Reflection about x Matrix Representations Reflection about y Reflection about the Origin                                                                   y x y x y x y x y x y x 1 0 0 1 1 0 0 1 1 0 0 1
  • 4. Reflections            1 0 0 0 1 0 0 0 1           1 0 0 0 1 0 0 0 1 Reflection about x axis: Reflection about y axis:             1 0 0 0 1 0 0 0 1 Reflection about origin: It is rotation matrix R(θ) With θ = 180o
  • 5. Reflection • Reflection can be generalized to any reflection point in xy-plane. This reflection is the same as a 180o rotation in the xy plane using the reflection point as the pivot point. • If we choose the reflection point as the diagonal line x=y, the reflection matrix is           1 0 0 0 0 1 0 1 0 y x y=x
  • 6. Reflection • We can derive this matrix by concatenating a sequence of rotation and coordinate- axis reflection matrices. One possible sequence is: a) clockwise rotation of 45o (b) reflection about x-axis (c) counterclockwise rotation by 45o. • To obtain a transformation matrix for reflection about the diagonal y = -x, we could concatenate matrices for the transformation sequence: a) clockwise rotation of 45o (b) reflection about y-axis (c) counterclockwise rotation by 45o. The resulting transformation is: • Reflections about any line y=mx + c in the xy plane can be accomplished with a combination of translate-rotate-reflect transformations.             1 0 0 0 0 1 0 1 0
  • 7. Shear • A shearing affects an object in a particular direction (in 2D, it’s either in the x or in the y direction) • A shear transformation in the x-direction (along x) shifts the points in the x- direction proportional to the y-coordinate. •The y-coordinate of each point is unaffected. y y y h x x x     
  • 8. Shear along x Matrix Representations Shear along y                                                                 1 0 0 0 1 0 0 1 1 0 1 1 0 0 0 1 0 0 1 1 0 1 h y x h y x h y x h y x Shear along x (homogeneous coordinate) Shear along y (homogeneous coordinate)
  • 9. Shearing • A shear in the x direction would be as follows: x’ = x + h. y & y’ = y h is shear parameter • The quantity h specifies what fraction of the y- coordinate should be added to the x-coordinate, and may be positive or negative • -ve values for h shifts coordinate positions to the left
  • 10. Shearing Original points Transformed points Shear by {g,h} g =0, h=0.5 Original points Transformed points Shear by {g,h} g=0.5, h=0.5
  • 11. • We generate x-direction shears relative to other reference lines with • With coordinate positions transformed as x’ = x + h(y- yref), y’ = y • We generate y-direction shears relative to other reference lines (eg. x = xref) with • With coordinate positions transformed as x’ = x & y’ = h(x- xref) + y,            1 0 0 0 1 0 . 1 ref y h h            1 0 0 . 1 0 0 1 ref x h h
  • 12. 2D Viewing and Information Visualization
  • 13. 2D Viewing Pipeline Construct World Coordinate Scene Using Model- Coordinate Transformations Convert World Coordinates to Viewing Coordinates Transform Viewing Coordinates to Normalized Coordinates Map Normalized Coordinates to Device Coordinates Modeling coordinates World coordinates Viewing coordinates Normalized coordinates Device coordinates From Computer Graphics by Hearn & Baker
  • 14.
  • 15.
  • 16. Coordinate Systems • Screen coordinates: the coordinate system used to address the screen (device coordinates) • World coordinates: a user defined application specific coordinate system having its own units of measure, axis, origin etc. • Window: the rectangular region of the world that is visible • Viewport: the rectangular region of the screen space that is used to display the window.
  • 17.
  • 18.
  • 21.
  • 22. max min max min y y y x x x     For a point (x,y) to be inside the clip rectangle: (xmin, ymin) (xmax, ymax) x = xmin x = xmax y = ymin y = ymax clip rectangle Point Clipping
  • 23. (xmin, ymin) (xmax, ymax) x = xmin x = xmax y = ymin y = ymax (x1, y1) clip rectangle max min max min y y y x x x     For a point (x,y) to be inside the clip rectangle: Point Clipping
  • 24. clip rectangle Cases for clipping lines Line Clipping
  • 25. Cases for clipping lines A B A B clip rectangle Line Clipping
  • 26. Cases for clipping lines D A B C D' A B C D' clip rectangle Line Clipping
  • 27. Cases for clipping lines D E F A B C D' A B C D' clip rectangle Line Clipping
  • 28. Cases for clipping lines D E F A B C D' G H G' H' A B C D' G' H' clip rectangle Line Clipping
  • 29. Cases for clipping lines D E F A B C D' G H G' H' I J I' J' A B C D' G' H' clip rectangle Line Clipping
  • 30. Cohen-Sutherland Clipping Basic Idea – Encode the line endpoints – Successively divide the line segments so that they are completely contained in the window or completely lies outside window – Division occurs at the boundary of window 1000 0010 1010 0110 0100 0101 0001 1001 0000 left right bottom top
  • 31. Four Cases – outcode1 = outcode2 = 0000 --> Accept all – outcode1 OR outcode2 = 0000 --> Accept all – outcode1 & outcode2 != 0000 --> Discard – outcode1 != 0000 , outcode2 = 0000 (Vice versa) --> Shorten – outcode1 & outcode2 = 0000 --> Discard or Shorten A B C D E F G H I J
  • 32. 1. A line segment can be trivially accepted if the outcodes of both the endpoints are zero. 2. A line segment can be trivially rejected if the logical AND of the outcodes of the endpoints is not zero. 3. A key property of the outcode is that bits that are set in nonzero outcode correspond to edges crossed. Cohen-Sutherland Algorithm
  • 33. • The Cohen-Sutherland Line-Clipping Algorithm performs initial tests on a line to determine whether intersection calculations can be avoided. 1. First, end-point pairs are checked for Trivial Acceptance. 2. If the line cannot be trivially accepted, region checks are done for Trivial Rejection. 3. If the line segment can be neither trivially accepted or rejected, it is divided into two segments at a clip edge, so that one segment can be trivially rejected. – These three steps are performed iteratively until what remains can be trivially accepted or rejected. Cohen-Sutherland Algorithm
  • 38. For a line {(x1, y1), (x2, y2)} The y coordinate of the intersection point with the vertical boundary is y=y1+m(x-x1) Where x=xwmin or xwmax m=(y2-y1)/(x2-x1) Intersection with horizontal boundary x= x1+(y-y1)/m With y=ywmin or ywmax
  • 39. (1) This is fundamentally different (from Cohen- Sutherland algorithm) and generally more efficient algorithm was originally published by Cyrus and Beck. (2) Liang and Barsky later independently developed a more efficient algorithm that is especially fast in the special cases of upright 2D and 3D clipping regions.They also introduced more efficient trivial rejection tests for general clip regions. Parametric Line-Clipping
  • 40. yo
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50. Liang-Barsky Clipping • The Liang-Barsky two-dimensional line clipping algorithm uses the parametric form of a line and the clipping window to determine the clipping coordinates of lines intersecting the clipping volume. • This algorithm is significantly more efficient than Cohen-Sutherland clipping.
  • 51. Liang-Barsky Clipping • To summarize, the Liang-Barsky clipping algorithm consists of the following steps: 1. Define all line segments in parametric form. 2. Set the minimum and maximum values for u (umin = 0 and umax = 1). 3. Calculate all the u values located between umin and umax. 4. Determine whether the arbitrary values of each parametric line lie within the clipping window. a. If the line intersects, shorten the line segment via a floating-point division. b. If the line doesn’t intersect the clipping window, discard it. 5. Display all clipped line segments.
  • 57. Clipping Polygons • Extending two-dimensional line clipping to polygons involves the clipping of polygons against a clipping rectangle or against other polygons, as is the case with hidden surface removal. • Polygon clipping algorithms are derived from simple line clipping algorithms. • We can thus clip a polygon against the edges of a clipping rectangle. • There is, however, a problem with this approach – clipping concave polygons can result in several additional polygons as shown in Figure 12-19.
  • 59. Clipping Polygons • The illustrated problem is not encountered when working with convex polygons. • The only solution to this problem is to consider the clipped region as a single polygon or to tessellate (divide) the polygon into a number of convex polygons
  • 61. Sutherland-Hodgman Polygon Clipping • Input each edge (vertex pair) successively. • Output is a new list of vertices. • Each edge goes through 4 clippers. • The rule for each edge for each clipper is: – If first input vertex is outside, and second is inside, output the intersection and the second vertex – If first both input vertices are inside, then just output second vertex – If first input vertex is inside, and second is outside, output is the intersection – If both vertices are outside, output is nothing
  • 62. Sutherland-Hodgman Polygon Clipping: Four possible scenarios at each clipper outside inside v1 v1’ v2 outside inside v1 v2 outside inside v1 v1’ v2 outside inside v1 v2 Outside to inside: Output: v1’ and v2 Inside to inside: Output: v2 Inside to outside: Output: v1’ Outside to outside: Output: nothing
  • 64.
  • 65.
  • 68. Input vertex P First Point Yes No F=P Does SP intersect E? No Yes Compute Intersection Point I Output vertex I S=P Is S on left side of E? Exit NO Yes Output vertex S Close Polygon entry Does SF intersect E? Compute Intersection I Yes Output vertex I Exit No