Exercises Chapter 17


1. Check that all the line equation representations given can all be expressed in terms of each other.

2. Let (x1,y1) to (x2,y2) be an arbitrary line. Let (xmin,xmax,ymin,ymax) represent the boundary of a clipping box. Write out in full the Cohen-Sutherland clipping algorithm. Pay particular attention to the following:
(a) What are the consequences of the boundary itself being taken as "inside" the clipping region or "outside"?
(b) What happens when the line is - vertical, horizontal, coincident with a clipping boundary, a single point?
(c) Consider the case where one end-point of the line is in the region {Left}, and the other is in the region {Bottom} and the line is outside the clipping region. At what stage would such a line be "rejected"?

3. Repeat question 3. for the Liang-Barsky line clipping algorithm.

4. Discuss the time complexity of CS compared to LB.

5. Construct Bresenham's algorithm for all possible cases, rather than only for the set of restrictions discussed.

6. Give a different interpretation to Figure 17.8  - suppose that the centreof the pixel is at the centre of the box. Find the area of the box whichis under the given line. Compare this quantity to the value of ei.

7. Suppose an image is represented by a square two dimensional array of colour values. We wish to display this image rotated by an arbitrary angle (eg,30 degrees). How could the line drawing algorithm of Bresenham be used toaccomplish this?

Back to: Index of Exercises
Back to: Chapter 17

Last modified: Tue Oct 02 22:43:16 GMT Daylight Time 2001