Clipping
Before clipping…
After clipping…
Point Clipping Display P = (x, y) if xw min <= x <= xw max yw min <= y <= yw max
Line Clipping Display P = (x, y) if xw min <= x <= xw max yw min <= y <= yw max Line Clipping If both points lie inside the window display segment
Line Clipping (cont) Display P = (x, y) if xw min <= x <= xw max yw min <= y <= yw max Line Clipping If both points lie inside the window display segment If both points lie outside the same boundary discard segment
Line Clipping (cont) Display P = (x, y) if xw min <= x <= xw max yw min <= y <= yw max If both points lie inside the window display segment If both points lie outside the same boundary discard segment If segment crosses one or more boundaries calculate intersections with boundaries x = x 1 + u(x 2 - x 1 ) y = y 1 + u(y 2 - y 1 ) if 0 <= u <= 1 display section within boundary else discard segment
Cohen - Sutherland Line Clipping 4 bit clip code: A B R L
Cohen - Sutherland Line Clipping (cont) 4 bit clip code: A B R L A = y > yw max B = y < yw min R = x > xw max L = x < xw min
4 bit clip code: A B R L A = y > yw max B = y < yw min R = x > xw max L = x < xw min Calculate clip code P 1 = P 2 = => accept segment P 1 P 2 (trivial accept since both end points are in the window
4 bit clip code: A B R L A = y > yw max B = y < yw min R = x > xw max L = x < xw min Calculate clip code P3 = P4 = => Reject segment P3 P4