SlideShare a Scribd company logo
1 of 4
Download to read offline
1
Cohen Sutherland Line Clipping Algorithm Example
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
Date: 20170821
Note
The implementation of the Cohen Sutherland Algorithm in C programming language is available
in following link.
https://www.academia.edu/2492014/Cohen_Sutherland_Line_Clipping_Algorithm_in_C
Problem
Demonstrate how Cohen Sutherland algorithm works for the line segment shown in the
following figure. Note that it intersects only with RIGHT and TOP boundaries.
Answer
done = 0, draw = 0;
done == 0  TRUE;
code1
code = 0000;
x < minx  FALSE;
x > maxx  FALSE;
y < miny  FALSE;
(x[0], y[0])
(x[1], y[1])
0
1
2
y > maxy  TRUE;
code = code | TOP_EDGE = 0000 | 1000 = 1000;
code1 = 1000;
code2
code = 0000;
x < minx  FALSE;
x > maxx  TRUE;
code = code | RIGHT_EDGE = 0000 | 0010 = 0010;
y < miny  FALSE;
y > maxy  FALSE;
code2 = 0010;
ACCEPT (code1, code2) = ! (1000 | 0010) = ! 1010  FALSE;
REJECT (code1, code2) = 1000 & 0010 = 0000  FALSE;
INSIDE (code1) = ! 1000  FALSE;
x[0] != x[1]  TRUE;
m = (y[1] – y[0])/(x[1] – x[0]);
code1 & LEFT_EDGE = 1000 & 0001 = 0000  FALSE;
code1 & RIGHT_EDGE = 1000 & 0010 = 0000  FALSE;
code1 & BOTTOM_EDGE = 1000 & 0100 = 0000  FALSE;
code1 & TOP_EDGE = 1000 & 1000 = 1000  TRUE;
x[0] != x[1]  TRUE;
x[0] += (maxy – y[0])/m;
y[0] = maxy;
done == 0  TRUE;
code1
code = 0000;
x < minx  FALSE;
x > maxx  FALSE;
y < miny  FALSE;
y > maxy  FALSE;
code1 = 0000;
0
1
3
code2
code = 0000;
x < minx  FALSE;
x > maxx  TRUE;
code = code | RIGHT_EDGE = 0000 | 0010 = 0010
y < miny  FALSE;
y > maxy  FALSE;
code2 = 0010;
ACCEPT (code1, code2) = ! (0000 | 0010) = ! 0010  FALSE;
REJECT (code1, code2) = 0000 & 0010 = 0000  FALSE;
INSIDE (code1) = ! 0000  TRUE;
swapPts;
swapCodes
code1 = 0010;
code2 = 0000;
x[0] != x[1]  TRUE;
m = (y[1] – y[0])/(x[1] – x[0]);
code1 & LEFT_EDGE = 0010 & 0001 = 0000  FALSE;
code1 & RIGHT_EDGE = 0010 & 0010 = 0010  TRUE;
y[0] += (maxx – x[0]) * m;
x[0] = maxx;
1
0
1
0
4
done == 0  TRUE;
code1
code = 0000;
x < minx  FALSE;
x > maxx  FALSE;
y < miny  FALSE;
y > maxy  FALSE;
code1 = 0000;
code2
code = 0000;
x < minx  FALSE;
x > maxx  FALSE;
y < miny  FALSE;
y > maxy  FALSE;
code2 = 0000;
ACCEPT (code1, code2) = ! (0000 | 0000) = ! 0000  TRUE;
done = 1, draw = 1;
done == 0  FALSE;
draw == 1  TRUE;
Line segment is drawn.

More Related Content

What's hot

Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformationSelvakumar Gna
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmMani Kanth
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.Mohd Arif
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithmAparna Joshi
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtrackingmandlapure
 
Hidden surfaces
Hidden surfacesHidden surfaces
Hidden surfacesMohd Arif
 
sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingArvind Kumar
 
Polygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesPolygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesOmprakash Chauhan
 
Character generation
Character generationCharacter generation
Character generationAnkit Garg
 
Attributes of output Primitive
Attributes of output Primitive Attributes of output Primitive
Attributes of output Primitive SachiniGunawardana
 
Huffman Coding Algorithm Presentation
Huffman Coding Algorithm PresentationHuffman Coding Algorithm Presentation
Huffman Coding Algorithm PresentationAkm Monir
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removalPunyajoy Saha
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 

What's hot (20)

BRESENHAM’S LINE DRAWING ALGORITHM
BRESENHAM’S  LINE DRAWING ALGORITHMBRESENHAM’S  LINE DRAWING ALGORITHM
BRESENHAM’S LINE DRAWING ALGORITHM
 
Clipping
ClippingClipping
Clipping
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformation
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
 
Computer Graphics - clipping
Computer Graphics - clippingComputer Graphics - clipping
Computer Graphics - clipping
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtracking
 
Hidden surfaces
Hidden surfacesHidden surfaces
Hidden surfaces
 
sutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clippingsutherland- Hodgeman Polygon clipping
sutherland- Hodgeman Polygon clipping
 
OOSE
OOSEOOSE
OOSE
 
Polygons - Computer Graphics - Notes
Polygons - Computer Graphics - NotesPolygons - Computer Graphics - Notes
Polygons - Computer Graphics - Notes
 
Character generation
Character generationCharacter generation
Character generation
 
Attributes of output Primitive
Attributes of output Primitive Attributes of output Primitive
Attributes of output Primitive
 
Weiler atherton
Weiler athertonWeiler atherton
Weiler atherton
 
Huffman Coding Algorithm Presentation
Huffman Coding Algorithm PresentationHuffman Coding Algorithm Presentation
Huffman Coding Algorithm Presentation
 
Compiler design lab programs
Compiler design lab programs Compiler design lab programs
Compiler design lab programs
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 

Similar to Cohen Sutherland Line Clipping Algorithm Example

10CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 510CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 5Vanishree Arun
 
GROUP03_AMAK:ERROR DETECTION AND CORRECTION PPT
GROUP03_AMAK:ERROR DETECTION AND CORRECTION PPTGROUP03_AMAK:ERROR DETECTION AND CORRECTION PPT
GROUP03_AMAK:ERROR DETECTION AND CORRECTION PPTKrishbathija
 
Review questions and answers
Review questions and answersReview questions and answers
Review questions and answersIIUM
 
19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf
19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf
19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdfKrishnaKumar2309
 
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdfIntroduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdffathimafancyjeweller
 
3 JavaScript challenges for one application
3 JavaScript challenges for one application3 JavaScript challenges for one application
3 JavaScript challenges for one applicationRoman Kryvun
 
A few solvers for portfolio selection
A few solvers for portfolio selectionA few solvers for portfolio selection
A few solvers for portfolio selectionBogusz Jelinski
 
Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Mokshya Priyadarshee
 
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...Janis Alnis
 
Unit2- line clipping.pptx
Unit2- line clipping.pptxUnit2- line clipping.pptx
Unit2- line clipping.pptxRYZEN14
 
Implementing qrcode
Implementing qrcodeImplementing qrcode
Implementing qrcodeBoshan Sun
 
03review
03review03review
03reviewIIUM
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptxsulekhasaxena2
 
Slide_code 128 barcode font for excel (1).pdf
Slide_code 128 barcode font for excel (1).pdfSlide_code 128 barcode font for excel (1).pdf
Slide_code 128 barcode font for excel (1).pdfBarcode Live
 
An Introduction to Linear Programming
An Introduction to Linear ProgrammingAn Introduction to Linear Programming
An Introduction to Linear ProgrammingMinh-Tri Pham
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better codeDror Helper
 

Similar to Cohen Sutherland Line Clipping Algorithm Example (20)

10CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 510CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 5
 
GROUP03_AMAK:ERROR DETECTION AND CORRECTION PPT
GROUP03_AMAK:ERROR DETECTION AND CORRECTION PPTGROUP03_AMAK:ERROR DETECTION AND CORRECTION PPT
GROUP03_AMAK:ERROR DETECTION AND CORRECTION PPT
 
Review questions and answers
Review questions and answersReview questions and answers
Review questions and answers
 
19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf
19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf
19BCS2605_Krishna_Kumar_Computer_Graphics_exp_3.1.pdf
 
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdfIntroduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
 
3 JavaScript challenges for one application
3 JavaScript challenges for one application3 JavaScript challenges for one application
3 JavaScript challenges for one application
 
jacobi method, gauss siedel for solving linear equations
jacobi method, gauss siedel for solving linear equationsjacobi method, gauss siedel for solving linear equations
jacobi method, gauss siedel for solving linear equations
 
A few solvers for portfolio selection
A few solvers for portfolio selectionA few solvers for portfolio selection
A few solvers for portfolio selection
 
Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)
 
conditional.ppt
conditional.pptconditional.ppt
conditional.ppt
 
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...
 
Unit2- line clipping.pptx
Unit2- line clipping.pptxUnit2- line clipping.pptx
Unit2- line clipping.pptx
 
Implementing qrcode
Implementing qrcodeImplementing qrcode
Implementing qrcode
 
03review
03review03review
03review
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptx
 
Slide_code 128 barcode font for excel (1).pdf
Slide_code 128 barcode font for excel (1).pdfSlide_code 128 barcode font for excel (1).pdf
Slide_code 128 barcode font for excel (1).pdf
 
C++ TUTORIAL 9
C++ TUTORIAL 9C++ TUTORIAL 9
C++ TUTORIAL 9
 
Numerical Methods Solving Linear Equations
Numerical Methods Solving Linear EquationsNumerical Methods Solving Linear Equations
Numerical Methods Solving Linear Equations
 
An Introduction to Linear Programming
An Introduction to Linear ProgrammingAn Introduction to Linear Programming
An Introduction to Linear Programming
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 

More from Kasun Ranga Wijeweera

Algorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonAlgorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonKasun Ranga Wijeweera
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmKasun Ranga Wijeweera
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingKasun Ranga Wijeweera
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic ProgrammingKasun Ranga Wijeweera
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingKasun Ranga Wijeweera
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Kasun Ranga Wijeweera
 

More from Kasun Ranga Wijeweera (20)

Decorator Design Pattern in C#
Decorator Design Pattern in C#Decorator Design Pattern in C#
Decorator Design Pattern in C#
 
Singleton Design Pattern in C#
Singleton Design Pattern in C#Singleton Design Pattern in C#
Singleton Design Pattern in C#
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
Algorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonAlgorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a Polygon
 
Geometric Transformations II
Geometric Transformations IIGeometric Transformations II
Geometric Transformations II
 
Geometric Transformations I
Geometric Transformations IGeometric Transformations I
Geometric Transformations I
 
Introduction to Polygons
Introduction to PolygonsIntroduction to Polygons
Introduction to Polygons
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
 
Loops in Visual Basic: Exercises
Loops in Visual Basic: ExercisesLoops in Visual Basic: Exercises
Loops in Visual Basic: Exercises
 
Conditional Logic: Exercises
Conditional Logic: ExercisesConditional Logic: Exercises
Conditional Logic: Exercises
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic Programming
 
CheckBoxes and RadioButtons
CheckBoxes and RadioButtonsCheckBoxes and RadioButtons
CheckBoxes and RadioButtons
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic Programming
 
Loops in Visual Basic Programming
Loops in Visual Basic ProgrammingLoops in Visual Basic Programming
Loops in Visual Basic Programming
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic Programming
 
Assignment for Variables
Assignment for VariablesAssignment for Variables
Assignment for Variables
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]
 
Assignment for Events
Assignment for EventsAssignment for Events
Assignment for Events
 
Mastering Arrays Assignment
Mastering Arrays AssignmentMastering Arrays Assignment
Mastering Arrays Assignment
 

Recently uploaded

Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 

Recently uploaded (20)

Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

Cohen Sutherland Line Clipping Algorithm Example

  • 1. 1 Cohen Sutherland Line Clipping Algorithm Example Author: Kasun Ranga Wijeweera Email: krw19870829@gmail.com Date: 20170821 Note The implementation of the Cohen Sutherland Algorithm in C programming language is available in following link. https://www.academia.edu/2492014/Cohen_Sutherland_Line_Clipping_Algorithm_in_C Problem Demonstrate how Cohen Sutherland algorithm works for the line segment shown in the following figure. Note that it intersects only with RIGHT and TOP boundaries. Answer done = 0, draw = 0; done == 0  TRUE; code1 code = 0000; x < minx  FALSE; x > maxx  FALSE; y < miny  FALSE; (x[0], y[0]) (x[1], y[1]) 0 1
  • 2. 2 y > maxy  TRUE; code = code | TOP_EDGE = 0000 | 1000 = 1000; code1 = 1000; code2 code = 0000; x < minx  FALSE; x > maxx  TRUE; code = code | RIGHT_EDGE = 0000 | 0010 = 0010; y < miny  FALSE; y > maxy  FALSE; code2 = 0010; ACCEPT (code1, code2) = ! (1000 | 0010) = ! 1010  FALSE; REJECT (code1, code2) = 1000 & 0010 = 0000  FALSE; INSIDE (code1) = ! 1000  FALSE; x[0] != x[1]  TRUE; m = (y[1] – y[0])/(x[1] – x[0]); code1 & LEFT_EDGE = 1000 & 0001 = 0000  FALSE; code1 & RIGHT_EDGE = 1000 & 0010 = 0000  FALSE; code1 & BOTTOM_EDGE = 1000 & 0100 = 0000  FALSE; code1 & TOP_EDGE = 1000 & 1000 = 1000  TRUE; x[0] != x[1]  TRUE; x[0] += (maxy – y[0])/m; y[0] = maxy; done == 0  TRUE; code1 code = 0000; x < minx  FALSE; x > maxx  FALSE; y < miny  FALSE; y > maxy  FALSE; code1 = 0000; 0 1
  • 3. 3 code2 code = 0000; x < minx  FALSE; x > maxx  TRUE; code = code | RIGHT_EDGE = 0000 | 0010 = 0010 y < miny  FALSE; y > maxy  FALSE; code2 = 0010; ACCEPT (code1, code2) = ! (0000 | 0010) = ! 0010  FALSE; REJECT (code1, code2) = 0000 & 0010 = 0000  FALSE; INSIDE (code1) = ! 0000  TRUE; swapPts; swapCodes code1 = 0010; code2 = 0000; x[0] != x[1]  TRUE; m = (y[1] – y[0])/(x[1] – x[0]); code1 & LEFT_EDGE = 0010 & 0001 = 0000  FALSE; code1 & RIGHT_EDGE = 0010 & 0010 = 0010  TRUE; y[0] += (maxx – x[0]) * m; x[0] = maxx; 1 0 1 0
  • 4. 4 done == 0  TRUE; code1 code = 0000; x < minx  FALSE; x > maxx  FALSE; y < miny  FALSE; y > maxy  FALSE; code1 = 0000; code2 code = 0000; x < minx  FALSE; x > maxx  FALSE; y < miny  FALSE; y > maxy  FALSE; code2 = 0000; ACCEPT (code1, code2) = ! (0000 | 0000) = ! 0000  TRUE; done = 1, draw = 1; done == 0  FALSE; draw == 1  TRUE; Line segment is drawn.