SlideShare a Scribd company logo
1 of 22
Clipping Algorithms
Cohen & Hodgeman algos
Presenter Rohit Jain
Line Clipping :-
◦ Windowing
◦ Concepts
◦ Clipping
◦ Introduction
◦ Brute Force
◦ Cohen-Sutherland Clipping Algorithm
Area Clipping :-
◦ Sutherland-Hodgman Area Clipping Algorithm
A scene is made up of a collection of objects specified in
world coordinates
World Coordinates
When we display a scene only those objects within a
particular window are displayed
wymax
wymin
wxmin wxmax
Window
World Coordinates
Because drawing things to a display takes time we
clip everything outside the window
wymax
wymin
wxmin wxmax
World Coordinates
Window
For the image below consider which lines and points
should be kept and which ones should be clipped
wymax
wymin
wxmin wxmax
P1
Window
P6
P5
P3
P7
P10
P9
P4
P
2
P
8
Easy - a point (x,y) is not clipped if:
wxmin≤ x ≤ wxmax AND wymin≤ y ≤ wymax
otherwise it is clipped
wymax
wymin
wxmin wxmax
Window
P1
P2
P5
P10
P4
P8
Clipped
Points Within the Window
are Not Clipped
P9
Clipped
Clipped
Clipped
P7
HARDER - EXAMINE THE END-POINTS OF EACH LINE
TO SEE IF THEY ARE IN THE WINDOW OR NOT
Situation Solution Example
Both end-points inside
the window
Don’t clip
One end-point inside
the window, one
outside
Must clip
Both end-points
outside the window
Don’t know!
◦ Don’t clip lines with both
end-points within the
window
◦ For lines with one end-
point inside the window
and one end-point
outside, calculate the
intersection point (using the equation of the line) and
clip from this point out
◦ For lines with both end-points
outside the window test the
line for intersection with all of
the window boundaries, and
clip appropriately
• An efficient line clipping algorithm…
• The key advantage of the algorithm is that it
vastly reduces the number of line intersections
that must be calculated…
Cohen – Sutherland: Clipping Algorithm
0001
0000
Window
0010
0101 0100 0110
World space is divided into regions based on the
window boundaries
◦ Each region has a unique four bit region code
◦ Region codes indicate the position of the regions
with respect to the window
1001 1000 1010
Top below Right Left
3 2 1 0
Region Code Legend
EVERY END-POINT IS LABELLED WITH THE
APPROPRIATE REGION CODE
wymax
wymin
wxmin wxmax
Window
P3 [0001]
P6 [0000]
P5 [0000]
P7 [0001]
P10 [0100]
P9 [0000]
P4 [1000]
P8 [0010]
P12 [0010]
P11 [1010]
P13 [0101] P14 [0110]
Cohen – Sutherland: Lines in the window
• Lines completely contained within the window boundaries have region code [0000] for
both end-points so are not clipped
wxmin wxmax
wymax
wymin
Window
P3 [0001]
P6 [0000]
P5 [0000]
P7 [0001]
P10 [0100]
P9 [0000]
P4 [1000]
P8 [0010]
P12 [0010]
P11 [1010]
P13 [0101] P14 [0110]
Any lines with a common set bit in the region codes of
both end-points can be clipped
– The AND operation can efficiently check this
wymax
wymin
wxmin wxmax
Window
P3 [0001]
P6 [0000]
P5 [0000]
P7 [0001]
P10 [0100]
P9 [0000]
4P [1000]
P8 [0010]
P12 [0010]
11P [1010]
P13 [0101] P14 [0110]
Cohen – Sutherland: Lines Outside the window
Similarly to lines, areas must
be clipped to a window
boundary
Consideration must be taken
as to which portions of the
area must be clipped
A technique for clipping areas developed by
Sutherland & Hodgman
Put simply the polygon is clipped by comparing
it against each boundary in turn
Original Area Clip Left Clip Right Clip Top Clip Bottom
Sutherland – hodgman Area clipping
Algorithm
To clip an area against an individual boundary:
◦ Consider each vertex in turn against the boundary
◦ Vertices inside the boundary are saved for clipping against
the next boundary
◦ Vertices outside the boundary are clipped
◦ If we proceed from a point inside the boundary to one
outside, the intersection of the line with the boundary is
saved
◦ If we cross from the outside to the inside intersection point
and the vertex are saved
Each example shows the point
being processed (P) and the
previous point (S) Saved points
define
area clipped to the boundary in
question
S
Save P
S
Point I
P
S
No Points Saved
P
Save Points I & P
Clipping concave areas can be a little more tricky as often superfluous
lines must be removed
urve
Clipping circles requires more work
• Objects within a scene must be clipped to
display the scene in a window…
• Because there are can be so many objects
clipping must be extremely efficient…
• The Cohen-Sutherland algorithm can be used
for line clipping…
• The Sutherland-Hodgman algorithm can be
used for area clipping…
Sutherlands Cohen and Hodgeman algorithms

More Related Content

What's hot

Unit 3
Unit 3Unit 3
Unit 3ypnrao
 
Perspective projection
Perspective projectionPerspective projection
Perspective projectionPranjalDas25
 
Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clippingArvind Kumar
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clippingMdAlAmin187
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer GraphicsKamal Acharya
 
Scan line method
Scan line methodScan line method
Scan line methodPooja Dixit
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphicsSHIVANI SONI
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithmMani Kanth
 
Back face detection
Back face detectionBack face detection
Back face detectionPooja Dixit
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer GraphicsSanu Philip
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAnuj Modi
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clippingAnkit Garg
 
COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"Ankit Surti
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithmKKARUNKARTHIK
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structurekalyanineve
 

What's hot (20)

Unit 3
Unit 3Unit 3
Unit 3
 
Perspective projection
Perspective projectionPerspective projection
Perspective projection
 
Curve and text clipping
Curve and text clippingCurve and text clipping
Curve and text clipping
 
Spline representations
Spline representationsSpline representations
Spline representations
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
Weiler atherton
Weiler athertonWeiler atherton
Weiler atherton
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Associative memory
Associative memoryAssociative memory
Associative memory
 
Data structure ppt
Data structure pptData structure ppt
Data structure ppt
 
Scan line method
Scan line methodScan line method
Scan line method
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithm
 
Back face detection
Back face detectionBack face detection
Back face detection
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer Graphics
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"COMPUTER GRAPHICS-"Projection"
COMPUTER GRAPHICS-"Projection"
 
Hidden surface removal algorithm
Hidden surface removal algorithmHidden surface removal algorithm
Hidden surface removal algorithm
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 

Similar to Sutherlands Cohen and Hodgeman algorithms

Similar to Sutherlands Cohen and Hodgeman algorithms (20)

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)
 
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
 
Clipping
ClippingClipping
Clipping
 
Windowing clipping
Windowing   clippingWindowing   clipping
Windowing clipping
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Lecture1616_16827_2D Clipping.ppt
Lecture1616_16827_2D Clipping.pptLecture1616_16827_2D Clipping.ppt
Lecture1616_16827_2D Clipping.ppt
 
Clipping
ClippingClipping
Clipping
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clipping
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
Clipping
ClippingClipping
Clipping
 
Clipping
ClippingClipping
Clipping
 
7-Clipping-16 (1).pdf
7-Clipping-16 (1).pdf7-Clipping-16 (1).pdf
7-Clipping-16 (1).pdf
 
Clipping
ClippingClipping
Clipping
 
ch4.pptx
ch4.pptxch4.pptx
ch4.pptx
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Implementation
ImplementationImplementation
Implementation
 
Clipping CG ppt.pptx
Clipping CG ppt.pptxClipping CG ppt.pptx
Clipping CG ppt.pptx
 
Unit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfUnit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdf
 
Clipping in Computer Graphics
Clipping in Computer Graphics Clipping in Computer Graphics
Clipping in Computer Graphics
 

More from Rohit Jain

VR - Virtual reality
VR - Virtual realityVR - Virtual reality
VR - Virtual realityRohit Jain
 
Lifi - Light Fidelity
Lifi - Light FidelityLifi - Light Fidelity
Lifi - Light FidelityRohit Jain
 
File system and Deadlocks
File system and DeadlocksFile system and Deadlocks
File system and DeadlocksRohit Jain
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligenceRohit Jain
 
Introduction about Processors
Introduction about Processors Introduction about Processors
Introduction about Processors Rohit Jain
 
Overview On water
Overview On waterOverview On water
Overview On waterRohit Jain
 
Advance peripheral devices
Advance peripheral devicesAdvance peripheral devices
Advance peripheral devicesRohit Jain
 

More from Rohit Jain (9)

VR - Virtual reality
VR - Virtual realityVR - Virtual reality
VR - Virtual reality
 
Social media
Social mediaSocial media
Social media
 
Lifi - Light Fidelity
Lifi - Light FidelityLifi - Light Fidelity
Lifi - Light Fidelity
 
File system and Deadlocks
File system and DeadlocksFile system and Deadlocks
File system and Deadlocks
 
Artificial intelligence
Artificial intelligenceArtificial intelligence
Artificial intelligence
 
Introduction about Processors
Introduction about Processors Introduction about Processors
Introduction about Processors
 
Overview On water
Overview On waterOverview On water
Overview On water
 
Advance peripheral devices
Advance peripheral devicesAdvance peripheral devices
Advance peripheral devices
 
Big Data
Big DataBig Data
Big Data
 

Recently uploaded

High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 

Recently uploaded (20)

High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 

Sutherlands Cohen and Hodgeman algorithms

  • 1. Clipping Algorithms Cohen & Hodgeman algos Presenter Rohit Jain
  • 2. Line Clipping :- ◦ Windowing ◦ Concepts ◦ Clipping ◦ Introduction ◦ Brute Force ◦ Cohen-Sutherland Clipping Algorithm Area Clipping :- ◦ Sutherland-Hodgman Area Clipping Algorithm
  • 3. A scene is made up of a collection of objects specified in world coordinates World Coordinates
  • 4. When we display a scene only those objects within a particular window are displayed wymax wymin wxmin wxmax Window World Coordinates
  • 5. Because drawing things to a display takes time we clip everything outside the window wymax wymin wxmin wxmax World Coordinates Window
  • 6. For the image below consider which lines and points should be kept and which ones should be clipped wymax wymin wxmin wxmax P1 Window P6 P5 P3 P7 P10 P9 P4 P 2 P 8
  • 7. Easy - a point (x,y) is not clipped if: wxmin≤ x ≤ wxmax AND wymin≤ y ≤ wymax otherwise it is clipped wymax wymin wxmin wxmax Window P1 P2 P5 P10 P4 P8 Clipped Points Within the Window are Not Clipped P9 Clipped Clipped Clipped P7
  • 8. HARDER - EXAMINE THE END-POINTS OF EACH LINE TO SEE IF THEY ARE IN THE WINDOW OR NOT Situation Solution Example Both end-points inside the window Don’t clip One end-point inside the window, one outside Must clip Both end-points outside the window Don’t know!
  • 9. ◦ Don’t clip lines with both end-points within the window ◦ For lines with one end- point inside the window and one end-point outside, calculate the intersection point (using the equation of the line) and clip from this point out
  • 10. ◦ For lines with both end-points outside the window test the line for intersection with all of the window boundaries, and clip appropriately
  • 11. • An efficient line clipping algorithm… • The key advantage of the algorithm is that it vastly reduces the number of line intersections that must be calculated… Cohen – Sutherland: Clipping Algorithm
  • 12. 0001 0000 Window 0010 0101 0100 0110 World space is divided into regions based on the window boundaries ◦ Each region has a unique four bit region code ◦ Region codes indicate the position of the regions with respect to the window 1001 1000 1010 Top below Right Left 3 2 1 0 Region Code Legend
  • 13. EVERY END-POINT IS LABELLED WITH THE APPROPRIATE REGION CODE wymax wymin wxmin wxmax Window P3 [0001] P6 [0000] P5 [0000] P7 [0001] P10 [0100] P9 [0000] P4 [1000] P8 [0010] P12 [0010] P11 [1010] P13 [0101] P14 [0110]
  • 14. Cohen – Sutherland: Lines in the window • Lines completely contained within the window boundaries have region code [0000] for both end-points so are not clipped wxmin wxmax wymax wymin Window P3 [0001] P6 [0000] P5 [0000] P7 [0001] P10 [0100] P9 [0000] P4 [1000] P8 [0010] P12 [0010] P11 [1010] P13 [0101] P14 [0110]
  • 15. Any lines with a common set bit in the region codes of both end-points can be clipped – The AND operation can efficiently check this wymax wymin wxmin wxmax Window P3 [0001] P6 [0000] P5 [0000] P7 [0001] P10 [0100] P9 [0000] 4P [1000] P8 [0010] P12 [0010] 11P [1010] P13 [0101] P14 [0110] Cohen – Sutherland: Lines Outside the window
  • 16. Similarly to lines, areas must be clipped to a window boundary Consideration must be taken as to which portions of the area must be clipped
  • 17. A technique for clipping areas developed by Sutherland & Hodgman Put simply the polygon is clipped by comparing it against each boundary in turn Original Area Clip Left Clip Right Clip Top Clip Bottom Sutherland – hodgman Area clipping Algorithm
  • 18. To clip an area against an individual boundary: ◦ Consider each vertex in turn against the boundary ◦ Vertices inside the boundary are saved for clipping against the next boundary ◦ Vertices outside the boundary are clipped ◦ If we proceed from a point inside the boundary to one outside, the intersection of the line with the boundary is saved ◦ If we cross from the outside to the inside intersection point and the vertex are saved
  • 19. Each example shows the point being processed (P) and the previous point (S) Saved points define area clipped to the boundary in question S Save P S Point I P S No Points Saved P Save Points I & P
  • 20. Clipping concave areas can be a little more tricky as often superfluous lines must be removed urve Clipping circles requires more work
  • 21. • Objects within a scene must be clipped to display the scene in a window… • Because there are can be so many objects clipping must be extremely efficient… • The Cohen-Sutherland algorithm can be used for line clipping… • The Sutherland-Hodgman algorithm can be used for area clipping…