Clipping must account for all of the viewport's boundaries. The Cohen-Sutherland Method is used to clip lines to a viewport. An outcode is determined by the position of an endpoint and is a 4-bit value indicating whether it is outside of the viewport to the top (MSB), bottom, right, or left (LSB) side(s).
The algorithm can be summarized as follows:
The worst case will iterate four times through the algorithm.
Clipping objects other than straight lines is rather difficult and/or computationally expensive. Clipping polygons involves ownership and adjacency problems as well as dealing with gaps formed when mesh surfaces are created and rotated.
Refer to Section 3.9.3 in the text (p 103).
Detailed notes in pdf format (138KB)
Last Updated 8/8/1999
G. Hill Price