Professional Documents
Culture Documents
Clipping On A Raster Display: 168 471 Computer Graphics, KKU. Lecture 8 1
Clipping On A Raster Display: 168 471 Computer Graphics, KKU. Lecture 8 1
outcode CompOutCode(
double x, double y, double xmin, double xmax, double ymin, double ymax)
{
outcode code = 0;
if ( y > ymax )
code |= TOP;
else if ( y < ymin )
code |= BOTTOM;
if ( x > xmax )
code |= RIGHT;
else if ( x < xmin )
code |= LEFT;
return code;
}
168 471 Computer Graphics, KKU. Lecture 8 9
Cohen-Sutherland Procedures
N i [ P(t ) PEi ] 0
N i [ P0 ( P1 P0 )t PEi ] 0
N i [ P0 PEi ] N i [ P1 P0 ]t 0
N i [ P0 PEi ]
t
N i D
where D ( P1 P0 )
Ni D 0 PE (angle 90)
Ni D 0 PL(angle 90)
Polygon clipping, edge by edge. (a) Before clipping. (b) Clip on right.
(c) Clip on bottom. (d) Clip on left. (e) Clip on top; polygon is fully
clipped
168 471 Computer Graphics, KKU. Lecture 8 21