SlideShare a Scribd company logo
1 of 12
Computer Graphics
Line Clipping
• Cohen Sutherland Algorithm (Line)
( x min
, y min
)
( x max
, y max
)
x = x min
x = x max
y = y min
y = y max
( x 1
, y 1
)
clip
rectangle
maxmin
maxmin
yyy
xxx
≤≤
≤≤
For a pointFor a point ((x,yx,y)) to be inside the clip rectangleto be inside the clip rectangle::
Point Clipping
clip
rectangle
( x a , y a )( x b , y b )
( x c , y c ) ( x d , y d )
( x 0
, y 0
)
( x 1
, y 1
)
( x , y )
clip
rectangle
( x a , y a )( x b , y b )
( x c , y c ) ( x d , y d )
( x 0
, y 0
)
( x 1
, y 1
)
( x , y )
( )
( )
1 1 1 1
1 1 1 1
1
: , 0, : ( ) ,
1
: , 0, : ( ) ,
T L
B R
Top x x y y m Left y m x x y m
m
Bottom x x y y m Right y m x x y m
m
= + − ≠ = − + ≠∞
= + − ≠ = − + ≠∞
Line Clipping
0000
1000
0100
1001 1010
0001 0010
0101 0110
clip
rectangle
Region outcodesRegion outcodes
min
max
yy
yy
<
>
:1bit
:0bit
min
max
xx
xx
<
>
:3bit
:2bit
Cohen-Sutherland Algorithm
The Cohen-Sutherland Line-Clipping
Algorithm performs initial tests on a line to
determine whether intersection calculations
can be avoided.
1. First, end-point pairs are checked for trivial
Acceptance.
2. If the line cannot be trivially accepted, region
checks are done for Trivial Rejection.
3. If the line segment can be neither trivially
accepted or rejected, it is divided into two
segments at a clip edge, so that one segment
can be trivially rejected.
These three steps are performed iteratively until
what remains can be trivially accepted or rejected.
Cohen-Sutherland Algorithm
Cohen-Sutherland Algorithm
Algorithm
1-Compute the codes for the Two end points
2-Enter in loop, check if both region codes are
zero(0000 and 0000) put line in display file
for display and exit loop, return
3-If both region codes are not zero then take
logical AND of both codes, check result for
nonzero if so reject line exit loop, return
4-If result is zero then subdivide the line from
intersection point of line and clipping
boundary and repeat step 2,3,4.
5. Special Case when test 4 fails.
clip
rectangle
A
B
C
D
E
An ExampleAn Example
Cohen-Sutherland Algorithm
An ExampleAn Example
clip
rectangle
B
C
D
E
Cohen-Sutherland Algorithm
An ExampleAn Example
clip
rectangle
B
C
D
Cohen-Sutherland Algorithm
An ExampleAn Example
clip
rectangle
B
C
Cohen-Sutherland Algorithm
Q1. Use Cohen Sutherland Algorithm to
clip line p1(70,20) and P2 (100,10)
against window lower left hand corner
(50,10) and upper right hand corner
(80,40).
Q2. Given a clipping window A(20,20),
B(60,20), C(60,40), D(20,40). Using
sutherland cohen algorithm find the
visible portion of line segment joining
the points p(40,80),Q(120,30).
Thank You

More Related Content

What's hot

Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformationAnkit Garg
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clippingMani Kanth
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphicsShaishavShah8
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithmMani Kanth
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removalAnkit Garg
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithmAparna Joshi
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithmMani Kanth
 
Clipping in Computer Graphics
Clipping in Computer Graphics Clipping in Computer Graphics
Clipping in Computer Graphics Barani Tharan
 
Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithmPooja Dixit
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.Mohd Arif
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer GraphicsSanu Philip
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer GraphicsLaxman Puri
 
Composite transformations
Composite transformationsComposite transformations
Composite transformationsMohd Arif
 

What's hot (20)

Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
 
Cohen sutherland line clipping
Cohen sutherland line clippingCohen sutherland line clipping
Cohen sutherland line clipping
 
visible surface detection
visible surface detectionvisible surface detection
visible surface detection
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Mid point circle algorithm
Mid point circle algorithmMid point circle algorithm
Mid point circle algorithm
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )
 
Shading
ShadingShading
Shading
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithm
 
Clipping in Computer Graphics
Clipping in Computer Graphics Clipping in Computer Graphics
Clipping in Computer Graphics
 
Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithm
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Clipping
ClippingClipping
Clipping
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer Graphics
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 
Clipping
ClippingClipping
Clipping
 
Boundary fill algm
Boundary fill algmBoundary fill algm
Boundary fill algm
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
 

Viewers also liked

Digital image processing &amp; computer graphics
Digital image processing &amp; computer graphicsDigital image processing &amp; computer graphics
Digital image processing &amp; computer graphicsAnkit Garg
 
Curve clipping
Curve clippingCurve clipping
Curve clippingAnkit Garg
 
Projection ppt
Projection pptProjection ppt
Projection pptAnkit Garg
 
3 d transformations
3 d transformations3 d transformations
3 d transformationsAnkit Garg
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesAnkit Garg
 
Polygon filling
Polygon fillingPolygon filling
Polygon fillingAnkit Garg
 
Character generation
Character generationCharacter generation
Character generationAnkit Garg
 

Viewers also liked (7)

Digital image processing &amp; computer graphics
Digital image processing &amp; computer graphicsDigital image processing &amp; computer graphics
Digital image processing &amp; computer graphics
 
Curve clipping
Curve clippingCurve clipping
Curve clipping
 
Projection ppt
Projection pptProjection ppt
Projection ppt
 
3 d transformations
3 d transformations3 d transformations
3 d transformations
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Character generation
Character generationCharacter generation
Character generation
 

Similar to Line clipping

Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1aravindangc
 
Clipping & Rasterization
Clipping & RasterizationClipping & Rasterization
Clipping & RasterizationAhmed Daoud
 
Cohen sutherland algorithm
Cohen sutherland algorithmCohen sutherland algorithm
Cohen sutherland algorithmFarwa Ansari
 
Computer Graphic - Clipping
Computer Graphic - ClippingComputer Graphic - Clipping
Computer Graphic - Clipping2013901097
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygonsaa11bb11
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons dericationKumar
 
10CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 510CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 5Vanishree Arun
 
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAScientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAAhmed Gamal Abdel Gawad
 
Cohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithmCohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithmTawfiq Ahmed
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsKetan Jani
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsThirunavukarasu Mani
 

Similar to Line clipping (20)

06 clipping
06 clipping06 clipping
06 clipping
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
Clipping & Rasterization
Clipping & RasterizationClipping & Rasterization
Clipping & Rasterization
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
Cohen sutherland algorithm
Cohen sutherland algorithmCohen sutherland algorithm
Cohen sutherland algorithm
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
Computer Graphics - clipping
Computer Graphics - clippingComputer Graphics - clipping
Computer Graphics - clipping
 
Computer Graphic - Clipping
Computer Graphic - ClippingComputer Graphic - Clipping
Computer Graphic - Clipping
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygons
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
 
10CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 510CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 5
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
MATLABgraphPlotting.pptx
MATLABgraphPlotting.pptxMATLABgraphPlotting.pptx
MATLABgraphPlotting.pptx
 
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAScientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
 
Cohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithmCohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithm
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 

More from Ankit Garg

Introduction to computer graphics part 2
Introduction to computer graphics part 2Introduction to computer graphics part 2
Introduction to computer graphics part 2Ankit Garg
 
Introduction to computer graphics part 1
Introduction to computer graphics part 1Introduction to computer graphics part 1
Introduction to computer graphics part 1Ankit Garg
 
Numerical unit 1
Numerical unit 1Numerical unit 1
Numerical unit 1Ankit Garg
 
Graphics software standards
Graphics software standardsGraphics software standards
Graphics software standardsAnkit Garg
 
Fractal introduction and applications modified version
Fractal introduction and applications modified versionFractal introduction and applications modified version
Fractal introduction and applications modified versionAnkit Garg
 
Concept of basic illumination model
Concept of basic illumination modelConcept of basic illumination model
Concept of basic illumination modelAnkit Garg
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithmAnkit Garg
 
Applications of cg
Applications of cgApplications of cg
Applications of cgAnkit Garg
 
2 d transformation
2 d transformation2 d transformation
2 d transformationAnkit Garg
 

More from Ankit Garg (10)

Introduction to computer graphics part 2
Introduction to computer graphics part 2Introduction to computer graphics part 2
Introduction to computer graphics part 2
 
Introduction to computer graphics part 1
Introduction to computer graphics part 1Introduction to computer graphics part 1
Introduction to computer graphics part 1
 
Unit 1
Unit 1Unit 1
Unit 1
 
Numerical unit 1
Numerical unit 1Numerical unit 1
Numerical unit 1
 
Graphics software standards
Graphics software standardsGraphics software standards
Graphics software standards
 
Fractal introduction and applications modified version
Fractal introduction and applications modified versionFractal introduction and applications modified version
Fractal introduction and applications modified version
 
Concept of basic illumination model
Concept of basic illumination modelConcept of basic illumination model
Concept of basic illumination model
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
 
Applications of cg
Applications of cgApplications of cg
Applications of cg
 
2 d transformation
2 d transformation2 d transformation
2 d transformation
 

Recently uploaded

Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 

Recently uploaded (20)

Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 

Line clipping

  • 1. Computer Graphics Line Clipping • Cohen Sutherland Algorithm (Line)
  • 2. ( x min , y min ) ( x max , y max ) x = x min x = x max y = y min y = y max ( x 1 , y 1 ) clip rectangle maxmin maxmin yyy xxx ≤≤ ≤≤ For a pointFor a point ((x,yx,y)) to be inside the clip rectangleto be inside the clip rectangle:: Point Clipping
  • 3. clip rectangle ( x a , y a )( x b , y b ) ( x c , y c ) ( x d , y d ) ( x 0 , y 0 ) ( x 1 , y 1 ) ( x , y ) clip rectangle ( x a , y a )( x b , y b ) ( x c , y c ) ( x d , y d ) ( x 0 , y 0 ) ( x 1 , y 1 ) ( x , y ) ( ) ( ) 1 1 1 1 1 1 1 1 1 : , 0, : ( ) , 1 : , 0, : ( ) , T L B R Top x x y y m Left y m x x y m m Bottom x x y y m Right y m x x y m m = + − ≠ = − + ≠∞ = + − ≠ = − + ≠∞ Line Clipping
  • 4. 0000 1000 0100 1001 1010 0001 0010 0101 0110 clip rectangle Region outcodesRegion outcodes min max yy yy < > :1bit :0bit min max xx xx < > :3bit :2bit Cohen-Sutherland Algorithm
  • 5. The Cohen-Sutherland Line-Clipping Algorithm performs initial tests on a line to determine whether intersection calculations can be avoided. 1. First, end-point pairs are checked for trivial Acceptance. 2. If the line cannot be trivially accepted, region checks are done for Trivial Rejection. 3. If the line segment can be neither trivially accepted or rejected, it is divided into two segments at a clip edge, so that one segment can be trivially rejected. These three steps are performed iteratively until what remains can be trivially accepted or rejected. Cohen-Sutherland Algorithm
  • 6. Cohen-Sutherland Algorithm Algorithm 1-Compute the codes for the Two end points 2-Enter in loop, check if both region codes are zero(0000 and 0000) put line in display file for display and exit loop, return 3-If both region codes are not zero then take logical AND of both codes, check result for nonzero if so reject line exit loop, return 4-If result is zero then subdivide the line from intersection point of line and clipping boundary and repeat step 2,3,4. 5. Special Case when test 4 fails.
  • 11. Q1. Use Cohen Sutherland Algorithm to clip line p1(70,20) and P2 (100,10) against window lower left hand corner (50,10) and upper right hand corner (80,40). Q2. Given a clipping window A(20,20), B(60,20), C(60,40), D(20,40). Using sutherland cohen algorithm find the visible portion of line segment joining the points p(40,80),Q(120,30).