Professional Documents
Culture Documents
Two-Dimensional Viewing: Intro. To Computer Graphics Spring 2009, Y. G. Shin
Two-Dimensional Viewing: Intro. To Computer Graphics Spring 2009, Y. G. Shin
Viewing
Chapter 6
Intro. to Computer Graphics
Spring 2009, Y. G. Shin
Viewing Pipeline
Two-Dimensional Viewing
Clipping
Remove portion of line outside viewport or
screen boundaries
Two approaches:
Clip during scan conversion: per-pixel bounds
check, or span endpoint tests.
Clip analytically, then scan-convert the modified
primitive.
Two-Dimensional Clipping
Fill-area clipping
Cohen-Sutherland
Cyrus-beck
Liang-Barsky
Sutherland-Hodgeman
Weiler-Atherton
Curve clipping
Text clipping
Line Clipping
Basic calculations:
Cohen-Sutherland
Line-Clipping Algorithm
1001
1000
1010
View port
0001
0000
0010
0101
0100
0110
Cohen-Sutherland
Line-Clipping Algorithm
Trivially accepted
if (both region codes = 0000)
Trivially rejected
if (AND of region codes 0000)
Cohen-Sutherland
Line-Clipping Algorithm
* Fixed order testing and clipping cause
needless clipping (external intersection)
Cohen-Sutherland
Line-Clipping Algorithm
Cohen-Sutherland
Line-Clipping Algorithm
N i [ P0 PEi ]
Ni D
Ni 0,
D 0 (that is P0 P1),
Ni D 0 (if not, no intersection)
i.e., Ni P0 P1 0 PE
Ni P0 P1 0 PL
tL
Parametric equation of
the line segment
x x1 ( x2 x1 )t x1 dx t
y y1 ( y2 y1 )t y1 dy t
t 0 P( x1 , y1 )
t 1 Q( x2 , y2 )
2.
tT
tB
tT
tR
tL
Clipping
Polygon clipping
Sutherland-Hodgeman Algorithm
Sutherland-Hodgeman Algorithm
Sutherland-Hodgeman Algorithm
How clip?
Texture Clipping
all-or-none text clipping : Using boundary box
for the entire text
all-or-none character clipping : Using boundary
box for each individual
clip individual characters
1.
2.
3.