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

Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithmAparna Joshi
 
Hidden surfaces
Hidden surfacesHidden surfaces
Hidden surfacesMohd Arif
 
Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...Mani Kanth
 
Unit 3
Unit 3Unit 3
Unit 3ypnrao
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformationAnkit Garg
 
Quadric surfaces
Quadric surfacesQuadric surfaces
Quadric surfacesAnkur Kumar
 
Visual surface detection i
Visual surface detection   iVisual surface detection   i
Visual surface detection ielaya1984
 
Visible Surface Detection
Visible Surface DetectionVisible Surface Detection
Visible Surface DetectionAmitBiswas99
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformationSelvakumar Gna
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithmsKumar
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clippingMohd Arif
 
Windowing and clipping final1
Windowing and clipping final1Windowing and clipping final1
Windowing and clipping final1kparthjadhav
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clippingMdAlAmin187
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphicsSHIVANI SONI
 
Computer graphics - colour crt and flat-panel displays
Computer graphics - colour crt and flat-panel displaysComputer graphics - colour crt and flat-panel displays
Computer graphics - colour crt and flat-panel displaysVishnupriya T H
 
Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewingMohd Arif
 

What's hot (20)

Curve clipping
Curve clippingCurve clipping
Curve clipping
 
Polygon filling algorithm
Polygon filling algorithmPolygon filling algorithm
Polygon filling algorithm
 
Clipping
ClippingClipping
Clipping
 
Hidden surfaces
Hidden surfacesHidden surfaces
Hidden surfaces
 
Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...Window to viewport transformation&matrix representation of homogeneous co...
Window to viewport transformation&matrix representation of homogeneous co...
 
Unit 3
Unit 3Unit 3
Unit 3
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
 
Quadric surfaces
Quadric surfacesQuadric surfaces
Quadric surfaces
 
Video display devices
Video display devicesVideo display devices
Video display devices
 
Visual surface detection i
Visual surface detection   iVisual surface detection   i
Visual surface detection i
 
Visible Surface Detection
Visible Surface DetectionVisible Surface Detection
Visible Surface Detection
 
Clipping
ClippingClipping
Clipping
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformation
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithms
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Windowing and clipping final1
Windowing and clipping final1Windowing and clipping final1
Windowing and clipping final1
 
2D viewing & clipping
2D viewing & clipping2D viewing & clipping
2D viewing & clipping
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
 
Computer graphics - colour crt and flat-panel displays
Computer graphics - colour crt and flat-panel displaysComputer graphics - colour crt and flat-panel displays
Computer graphics - colour crt and flat-panel displays
 
Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
 

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
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphicsShaishavShah8
 
Unit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfUnit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfAmol Gaikwad
 
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
 

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
 
Clipping computer graphics
Clipping  computer graphicsClipping  computer graphics
Clipping computer graphics
 
99995327.ppt
99995327.ppt99995327.ppt
99995327.ppt
 
Unit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdfUnit-IV Windowing and Clipping.pdf
Unit-IV Windowing and Clipping.pdf
 
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
 
Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )Clipping ( Cohen-Sutherland Algorithm )
Clipping ( Cohen-Sutherland Algorithm )
 

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

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
 
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
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
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
 
(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
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
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
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
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
 
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
 
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
 
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
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 

Recently uploaded (20)

Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
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
 
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...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
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
 
(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...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
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
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
★ 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
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
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...
 
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
 
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
 
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
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 

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