View & Clipping
View & Clipping
BY:AKANKSHA YADAV
FOET,LU
SUBJECT:COMPUTER GRAPHICS
BRANCH/YEAR:MCA/2ND.
2
of
44
Contents
Windowing Concepts
Clipping
– Introduction
– Brute Force
– Cohen-Sutherland Clipping Algorithm
Area Clipping
– Sutherland-Hodgman Area Clipping
Algorithm
3
of
44
Windowing I
A scene is made up of a collection of objects
specified in world coordinates
World Coordinates
4
of
44
Windowing II
When we display a scene only those objects
within a particular window are displayed
Window
wymax
wymin
wxmin wxmax
World Coordinates
5
of
44
Windowing III
Because drawing things to a display takes
time we clip everything outside the window
Window
wymax
wymin
wxmin wxmax
World Coordinates
6
of
44
Window P2
wymax
P6
P3
P1
P7 P5
P9
P8
wymin
P10
wxmin wxmax
13
of
44
Point Clipping
Easy - a point (x,y) is not clipped if:
wxmin ≤ x ≤ wxmax AND wymin ≤ y ≤ wymax
otherwise it is clipped
P4 Clipped
Clipped
Window P2
wymax
Clipped
P5
P1
P7 Points Within the Window
are Not Clipped
P9 P8
wymin
Clipped P10
wxmin wxmax
14
of
44
Line Clipping
Harder - examine the end-points of each line
to see if they are in the window or not
Situation Solution Example
Both end-points
Don’t know!
outside the window
15
of
44
Brute Force Line Clipping
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
16
of
44
Brute Force Line Clipping (cont…)
– For lines with both end-
points outside the
window test the line for
intersection with all of
the window boundaries,
and clip appropriately
Window
wymax
P6 [0000]
P3 [0001]
P5 [0000] P12 [0010]
P7 [0001]
P9 [0000] P8 [0010]
wymin
P10 [0100]
P13 [0101] P14 [0110]
wxmin wxmax
22
of
44
Cohen-Sutherland: Lines In The Window
Window
wymax
P6 [0000]
P3 [0001]
P5 [0000] P12 [0010]
P7 [0001]
P9 [0000] P8 [0010]
wymin
P10 [0100]
P13 [0101] P14 [0110]
wxmin wxmax
23
of
Cohen-Sutherland: Lines Outside The
44 Window
Any lines with 1 in the same bit position for both end-points
is completely outside and must be clipped.
For example a line with 1010 code for one endpoint and
0010 for the other (line P11, P12) is completely to the right
of the clipping window.
P11 [1010]
P4 [1000]
Window
wymax
P6 [0000]
P3 [0001]
P5 [0000] P12 [0010]
P7 [0001]
P9 [0000] P8 [0010]
wymin
P10 [0100]
P13 [0101] P14 [0110]
wxmin wxmax
24
of
44
Cohen-Sutherland: Inside/Outside Lines
boundary P [0100]
10