SlideShare a Scribd company logo
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

More Related Content

What's hot

Computer animation
Computer animationComputer animation
Computer animation
shusrusha
 
Camera model ‫‬
Camera model ‫‬Camera model ‫‬
Camera model ‫‬
Fatima Radi
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D
2013901097
 
Unit 3
Unit 3Unit 3
Unit 3
ypnrao
 
2 d viewing computer graphics
2 d viewing computer graphics2 d viewing computer graphics
2 d viewing computer graphics
KALESHWAR KUMAR
 
3 d display methods
3 d display methods3 d display methods
3 d display methods
Shami Al Rahad
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
Ankit Garg
 
Color models
Color modelsColor models
Color models
Haitham Ahmed
 
Quadric surfaces
Quadric surfacesQuadric surfaces
Quadric surfaces
Ankur Kumar
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.Mohd Arif
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
smruti sarangi
 
Line clipping
Line clippingLine clipping
Line clipping
Ankit Garg
 
Weiler atherton
Weiler athertonWeiler atherton
Weiler atherton
Arvind Kumar
 
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
Scan line method
Scan line methodScan line method
Scan line method
Pooja Dixit
 
Animation in Computer Graphics
Animation in Computer GraphicsAnimation in Computer Graphics
Animation in Computer Graphics
RinkuNahar
 
sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clipping
Arvind Kumar
 
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
 

What's hot (20)

Computer animation
Computer animationComputer animation
Computer animation
 
Camera model ‫‬
Camera model ‫‬Camera model ‫‬
Camera model ‫‬
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D
 
Unit 3
Unit 3Unit 3
Unit 3
 
2 d viewing computer graphics
2 d viewing computer graphics2 d viewing computer graphics
2 d viewing computer graphics
 
3 d display methods
3 d display methods3 d display methods
3 d display methods
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
 
Color models
Color modelsColor models
Color models
 
Quadric surfaces
Quadric surfacesQuadric surfaces
Quadric surfaces
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
Line clipping
Line clippingLine clipping
Line clipping
 
Weiler atherton
Weiler athertonWeiler atherton
Weiler atherton
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Scan line method
Scan line methodScan line method
Scan line method
 
Animation in Computer Graphics
Animation in Computer GraphicsAnimation in Computer Graphics
Animation in Computer Graphics
 
sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clipping
 
Clipping
ClippingClipping
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
 

Similar to Line clipping algorithm (Detailed)

Cohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithmCohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithm
Tawfiq Ahmed
 
Clipping
ClippingClipping
Group 5 Presentation.pptx
Group 5 Presentation.pptxGroup 5 Presentation.pptx
Group 5 Presentation.pptx
KelvinDube4
 
Group 5 Presentation.pptx
Group 5 Presentation.pptxGroup 5 Presentation.pptx
Group 5 Presentation.pptx
KelvinDube4
 
Group 6 Presentation - Copy.pptx
Group 6 Presentation - Copy.pptxGroup 6 Presentation - Copy.pptx
Group 6 Presentation - Copy.pptx
KelvinDube4
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
lokesh503
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
Lokesh Reddy
 
Computer graphics
Computer graphicsComputer graphics
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
ABDULSAMADKAZI
 
Clipping
ClippingClipping
Clipping
Pooja Dixit
 
Sutherlands Cohen and Hodgeman algorithms
Sutherlands Cohen and Hodgeman algorithmsSutherlands Cohen and Hodgeman algorithms
Sutherlands Cohen and Hodgeman algorithms
Rohit Jain
 
ch4.pptx
ch4.pptxch4.pptx
ch4.pptx
OnkarTalekar4
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
MdAlAmin187
 
Cohen sutherland algorithm
Cohen sutherland algorithmCohen sutherland algorithm
Cohen sutherland algorithm
Farwa Ansari
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clipping
majicyoung
 
Computer Graphics - Windowing and Clipping
Computer Graphics - Windowing and ClippingComputer Graphics - Windowing and Clipping
Computer Graphics - Windowing and Clipping
Chandrakant Divate
 
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)
Priscilla CPG
 
CAD/CAM/CAE - Notes
CAD/CAM/CAE - NotesCAD/CAM/CAE - Notes
CAD/CAM/CAE - Notes
Learn With GeekAlign
 

Similar to Line clipping algorithm (Detailed) (20)

Cohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithmCohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithm
 
Clipping
ClippingClipping
Clipping
 
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
 
Group 6 Presentation - Copy.pptx
Group 6 Presentation - Copy.pptxGroup 6 Presentation - Copy.pptx
Group 6 Presentation - Copy.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
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
Cohen sutherland algorithm
Cohen sutherland algorithmCohen sutherland algorithm
Cohen sutherland algorithm
 
lecture8 clipping
lecture8 clippinglecture8 clipping
lecture8 clipping
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clipping
 
Computer Graphics - Windowing and Clipping
Computer Graphics - Windowing and ClippingComputer Graphics - Windowing and Clipping
Computer Graphics - Windowing and 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
 

More from Aamir Sohail

Presentation on java servlets
Presentation on java servletsPresentation on java servlets
Presentation on java servlets
Aamir Sohail
 
Presentation on html, css
Presentation on html, cssPresentation on html, css
Presentation on html, css
Aamir 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 algorithm
Aamir Sohail
 
Vb script
Vb scriptVb script
Vb script
Aamir Sohail
 
Infromation securiity
Infromation securiityInfromation securiity
Infromation securiity
Aamir Sohail
 
Network Security Policies
Network Security PoliciesNetwork Security Policies
Network Security Policies
Aamir Sohail
 
Scheduling and scheduling personnel
Scheduling and scheduling personnelScheduling and scheduling personnel
Scheduling and scheduling personnel
Aamir Sohail
 

More from 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
 

Recently uploaded

Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 

Recently uploaded (20)

Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 

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