SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Introduction
 When drawing a 2D line on screen, it might
happen that one or both 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. This way, all those
points of the line outside the screen are
clipped away and don't need to waste any
execution time on them.
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:
 Case A: Both endpoints are inside the screen, so no clipping needed.
 Case B: One end-point outside the screen, that one had to be clipped.
 Case C: both endpoints are outside the screen, and no part of the line is visible,
don't draw it at all.
 Case D: both endpoints are outside the screen, and a part of the line is visible, clip
both endpoints and draw it.
How Cohen
Sutherland
Clipping
Algorithm
works.
 The Cohen–Sutherland algorithm is a
computer-graphics algorithm used for line
clipping. The algorithm divides a two-
dimensional space into 9 regions and then
efficiently determines the lines to the clipping
rectangle. It concerns itself with performing
the simple cases quickly.
 In this algorithm it divides lines & edges into
2 cases.
1) Trivially Accept
2) Trivially Reject.
 Both endpoints of segment AB lie within
the window, so the whole segment AB must
lie within the window. Therefore, AB can be
trivially accepted.
 Both endpoints of segment CD lie entirely
to one side of the window, so segment CD
must lie entirely outside of the window.
Therefore, CD can be trivially rejected.
 Xmin ≀ X ≀ Xmax
 Ymin ≀ Y ≀ Ymax
 Lines fulfill these conditions then
we will mark
 those lines as trivially accept.
 X0 < Xmin & X1 < Xmin or
 Y0 < Ymin & Y1 < Ymin
 X0 > Xmax & X1 > Xmax or
 Y0 > Ymax & Y1 > Ymax
This is also known as ABRL code.
1. The center region is the screen or Window
Position (0000).
2. If the region is above the screen, the first
bit is 1.
3. If the region is below the screen, the
second bit is 1.
4. If the region is to the right of the screen,
the third bit is 1.
5. If the region is to the left of the screen, the
fourth bit is 1.
Then we have the final line after clipping is CD
THANK YOU

Weitere Àhnliche Inhalte

Was ist angesagt?

Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithmPolygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Mani Kanth
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
Ankit Garg
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
Mani Kanth
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
Ankit Garg
 
Visual surface detection i
Visual surface detection   iVisual surface detection   i
Visual surface detection i
elaya1984
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unit
aravindangc
 

Was ist angesagt? (20)

Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clipping
 
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithmPolygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
Polygon clipping with sutherland hodgeman algorithm and scan line fill algorithm
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer Graphics
 
Clipping in Computer Graphics
Clipping in Computer Graphics Clipping in Computer Graphics
Clipping in Computer Graphics
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Graphics_3D viewing
Graphics_3D viewingGraphics_3D viewing
Graphics_3D viewing
 
Quadric surfaces
Quadric surfacesQuadric surfaces
Quadric surfaces
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
4. THREE DIMENSIONAL DISPLAY METHODS
4.	THREE DIMENSIONAL DISPLAY METHODS4.	THREE DIMENSIONAL DISPLAY METHODS
4. THREE DIMENSIONAL DISPLAY METHODS
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
lecture8 clipping
lecture8 clippinglecture8 clipping
lecture8 clipping
 
Weiler atherton
Weiler athertonWeiler atherton
Weiler atherton
 
Visual surface detection i
Visual surface detection   iVisual surface detection   i
Visual surface detection i
 
Computer graphics iv unit
Computer graphics iv unitComputer graphics iv unit
Computer graphics iv unit
 
Scan line method
Scan line methodScan line method
Scan line method
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 

Ähnlich wie Cohen sutherland line clipping algorithm

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
avelraj
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
lokesh503
 

Ähnlich wie Cohen sutherland line clipping algorithm (20)

Clipping
ClippingClipping
Clipping
 
Clipping
ClippingClipping
Clipping
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clipping
 
line clipping
line clipping line clipping
line 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
ClippingClipping
Clipping
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clipping
 
kgv.pptx
kgv.pptxkgv.pptx
kgv.pptx
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
Clipping
ClippingClipping
Clipping
 
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
 
ibuib.pptx
ibuib.pptxibuib.pptx
ibuib.pptx
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Computer Graphics - clipping
Computer Graphics - clippingComputer Graphics - clipping
Computer Graphics - clipping
 
Computer Graphic - Clipping
Computer Graphic - ClippingComputer Graphic - Clipping
Computer Graphic - Clipping
 

KĂŒrzlich hochgeladen

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

KĂŒrzlich hochgeladen (20)

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
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
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
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
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
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...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

Cohen sutherland line clipping algorithm

  • 1.
  • 2. Introduction  When drawing a 2D line on screen, it might happen that one or both 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. This way, all those points of the line outside the screen are clipped away and don't need to waste any execution time on them.
  • 3. 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:  Case A: Both endpoints are inside the screen, so no clipping needed.  Case B: One end-point outside the screen, that one had to be clipped.  Case C: both endpoints are outside the screen, and no part of the line is visible, don't draw it at all.  Case D: both endpoints are outside the screen, and a part of the line is visible, clip both endpoints and draw it.
  • 4. How Cohen Sutherland Clipping Algorithm works.  The Cohen–Sutherland algorithm is a computer-graphics algorithm used for line clipping. The algorithm divides a two- dimensional space into 9 regions and then efficiently determines the lines to the clipping rectangle. It concerns itself with performing the simple cases quickly.  In this algorithm it divides lines & edges into 2 cases. 1) Trivially Accept 2) Trivially Reject.
  • 5.  Both endpoints of segment AB lie within the window, so the whole segment AB must lie within the window. Therefore, AB can be trivially accepted.  Both endpoints of segment CD lie entirely to one side of the window, so segment CD must lie entirely outside of the window. Therefore, CD can be trivially rejected.
  • 6.  Xmin ≀ X ≀ Xmax  Ymin ≀ Y ≀ Ymax  Lines fulfill these conditions then we will mark  those lines as trivially accept.
  • 7.  X0 < Xmin & X1 < Xmin or  Y0 < Ymin & Y1 < Ymin  X0 > Xmax & X1 > Xmax or  Y0 > Ymax & Y1 > Ymax
  • 8. This is also known as ABRL code.
  • 9. 1. The center region is the screen or Window Position (0000). 2. If the region is above the screen, the first bit is 1. 3. If the region is below the screen, the second bit is 1. 4. If the region is to the right of the screen, the third bit is 1. 5. If the region is to the left of the screen, the fourth bit is 1.
  • 10.
  • 11. Then we have the final line after clipping is CD