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

Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
Ankit Garg
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphicanku2266
 
Unit 3
Unit 3Unit 3
Unit 3
ypnrao
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
Punyajoy Saha
 
Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )
Harshana Madusanka Jayamaha
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clippingMohd Arif
 
Curves and surfaces
Curves and surfacesCurves and surfaces
Curves and surfaces
Mohammed Mahmoud
 
fractals
fractalsfractals
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithm
Mani Kanth
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
ShaishavShah8
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
Aparna Joshi
 
Clipping Algorithm In Computer Graphics
Clipping Algorithm In Computer GraphicsClipping Algorithm In Computer Graphics
Clipping Algorithm In Computer Graphicsstudent(MCA)
 
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 clippingavelraj
 
Computer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methodsComputer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methods
Joseph Charles
 
2 d viewing computer graphics
2 d viewing computer graphics2 d viewing computer graphics
2 d viewing computer graphics
KALESHWAR KUMAR
 
Cohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithmCohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithm
Tawfiq Ahmed
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmrajivagarwal23dei
 
Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clipping
Arvind Kumar
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fillwahab13
 

What's hot (20)

Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Visible surface detection in computer graphic
Visible surface detection in computer graphicVisible surface detection in computer graphic
Visible surface detection in computer graphic
 
Unit 3
Unit 3Unit 3
Unit 3
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Curves and surfaces
Curves and surfacesCurves and surfaces
Curves and surfaces
 
fractals
fractalsfractals
fractals
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithm
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Clipping Algorithm In Computer Graphics
Clipping Algorithm In Computer GraphicsClipping Algorithm In Computer Graphics
Clipping Algorithm In Computer Graphics
 
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
 
Computer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methodsComputer Graphics: Visible surface detection methods
Computer Graphics: Visible surface detection methods
 
2 d viewing computer graphics
2 d viewing computer graphics2 d viewing computer graphics
2 d viewing computer graphics
 
Cohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithmCohen sutherland line clipping algorithm
Cohen sutherland line clipping algorithm
 
Clipping
ClippingClipping
Clipping
 
hidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithmhidden surface elimination using z buffer algorithm
hidden surface elimination using z buffer algorithm
 
Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clipping
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fill
 

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 graphics
Ankit Garg
 
Curve clipping
Curve clippingCurve clipping
Curve clipping
Ankit Garg
 
Projection ppt
Projection pptProjection ppt
Projection ppt
Ankit Garg
 
3 d transformations
3 d transformations3 d transformations
3 d transformations
Ankit Garg
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
Ankit Garg
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
Ankit Garg
 
Character generation
Character generationCharacter generation
Character generation
Ankit 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 1
aravindangc
 
Clipping & Rasterization
Clipping & RasterizationClipping & Rasterization
Clipping & Rasterization
Ahmed Daoud
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
Prabin Gautam
 
Cohen sutherland algorithm
Cohen sutherland algorithmCohen sutherland algorithm
Cohen sutherland algorithm
Farwa Ansari
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
Mattupallipardhu
 
Computer Graphics - clipping
Computer Graphics - clippingComputer Graphics - clipping
Computer Graphic - Clipping
Computer Graphic - ClippingComputer Graphic - Clipping
Computer Graphic - Clipping
2013901097
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
ABDULSAMADKAZI
 
Computer graphics
Computer graphicsComputer graphics
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
MdAlAmin187
 
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 derication
Kumar
 
10CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 510CSL67 CG LAB PROGRAM 5
10CSL67 CG LAB PROGRAM 5
Vanishree Arun
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
lokesh503
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
Lokesh Reddy
 
MATLABgraphPlotting.pptx
MATLABgraphPlotting.pptxMATLABgraphPlotting.pptx
MATLABgraphPlotting.pptx
PrabhakarSingh646829
 
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
Ahmed Gamal Abdel Gawad
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsThirunavukarasu Mani
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsKetan Jani
 

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
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
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
 
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 2
Ankit Garg
 
Introduction to computer graphics part 1
Introduction to computer graphics part 1Introduction to computer graphics part 1
Introduction to computer graphics part 1
Ankit Garg
 
Numerical unit 1
Numerical unit 1Numerical unit 1
Numerical unit 1
Ankit Garg
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
Ankit Garg
 
Graphics software standards
Graphics software standardsGraphics software standards
Graphics software standards
Ankit Garg
 
Fractal introduction and applications modified version
Fractal introduction and applications modified versionFractal introduction and applications modified version
Fractal introduction and applications modified version
Ankit Garg
 
Concept of basic illumination model
Concept of basic illumination modelConcept of basic illumination model
Concept of basic illumination model
Ankit Garg
 
Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
Ankit Garg
 
Applications of cg
Applications of cgApplications of cg
Applications of cg
Ankit Garg
 
2 d transformation
2 d transformation2 d transformation
2 d transformation
Ankit Garg
 

More from Ankit Garg (11)

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
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
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

ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 

Recently uploaded (20)

ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 

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).