SlideShare a Scribd company logo
1 of 30
Windowing and Clipping
 Windowing Concepts
 Introduction to Clipping
 Point Clipping
 Line Clipping
 Area Clipping
2
3
Window
Image Space
Viewport
Information
outside
the viewport is
clipped away
• World Coordinate System (Object Space) -
Representation of an object measured in some
physical units.
• Window - The rectangle defining the part of the
world we wish to display.
• Image Coordinate System (Image Space) - The
space within the image is displayed.
• Viewport - The rectangle area in image space
where the image from the window will appear.
• Viewing Transformation - The process of going
from a window in world coordinates to a
viewport in image coordinates.
4
5
• In 2D, a ‘world’ consists of an infinite plane,
defined in ‘world’ coordinates, i.e metres,
angstroms etc.
• We need to pick an area of the 2D plane to view,
referred to as the ‘window’.
• On our display device, need to allocate an area for
display, referred to as the ‘viewport’ in device
specific coordinates.
– Clip objects outside of window.
– Translate to fit viewport.
– Scale to device coordinates.
6
Choose Window in
World Coordinates
Clip to size
of Window
Translate to
origin
Scale to size of Viewport Translate to proper position in
image
 Any procedure that identifies those portions of a
picture that are either inside or outside of a
specified region is referred to as a clipping
algorithm or clipping.
7
World Coordinates
8
• When we display a scene only those objects
within a particular window are displayed.
wymax
wymin
wxmin wxmax
Window or Clipping Region
World Coordinates
9
Because drawing things to a display takes time
we clip everything outside the window.
wymax
wymin
wxmin wxmax
Window or Clipping Region
World Coordinates
 For the image below consider which lines and
points should be kept and which ones should be
clipped.
10
wymax
wymin
wxmin wxmax
Window
P1
P2
P3
P6
P5
P7
P10
P9
P4
P8
 Easy - a point (x,y) is not clipped if:
wxmin ≤ x ≤ wxmax AND wymin ≤ y ≤ wymax
11
wymax
wymin
wxmin wxmax
Window
P1
P2
P5
P7
P10
P9
P4
P8
Clipped
Points Within the
Window are Not Clipped
Clipped
Clipped
Clipped
 Harder - examine the end-points of each line to
see if they are in the window or not.
12
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!
Brute force line clipping can be performed as follows:
 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.
13
14
– For lines with both end-
points outside the
window test the line for
intersection with all of
the window boundaries,
and clip appropriately.
However, calculating line intersections is
computationally expensive.
Because a scene can contain so many lines,
the brute force approach to clipping is much
too slow.
15
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.
Dr. Ivan E. Sutherland
c o - d e v e l o p e d t h e
C o h e n - S u t h e r l a n d
clipping algorithm.
Sutherland is a graphics
giant and includes
a m o n g s t h i s
a c h i e v e m e n t s t h e
invention of the head
Cohen is something of a mystery – can
anybody find out who he was?
Algorithm
Step 1 − Assign a region code for each endpoints.
Step 2 − If both endpoints have a region code 0000 then accept this line.
Step 3 − Else, perform the logical AND operation for both region codes.
Step 3.1 − If the result is not 0000, then reject the line.
Step 3.2 − Else you need clipping.
Step 3.2.1 − Choose an endpoint of the line that is outside the
window.
Step 3.2.2 − Find the intersection point at the window boundary
(base on region code).
Step 3.2.3 − Replace endpoint with the intersection point and
update the region code.
Step 3.2.4 − Repeat step 2 until we find a clipped line either
trivially accepted or trivially rejected.
Step 4 − Repeat step 1 for other lines.
16
 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.
17
above below right left
3 2 1 0
Region Code Legend
1001 1000 1010
0001
0000
Window
0010
0101 0100 0110
18
• 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]
19
Lines completely contained within the window
boundaries have region code [0000] for both end-
points so are not clipped. The OR operation can
efficiently check this.
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]
20
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]
P4 [1000]
P8 [0010]
P12 [0010]
P11 [1010]
P13 [0101] P14 [0110]
 Lines that cannot be identified as completely inside
or outside the window may or may not cross the
window interior.
 These lines are processed as follows:
 Compare an end-point outside the window to a
boundary (choose any order in which to consider
boundaries e.g. left, right, bottom, top) and
determine how much can be discarded.
 If the remainder of the line is entirely inside or
outside the window, retain it or clip it respectively.
21
 Otherwise, compare the remainder of the line against the
other window boundaries.
 Continue until the line is either discarded or a segment
inside the window is found.
 We can use the region codes to determine which
window boundaries should be considered for
intersection.
 To check if a line crosses a particular boundary we
compare the appropriate bits in the region codes of its
end-points.
 If one of these is a 1 and the other is a 0 then the line
crosses the boundary.
22
 Intersection points with the window boundaries are
calculated using the line-equation parameters.
 Consider a line with the end-points (x1, y1) and (x2, y2)
 The y-coordinate of an intersection with a vertical
window boundary can be calculated using:
y = y1 + m (xboundary - x1)
where xboundary can be set to either wxmin or wxmax
23
 The x-coordinate of an intersection with a
horizontal window boundary can be calculated
using:
x = x1 + (yboundary - y1) / m
where yboundary can be set to either wymin or wymax
 m is the slope of the line in question and can be
calculated as
m = (y2 - y1) / (x2 - x1)
24
 Polygons can be clipped against each edge of the
window one edge at a time. Window/edge
intersections, if any, are easy to find since the X or
Y coordinates are already known.
 Vertices which are kept after clipping against one
window edge are saved for clipping against the
remaining edges. Note that the number of vertices
usually changes and will often increase.
25
 A technique for clipping areas
developed by Sutherland &
Hodgman.
 Put simply the polygon is clipped
by comparing it against each
boundary in turn.
26
Sutherland
turns up
again. This
time with
Gary Hodgman
with whom he
worked at the first
ever graphics
company Evans &
Sutherland
Original Area Clip Left Clip Right Clip Top Clip Bottom
 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.
27
 Each example shows
the point being
processed (P) and the
previous point (S).
 Saved points define
area clipped to the
boundary in question.
28
S
P
Save Point P
S
P
Save Point I
I
P
S
No Points Saved
S
P
Save Points I & P
I
 Instead of always
proceeding around the
polygon edges as vertices are
processed, we sometime
want to follow window
boundary.
 This algorithm is used for
clipping concave polygons.
 V1, V2, V3, V4, V5 are the
vertices of the polygon.
 C1, C2, C3, C4 are the
vertices of the clip polygon
 I1, I2, I3, I4 are the
intersection points of 29
Thank You !!!
30

More Related Content

What's hot

What's hot (20)

The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
 
Three dimensional concepts - Computer Graphics
Three dimensional concepts - Computer GraphicsThree dimensional concepts - Computer Graphics
Three dimensional concepts - Computer Graphics
 
3 d viewing
3 d viewing3 d viewing
3 d viewing
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
Depth Buffer Method
Depth Buffer MethodDepth Buffer Method
Depth Buffer Method
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Clipping
ClippingClipping
Clipping
 
Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
 
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmCohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
 
Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
 
Overview of the graphics system
Overview of the graphics systemOverview of the graphics system
Overview of the graphics system
 
Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
 
Raster scan system & random scan system
Raster scan system & random scan systemRaster scan system & random scan system
Raster scan system & random scan system
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPTHOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
 
Quadric surfaces
Quadric surfacesQuadric surfaces
Quadric surfaces
 
Z buffer
Z bufferZ buffer
Z buffer
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 

Similar to Windowing clipping

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
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clippingmajicyoung
 
Unit 3
Unit 3Unit 3
Unit 3ypnrao
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphicsShaishavShah8
 
Lecture1616_16827_2D Clipping.ppt
Lecture1616_16827_2D Clipping.pptLecture1616_16827_2D Clipping.ppt
Lecture1616_16827_2D Clipping.pptGaganvirKaur
 
UNIT_3-Two-Dimensional-Geometric-Transformations.pdf
UNIT_3-Two-Dimensional-Geometric-Transformations.pdfUNIT_3-Two-Dimensional-Geometric-Transformations.pdf
UNIT_3-Two-Dimensional-Geometric-Transformations.pdfVivekKumar148171
 
Clipping CG ppt.pptx
Clipping CG ppt.pptxClipping CG ppt.pptx
Clipping CG ppt.pptxAamirSheikh49
 
Sutherlands Cohen and Hodgeman algorithms
Sutherlands Cohen and Hodgeman algorithmsSutherlands Cohen and Hodgeman algorithms
Sutherlands Cohen and Hodgeman algorithmsRohit Jain
 
Unit2- line clipping.pptx
Unit2- line clipping.pptxUnit2- line clipping.pptx
Unit2- line clipping.pptxRYZEN14
 
Bhavesh window clipping slidshare
Bhavesh window clipping slidshareBhavesh window clipping slidshare
Bhavesh window clipping slidshareBhavesh Panchal
 

Similar to Windowing clipping (20)

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
 
line clipping
line clipping line clipping
line clipping
 
Clipping
ClippingClipping
Clipping
 
Clipping
ClippingClipping
Clipping
 
Lect 5 2d clipping
Lect 5 2d clippingLect 5 2d clipping
Lect 5 2d clipping
 
Unit 4 notes
Unit 4 notesUnit 4 notes
Unit 4 notes
 
Unit 3
Unit 3Unit 3
Unit 3
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
Lecture1616_16827_2D Clipping.ppt
Lecture1616_16827_2D Clipping.pptLecture1616_16827_2D Clipping.ppt
Lecture1616_16827_2D Clipping.ppt
 
UNIT_3-Two-Dimensional-Geometric-Transformations.pdf
UNIT_3-Two-Dimensional-Geometric-Transformations.pdfUNIT_3-Two-Dimensional-Geometric-Transformations.pdf
UNIT_3-Two-Dimensional-Geometric-Transformations.pdf
 
ohu.pptx
ohu.pptxohu.pptx
ohu.pptx
 
Clipping
ClippingClipping
Clipping
 
Clipping CG ppt.pptx
Clipping CG ppt.pptxClipping CG ppt.pptx
Clipping CG ppt.pptx
 
Sutherlands Cohen and Hodgeman algorithms
Sutherlands Cohen and Hodgeman algorithmsSutherlands Cohen and Hodgeman algorithms
Sutherlands Cohen and Hodgeman algorithms
 
Unit2- line clipping.pptx
Unit2- line clipping.pptxUnit2- line clipping.pptx
Unit2- line clipping.pptx
 
kgv.pptx
kgv.pptxkgv.pptx
kgv.pptx
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Clipping 22
Clipping 22Clipping 22
Clipping 22
 
Bhavesh window clipping slidshare
Bhavesh window clipping slidshareBhavesh window clipping slidshare
Bhavesh window clipping slidshare
 

More from Shweta Shah

CG_Unit1_SShah.pptx
CG_Unit1_SShah.pptxCG_Unit1_SShah.pptx
CG_Unit1_SShah.pptxShweta Shah
 
ConsTRUCTION AND DESTRUCTION
ConsTRUCTION AND DESTRUCTIONConsTRUCTION AND DESTRUCTION
ConsTRUCTION AND DESTRUCTIONShweta Shah
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++Shweta Shah
 
Class objects oopm
Class objects oopmClass objects oopm
Class objects oopmShweta Shah
 
Virtual function and abstract class
Virtual function and abstract classVirtual function and abstract class
Virtual function and abstract classShweta Shah
 
Introduction to computer graphics and multimedia
Introduction to computer graphics and multimediaIntroduction to computer graphics and multimedia
Introduction to computer graphics and multimediaShweta Shah
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating SystemsShweta Shah
 

More from Shweta Shah (7)

CG_Unit1_SShah.pptx
CG_Unit1_SShah.pptxCG_Unit1_SShah.pptx
CG_Unit1_SShah.pptx
 
ConsTRUCTION AND DESTRUCTION
ConsTRUCTION AND DESTRUCTIONConsTRUCTION AND DESTRUCTION
ConsTRUCTION AND DESTRUCTION
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Class objects oopm
Class objects oopmClass objects oopm
Class objects oopm
 
Virtual function and abstract class
Virtual function and abstract classVirtual function and abstract class
Virtual function and abstract class
 
Introduction to computer graphics and multimedia
Introduction to computer graphics and multimediaIntroduction to computer graphics and multimedia
Introduction to computer graphics and multimedia
 
Introduction to Operating Systems
Introduction to Operating SystemsIntroduction to Operating Systems
Introduction to Operating Systems
 

Recently uploaded

Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
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
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
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
 
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
 
(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
 
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
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
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
 

Recently uploaded (20)

Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
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
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
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...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
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
 
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...
 
(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
 
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
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
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
 

Windowing clipping

  • 2.  Windowing Concepts  Introduction to Clipping  Point Clipping  Line Clipping  Area Clipping 2
  • 4. • World Coordinate System (Object Space) - Representation of an object measured in some physical units. • Window - The rectangle defining the part of the world we wish to display. • Image Coordinate System (Image Space) - The space within the image is displayed. • Viewport - The rectangle area in image space where the image from the window will appear. • Viewing Transformation - The process of going from a window in world coordinates to a viewport in image coordinates. 4
  • 5. 5 • In 2D, a ‘world’ consists of an infinite plane, defined in ‘world’ coordinates, i.e metres, angstroms etc. • We need to pick an area of the 2D plane to view, referred to as the ‘window’. • On our display device, need to allocate an area for display, referred to as the ‘viewport’ in device specific coordinates. – Clip objects outside of window. – Translate to fit viewport. – Scale to device coordinates.
  • 6. 6 Choose Window in World Coordinates Clip to size of Window Translate to origin Scale to size of Viewport Translate to proper position in image
  • 7.  Any procedure that identifies those portions of a picture that are either inside or outside of a specified region is referred to as a clipping algorithm or clipping. 7 World Coordinates
  • 8. 8 • When we display a scene only those objects within a particular window are displayed. wymax wymin wxmin wxmax Window or Clipping Region World Coordinates
  • 9. 9 Because drawing things to a display takes time we clip everything outside the window. wymax wymin wxmin wxmax Window or Clipping Region World Coordinates
  • 10.  For the image below consider which lines and points should be kept and which ones should be clipped. 10 wymax wymin wxmin wxmax Window P1 P2 P3 P6 P5 P7 P10 P9 P4 P8
  • 11.  Easy - a point (x,y) is not clipped if: wxmin ≤ x ≤ wxmax AND wymin ≤ y ≤ wymax 11 wymax wymin wxmin wxmax Window P1 P2 P5 P7 P10 P9 P4 P8 Clipped Points Within the Window are Not Clipped Clipped Clipped Clipped
  • 12.  Harder - examine the end-points of each line to see if they are in the window or not. 12 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!
  • 13. Brute force line clipping can be performed as follows:  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. 13
  • 14. 14 – For lines with both end- points outside the window test the line for intersection with all of the window boundaries, and clip appropriately. However, calculating line intersections is computationally expensive. Because a scene can contain so many lines, the brute force approach to clipping is much too slow.
  • 15. 15 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. Dr. Ivan E. Sutherland c o - d e v e l o p e d t h e C o h e n - S u t h e r l a n d clipping algorithm. Sutherland is a graphics giant and includes a m o n g s t h i s a c h i e v e m e n t s t h e invention of the head Cohen is something of a mystery – can anybody find out who he was?
  • 16. Algorithm Step 1 − Assign a region code for each endpoints. Step 2 − If both endpoints have a region code 0000 then accept this line. Step 3 − Else, perform the logical AND operation for both region codes. Step 3.1 − If the result is not 0000, then reject the line. Step 3.2 − Else you need clipping. Step 3.2.1 − Choose an endpoint of the line that is outside the window. Step 3.2.2 − Find the intersection point at the window boundary (base on region code). Step 3.2.3 − Replace endpoint with the intersection point and update the region code. Step 3.2.4 − Repeat step 2 until we find a clipped line either trivially accepted or trivially rejected. Step 4 − Repeat step 1 for other lines. 16
  • 17.  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. 17 above below right left 3 2 1 0 Region Code Legend 1001 1000 1010 0001 0000 Window 0010 0101 0100 0110
  • 18. 18 • 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]
  • 19. 19 Lines completely contained within the window boundaries have region code [0000] for both end- points so are not clipped. The OR operation can efficiently check this. 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]
  • 20. 20 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] P4 [1000] P8 [0010] P12 [0010] P11 [1010] P13 [0101] P14 [0110]
  • 21.  Lines that cannot be identified as completely inside or outside the window may or may not cross the window interior.  These lines are processed as follows:  Compare an end-point outside the window to a boundary (choose any order in which to consider boundaries e.g. left, right, bottom, top) and determine how much can be discarded.  If the remainder of the line is entirely inside or outside the window, retain it or clip it respectively. 21
  • 22.  Otherwise, compare the remainder of the line against the other window boundaries.  Continue until the line is either discarded or a segment inside the window is found.  We can use the region codes to determine which window boundaries should be considered for intersection.  To check if a line crosses a particular boundary we compare the appropriate bits in the region codes of its end-points.  If one of these is a 1 and the other is a 0 then the line crosses the boundary. 22
  • 23.  Intersection points with the window boundaries are calculated using the line-equation parameters.  Consider a line with the end-points (x1, y1) and (x2, y2)  The y-coordinate of an intersection with a vertical window boundary can be calculated using: y = y1 + m (xboundary - x1) where xboundary can be set to either wxmin or wxmax 23
  • 24.  The x-coordinate of an intersection with a horizontal window boundary can be calculated using: x = x1 + (yboundary - y1) / m where yboundary can be set to either wymin or wymax  m is the slope of the line in question and can be calculated as m = (y2 - y1) / (x2 - x1) 24
  • 25.  Polygons can be clipped against each edge of the window one edge at a time. Window/edge intersections, if any, are easy to find since the X or Y coordinates are already known.  Vertices which are kept after clipping against one window edge are saved for clipping against the remaining edges. Note that the number of vertices usually changes and will often increase. 25
  • 26.  A technique for clipping areas developed by Sutherland & Hodgman.  Put simply the polygon is clipped by comparing it against each boundary in turn. 26 Sutherland turns up again. This time with Gary Hodgman with whom he worked at the first ever graphics company Evans & Sutherland Original Area Clip Left Clip Right Clip Top Clip Bottom
  • 27.  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. 27
  • 28.  Each example shows the point being processed (P) and the previous point (S).  Saved points define area clipped to the boundary in question. 28 S P Save Point P S P Save Point I I P S No Points Saved S P Save Points I & P I
  • 29.  Instead of always proceeding around the polygon edges as vertices are processed, we sometime want to follow window boundary.  This algorithm is used for clipping concave polygons.  V1, V2, V3, V4, V5 are the vertices of the polygon.  C1, C2, C3, C4 are the vertices of the clip polygon  I1, I2, I3, I4 are the intersection points of 29