SlideShare a Scribd company logo
1 of 15
POLYGON CLIPPING WITH
SUTHERLAND HODGEMAN
ALGORITHM
AND
SCAN LINE FILL ALGORITHM
Clipping
 The primary use of clipping in computer graphics is to remove
objects, lines, or line segments that are outside the viewing pane .
Clip Window: The region against which an object is to be clipped.
 Point Clipping
 Line Clipping (straight-line segments)
 Area Clipping (polygons)
 Text Clipping
Polygon Clipping
 Clipping a polygon fill area needs more than line-clipping of the
polygon edges
-would produce and unconnected set of lines
 Must generate one or more closed polylines, which can be filled with
the assigned colour or pattern
Sutherland–Hodgeman algorithm
 Each edge of the polygon must be tested against each edge of the clip
rectangle; new edges must be added, and existing edges must be
discarded, retained, or divided. Multiple polygons may result from
clipping a single polygon. We need an organized way to deal with all
these cases
FOUR POSSIBLE SCENARIOS AT EACH CLIPPER
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
Steps of Sutherland-Hodgmans polygon
clipping algorithm
 Polygons can be clipped against each edge of the window one at a
time.
 Vertices which are kept after clipping against one window edge are
saved for clipping against the remaining edges .
 Note that the number of vertices usually changes and will often
increases.
SCAN LINE FILL ALGORITHM
Scan-Line
 A scan line is one line, or row, in a raster scanning
pattern, such as a line of video on a cathode ray
tube display of a television set or computer
monitor.
Scan-line Polygon Fill
For each scan-line :
 Locate the intersection of the scan-line with the edges (y=ys)
 Sort the intersection points from left to right.
 Draw the interiors intersection points pairwise. (a-b), (c-d)
Problem with corners. Same point counted twice or not?
 a,b,c and d are intersected by 2 line segments each.
 Count b,c twice but a and d once. Why?
Solution:
Make a clockwise or counter-clockwise traversal on edges.
Check if y is monotonically increasing or decreasing. If
direction changes, double intersection, otherwise single
intersection.
Scan Line Fill: What happens at edge
end-point?
 Edge endpoint is duplicated.
 In other words, when a scan line intersects an edge endpoint, it
intersects two edges.
 Two cases:
Case A: edges are monotonically increasing or decreasing
Case B: edges reverse direction at endpoint
 In Case A, we should consider this as only ONE edge
intersection
 In Case B, we should consider this as TWO edge intersections
Scan Line Fill Algorithm
Basic algorithm:
 Assume scan line start from the left and is outside the polygon.
 When intersect an edge of polygon, start to color each pixel (because
now we’re inside the polygon), when intersect another edge, stop
coloring …
 Odd number of edges: inside
 Even number of edges: outside
THANK YOU

More Related Content

What's hot

Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clippingMani Kanth
 
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmCohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmMaruf Abdullah (Rion)
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithmAparna Joshi
 
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygonsLiang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygonsLahiru Danushka
 
Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clippingArvind Kumar
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer GraphicsLaxman Puri
 
Polygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesPolygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesOmprakash Chauhan
 
Parallel projection
Parallel projectionParallel projection
Parallel projectionPrince Shahu
 
Reflection transformation
Reflection transformationReflection transformation
Reflection transformationMani Kanth
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmrajivagarwal23dei
 
Back face detection
Back face detectionBack face detection
Back face detectionPooja Dixit
 
Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...Mani Kanth
 
Unit 3
Unit 3Unit 3
Unit 3ypnrao
 
Cohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marksCohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marksRehan Khan
 
Segments in Graphics
Segments in GraphicsSegments in Graphics
Segments in GraphicsRajani Thite
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clippingAnkit Garg
 

What's hot (20)

Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
 
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmCohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygonsLiang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
Liang- Barsky Algorithm, Polygon clipping & pipeline clipping of polygons
 
Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clipping
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 
Polygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesPolygons - Computer Graphics - Notes
Polygons - Computer Graphics - Notes
 
Parallel projection
Parallel projectionParallel projection
Parallel projection
 
Reflection transformation
Reflection transformationReflection transformation
Reflection transformation
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithm
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Graphics a buffer
Graphics a bufferGraphics a buffer
Graphics a buffer
 
Back face detection
Back face detectionBack face detection
Back face detection
 
Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...
 
Weiler atherton
Weiler athertonWeiler atherton
Weiler atherton
 
Unit 3
Unit 3Unit 3
Unit 3
 
Cohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marksCohen and Sutherland Algorithm for 7-8 marks
Cohen and Sutherland Algorithm for 7-8 marks
 
Z buffer
Z bufferZ buffer
Z buffer
 
Segments in Graphics
Segments in GraphicsSegments in Graphics
Segments in Graphics
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 

Similar to Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm

Similar to Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm (20)

lecture8 clipping
lecture8 clippinglecture8 clipping
lecture8 clipping
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping & Rasterization
Clipping & RasterizationClipping & Rasterization
Clipping & Rasterization
 
7-Clipping-16 (1).pdf
7-Clipping-16 (1).pdf7-Clipping-16 (1).pdf
7-Clipping-16 (1).pdf
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clipping
 
Clipping
ClippingClipping
Clipping
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Lecture 2d point,curve,text,line clipping
Lecture   2d point,curve,text,line clippingLecture   2d point,curve,text,line clipping
Lecture 2d point,curve,text,line clipping
 
Clipping
ClippingClipping
Clipping
 
UNIT2.pptx
UNIT2.pptxUNIT2.pptx
UNIT2.pptx
 
Clipping
ClippingClipping
Clipping
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clipping
 
ibuib.pptx
ibuib.pptxibuib.pptx
ibuib.pptx
 
Clipping
ClippingClipping
Clipping
 
UNIT-III
UNIT-IIIUNIT-III
UNIT-III
 
Group 6 Presentation - Copy.pptx
Group 6 Presentation - Copy.pptxGroup 6 Presentation - Copy.pptx
Group 6 Presentation - Copy.pptx
 
Group 5 Presentation.pptx
Group 5 Presentation.pptxGroup 5 Presentation.pptx
Group 5 Presentation.pptx
 
Group 5 Presentation.pptx
Group 5 Presentation.pptxGroup 5 Presentation.pptx
Group 5 Presentation.pptx
 

More from Mani Kanth

White box testing
White box testing White box testing
White box testing Mani Kanth
 
System testing
System testingSystem testing
System testingMani Kanth
 
management of maintainance
management of maintainancemanagement of maintainance
management of maintainanceMani Kanth
 
Se (techniques for black box testing ppt)
Se (techniques for black box testing ppt)Se (techniques for black box testing ppt)
Se (techniques for black box testing ppt)Mani Kanth
 
Reverse engineering in software engineering vaibhav
Reverse engineering in software engineering vaibhavReverse engineering in software engineering vaibhav
Reverse engineering in software engineering vaibhavMani Kanth
 
Mutation testing 1
Mutation testing 1Mutation testing 1
Mutation testing 1Mani Kanth
 
Mutation testing
Mutation testingMutation testing
Mutation testingMani Kanth
 
Guideline for euivalence class testing
Guideline for euivalence class testingGuideline for euivalence class testing
Guideline for euivalence class testingMani Kanth
 
Equivalence class testing
Equivalence  class testingEquivalence  class testing
Equivalence class testingMani Kanth
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithmMani Kanth
 
Scaling and shearing
Scaling and shearingScaling and shearing
Scaling and shearingMani Kanth
 
Raster and random scan display types of input devices
Raster and random scan display types of input devicesRaster and random scan display types of input devices
Raster and random scan display types of input devicesMani Kanth
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithmMani Kanth
 
Graphics software and standards
Graphics software and standardsGraphics software and standards
Graphics software and standardsMani Kanth
 
Character generation techniques
Character generation techniquesCharacter generation techniques
Character generation techniquesMani Kanth
 

More from Mani Kanth (20)

White box testing
White box testing White box testing
White box testing
 
Unit testing
Unit testing Unit testing
Unit testing
 
System testing
System testingSystem testing
System testing
 
management of maintainance
management of maintainancemanagement of maintainance
management of maintainance
 
Se (techniques for black box testing ppt)
Se (techniques for black box testing ppt)Se (techniques for black box testing ppt)
Se (techniques for black box testing ppt)
 
Reverse engineering in software engineering vaibhav
Reverse engineering in software engineering vaibhavReverse engineering in software engineering vaibhav
Reverse engineering in software engineering vaibhav
 
Mutation testing 1
Mutation testing 1Mutation testing 1
Mutation testing 1
 
Mutation testing
Mutation testingMutation testing
Mutation testing
 
Guideline for euivalence class testing
Guideline for euivalence class testingGuideline for euivalence class testing
Guideline for euivalence class testing
 
Equivalence class testing
Equivalence  class testingEquivalence  class testing
Equivalence class testing
 
Deployment
DeploymentDeployment
Deployment
 
unit testing
unit testingunit testing
unit testing
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithm
 
Scaling and shearing
Scaling and shearingScaling and shearing
Scaling and shearing
 
Raster and random scan display types of input devices
Raster and random scan display types of input devicesRaster and random scan display types of input devices
Raster and random scan display types of input devices
 
Projection
ProjectionProjection
Projection
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
 
Graphics software and standards
Graphics software and standardsGraphics software and standards
Graphics software and standards
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
 
Character generation techniques
Character generation techniquesCharacter generation techniques
Character generation techniques
 

Recently uploaded

Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxpritamlangde
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...vershagrag
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...jabtakhaidam7
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptAfnanAhmad53
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesChandrakantDivate1
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 

Recently uploaded (20)

Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
 
fitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .pptfitting shop and tools used in fitting shop .ppt
fitting shop and tools used in fitting shop .ppt
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 

Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm

  • 1. POLYGON CLIPPING WITH SUTHERLAND HODGEMAN ALGORITHM AND SCAN LINE FILL ALGORITHM
  • 2. Clipping  The primary use of clipping in computer graphics is to remove objects, lines, or line segments that are outside the viewing pane . Clip Window: The region against which an object is to be clipped.  Point Clipping  Line Clipping (straight-line segments)  Area Clipping (polygons)  Text Clipping
  • 3. Polygon Clipping  Clipping a polygon fill area needs more than line-clipping of the polygon edges -would produce and unconnected set of lines  Must generate one or more closed polylines, which can be filled with the assigned colour or pattern
  • 4. Sutherland–Hodgeman algorithm  Each edge of the polygon must be tested against each edge of the clip rectangle; new edges must be added, and existing edges must be discarded, retained, or divided. Multiple polygons may result from clipping a single polygon. We need an organized way to deal with all these cases
  • 5. FOUR POSSIBLE SCENARIOS AT EACH CLIPPER 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
  • 6. Steps of Sutherland-Hodgmans polygon clipping algorithm  Polygons can be clipped against each edge of the window one at a time.  Vertices which are kept after clipping against one window edge are saved for clipping against the remaining edges .  Note that the number of vertices usually changes and will often increases.
  • 7.
  • 8.
  • 9. SCAN LINE FILL ALGORITHM
  • 10. Scan-Line  A scan line is one line, or row, in a raster scanning pattern, such as a line of video on a cathode ray tube display of a television set or computer monitor.
  • 11. Scan-line Polygon Fill For each scan-line :  Locate the intersection of the scan-line with the edges (y=ys)  Sort the intersection points from left to right.  Draw the interiors intersection points pairwise. (a-b), (c-d)
  • 12. Problem with corners. Same point counted twice or not?  a,b,c and d are intersected by 2 line segments each.  Count b,c twice but a and d once. Why? Solution: Make a clockwise or counter-clockwise traversal on edges. Check if y is monotonically increasing or decreasing. If direction changes, double intersection, otherwise single intersection.
  • 13. Scan Line Fill: What happens at edge end-point?  Edge endpoint is duplicated.  In other words, when a scan line intersects an edge endpoint, it intersects two edges.  Two cases: Case A: edges are monotonically increasing or decreasing Case B: edges reverse direction at endpoint  In Case A, we should consider this as only ONE edge intersection  In Case B, we should consider this as TWO edge intersections
  • 14. Scan Line Fill Algorithm Basic algorithm:  Assume scan line start from the left and is outside the polygon.  When intersect an edge of polygon, start to color each pixel (because now we’re inside the polygon), when intersect another edge, stop coloring …  Odd number of edges: inside  Even number of edges: outside