SlideShare une entreprise Scribd logo
1  sur  21
Cohen-Sutherland Line
Clipping Algorithm
Presenting By: Aamir Sohail
Presenting to: Sir M.Arshad
Class: Computer Graphics
Department of Computer Science
1Aamir Sohail
Introduction
When drawing a 2D line on screen, it might happen that
one or both of the endpoints are outside the screen while
a part of the line should still be visible.
In that case, an efficient algorithm is needed to find two
new endpoints that are on the edges on the screen, so
that the part of the line that's visible can now be drawn.
2Aamir Sohail
Introduction cont…
This way, all those points of the line outside the screen
are clipped away and you don't need to waste any
execution time on them.
A good clipping algorithm is the Cohen-Sutherland line
clipping algorithm for this solution.
3Aamir Sohail
Cohen Sutherland Clipping Algorithm
When drawing a 2D line, if one endpoint of the line is
outside the screen, and the other inside, you have to
clip the line so that only the part of it that's inside the
screen remains.
Even if both endpoints are outside the screen, it's still
possible that a part of the line should be visible.
The clipping algorithm needs to find new endpoints of
the lines, that are inside or on the edges of the screen.
4Aamir Sohail
Cases
Here are a few cases, where the black rectangle
represents the screen, in red are the old endpoints,
and in blue the ones after clipping:
5Aamir Sohail
Cont…
Case A: Both end-points are inside the screen, so no
clipping needed.
6Aamir Sohail
Cont…
Case B: One end-point outside the screen, that one had to
be clipped.
7Aamir Sohail
Cont…
Case C: both endpoint are outside the screen, and no part of
the line is visible, don't draw it at all.
8Aamir Sohail
Cont…
Case D: both endpoint are outside the screen, and a part of
the line is visible, clip both endpoints and draw it.
9Aamir Sohail
Cohen Sutherland Clipping Algorithm
Now we will learn what is Cohen Sutherland Clipping Algorithm
and how it works.
This algorithm clips a line to the clipping rectangle. It
concerns itself with performing the simple cases quickly.
10Aamir Sohail
Cont…
In this algorithm it divides lines & edges into 2 cases.
1) Trivially Accept and
2) Trivially Reject.
11Aamir Sohail
Conditions of Trivially Accept
Xmin ≤ X ≤ Xmax
Ymin ≤ Y ≤ Ymax
Lines fulfill this conditions then we will
mark those lines as trivially accept.
Ymax
Ymin
Xmin Xmax
12Aamir Sohail
Conditions of Trivially Reject
 X0 < Xmin & X1 < Xmin or
Y0 < Ymin & Y1 < Ymin
X0 > Xmax & X1 > Xmax or
Y0 > Ymax & Y1 > Ymax
13Aamir Sohail
Question Arrives
We must have a question now??
A
B
Then we will move forward for solve this ……..14Aamir Sohail
Cont…
The algorithm divides the 2D space in 9
regions:
This is also known as ABRL CODE
15Aamir Sohail
ABRL Cont…
 The center region is the screen or Window Position (0000).
 If the region is above the screen, the first bit is 1.
 If the region is below the screen, the second bit is 1.
 If the region is to the right of the screen, the third bit is 1.
 If the region is to the left of the screen, the fourth bit is
1.
16Aamir Sohail
A (0100) B (0010)
AND Operation
Then get the new point C (0000)
17Aamir Sohail
C (0000) B (0010)
AND Operation
Then get the new point D (0000)
Then we have the final line after clipping is CD 18Aamir Sohail
Handling Similar Situations
If similar problems arrive then we have to clip
those according to mentioned method.
Some examples of similar situations
19Aamir Sohail
I hope there will be no
question in your mind…
20Aamir Sohail
References
https://en.wikipedia.org/wiki/Line_clipping
https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm
http://www.cc.gatech.edu/grads/h/Hao-wei.Hsieh/Haowei.Hsieh/mm.html
https://www.cs.helsinki.fi/group/goa/viewing/leikkaus/lineClip.html
Pptx files and some video lectures.
21Aamir Sohail

Contenu connexe

Tendances

Cohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithmCohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithmTawfiq Ahmed
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithmAparna Joshi
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer GraphicsLaxman Puri
 
CG - Output Primitives
CG - Output PrimitivesCG - Output Primitives
CG - Output Primitivesvinay arora
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.Mohd Arif
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clippingMdAlAmin187
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphicsShaishavShah8
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clippingShweta Shah
 
3 d viewing projection
3 d viewing  projection3 d viewing  projection
3 d viewing projectionPooja Dixit
 
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
 
Back face detection
Back face detectionBack face detection
Back face detectionPooja Dixit
 
Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clippingArvind Kumar
 
Graphics_3D viewing
Graphics_3D viewingGraphics_3D viewing
Graphics_3D viewingRabin BK
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unitaravindangc
 
Polygon filling
Polygon fillingPolygon filling
Polygon fillingAnkit Garg
 
Liang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmLiang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmArvind Kumar
 

Tendances (20)

Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Cohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithmCohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithm
 
Clipping
ClippingClipping
Clipping
 
Clipping
ClippingClipping
Clipping
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 
CG - Output Primitives
CG - Output PrimitivesCG - Output Primitives
CG - Output Primitives
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
line clipping
line clipping line clipping
line clipping
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clipping
 
3 d viewing projection
3 d viewing  projection3 d viewing  projection
3 d viewing projection
 
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
 
Back face detection
Back face detectionBack face detection
Back face detection
 
Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clipping
 
Graphics_3D viewing
Graphics_3D viewingGraphics_3D viewing
Graphics_3D viewing
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unit
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Liang barsky Line Clipping Algorithm
Liang barsky Line Clipping AlgorithmLiang barsky Line Clipping Algorithm
Liang barsky Line Clipping Algorithm
 

Similaire à Line clipping algorithm (Detailed)

Similaire à Line clipping algorithm (Detailed) (20)

Clipping
ClippingClipping
Clipping
 
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
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Clipping
ClippingClipping
Clipping
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
Clipping
ClippingClipping
Clipping
 
Sutherlands Cohen and Hodgeman algorithms
Sutherlands Cohen and Hodgeman algorithmsSutherlands Cohen and Hodgeman algorithms
Sutherlands Cohen and Hodgeman algorithms
 
ch4.pptx
ch4.pptxch4.pptx
ch4.pptx
 
Cohen sutherland algorithm
Cohen sutherland algorithmCohen sutherland algorithm
Cohen sutherland algorithm
 
Line clipping
Line clippingLine clipping
Line clipping
 
lecture8 clipping
lecture8 clippinglecture8 clipping
lecture8 clipping
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clipping
 
CAD - Unit-1 (Fundamentals of Computer Graphics)
CAD - Unit-1 (Fundamentals of Computer Graphics)CAD - Unit-1 (Fundamentals of Computer Graphics)
CAD - Unit-1 (Fundamentals of Computer Graphics)
 
CAD/CAM/CAE - Notes
CAD/CAM/CAE - NotesCAD/CAM/CAE - Notes
CAD/CAM/CAE - Notes
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
7-Clipping-16 (1).pdf
7-Clipping-16 (1).pdf7-Clipping-16 (1).pdf
7-Clipping-16 (1).pdf
 

Plus de Aamir Sohail

Presentation on java servlets
Presentation on java servletsPresentation on java servlets
Presentation on java servletsAamir Sohail
 
Presentation on html, css
Presentation on html, cssPresentation on html, css
Presentation on html, cssAamir Sohail
 
Hash table in data structure and algorithm
Hash table in data structure and algorithmHash table in data structure and algorithm
Hash table in data structure and algorithmAamir Sohail
 
Infromation securiity
Infromation securiityInfromation securiity
Infromation securiityAamir Sohail
 
Network Security Policies
Network Security PoliciesNetwork Security Policies
Network Security PoliciesAamir Sohail
 
Scheduling and scheduling personnel
Scheduling and scheduling personnelScheduling and scheduling personnel
Scheduling and scheduling personnelAamir Sohail
 

Plus de Aamir Sohail (7)

Presentation on java servlets
Presentation on java servletsPresentation on java servlets
Presentation on java servlets
 
Presentation on html, css
Presentation on html, cssPresentation on html, css
Presentation on html, css
 
Hash table in data structure and algorithm
Hash table in data structure and algorithmHash table in data structure and algorithm
Hash table in data structure and algorithm
 
Vb script
Vb scriptVb script
Vb script
 
Infromation securiity
Infromation securiityInfromation securiity
Infromation securiity
 
Network Security Policies
Network Security PoliciesNetwork Security Policies
Network Security Policies
 
Scheduling and scheduling personnel
Scheduling and scheduling personnelScheduling and scheduling personnel
Scheduling and scheduling personnel
 

Dernier

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 

Dernier (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 

Line clipping algorithm (Detailed)

  • 1. Cohen-Sutherland Line Clipping Algorithm Presenting By: Aamir Sohail Presenting to: Sir M.Arshad Class: Computer Graphics Department of Computer Science 1Aamir Sohail
  • 2. Introduction When drawing a 2D line on screen, it might happen that one or both of the endpoints are outside the screen while a part of the line should still be visible. In that case, an efficient algorithm is needed to find two new endpoints that are on the edges on the screen, so that the part of the line that's visible can now be drawn. 2Aamir Sohail
  • 3. Introduction cont… This way, all those points of the line outside the screen are clipped away and you don't need to waste any execution time on them. A good clipping algorithm is the Cohen-Sutherland line clipping algorithm for this solution. 3Aamir Sohail
  • 4. Cohen Sutherland Clipping Algorithm When drawing a 2D line, if one endpoint of the line is outside the screen, and the other inside, you have to clip the line so that only the part of it that's inside the screen remains. Even if both endpoints are outside the screen, it's still possible that a part of the line should be visible. The clipping algorithm needs to find new endpoints of the lines, that are inside or on the edges of the screen. 4Aamir Sohail
  • 5. Cases Here are a few cases, where the black rectangle represents the screen, in red are the old endpoints, and in blue the ones after clipping: 5Aamir Sohail
  • 6. Cont… Case A: Both end-points are inside the screen, so no clipping needed. 6Aamir Sohail
  • 7. Cont… Case B: One end-point outside the screen, that one had to be clipped. 7Aamir Sohail
  • 8. Cont… Case C: both endpoint are outside the screen, and no part of the line is visible, don't draw it at all. 8Aamir Sohail
  • 9. Cont… Case D: both endpoint are outside the screen, and a part of the line is visible, clip both endpoints and draw it. 9Aamir Sohail
  • 10. Cohen Sutherland Clipping Algorithm Now we will learn what is Cohen Sutherland Clipping Algorithm and how it works. This algorithm clips a line to the clipping rectangle. It concerns itself with performing the simple cases quickly. 10Aamir Sohail
  • 11. Cont… In this algorithm it divides lines & edges into 2 cases. 1) Trivially Accept and 2) Trivially Reject. 11Aamir Sohail
  • 12. Conditions of Trivially Accept Xmin ≤ X ≤ Xmax Ymin ≤ Y ≤ Ymax Lines fulfill this conditions then we will mark those lines as trivially accept. Ymax Ymin Xmin Xmax 12Aamir Sohail
  • 13. Conditions of Trivially Reject  X0 < Xmin & X1 < Xmin or Y0 < Ymin & Y1 < Ymin X0 > Xmax & X1 > Xmax or Y0 > Ymax & Y1 > Ymax 13Aamir Sohail
  • 14. Question Arrives We must have a question now?? A B Then we will move forward for solve this ……..14Aamir Sohail
  • 15. Cont… The algorithm divides the 2D space in 9 regions: This is also known as ABRL CODE 15Aamir Sohail
  • 16. ABRL Cont…  The center region is the screen or Window Position (0000).  If the region is above the screen, the first bit is 1.  If the region is below the screen, the second bit is 1.  If the region is to the right of the screen, the third bit is 1.  If the region is to the left of the screen, the fourth bit is 1. 16Aamir Sohail
  • 17. A (0100) B (0010) AND Operation Then get the new point C (0000) 17Aamir Sohail
  • 18. C (0000) B (0010) AND Operation Then get the new point D (0000) Then we have the final line after clipping is CD 18Aamir Sohail
  • 19. Handling Similar Situations If similar problems arrive then we have to clip those according to mentioned method. Some examples of similar situations 19Aamir Sohail
  • 20. I hope there will be no question in your mind… 20Aamir Sohail