Computer Graphics 1996

Exercises on Viewing and Clipping

Answers to some of these exercises are available.

Note: Questions that have a * besides them are more difficult and should be considered at some time, but not necessarily now.

1. Find the implicit, explicit and parametric equations of the line that passes through two points (4,2) and (6,8).

2. Find only the implicit equation of the line that passes through (5,1) and (10,6).

(a) By making use of the parametric equation of the line in question 1, find its intersection point with the line in this question.

(b) Two distinct lines will always intersect (unless they are parallel). However, two line segments might not intersect. Does the line segment of 1. intersect the line of this question?

3. Suppose (x1,y1) and (x2,y2) defines a line segment. Consider the left boundary of the clipping region x = Wxmin.

(a) Specify the visible side of the boundary.

(b) Construct a test to find whether both end-points are on the invisible, or both on the visible side of the boundary, or whether one point is one side and the other is the opposite side.

(c) Find the intersection of the the line segment with the boundary, if any.

4. Suppose the window is defined by 1.0 <=x <= 2.0, 0.1 <=y <= 1.1, and the viewport is 0 <= x <= 200, 100 <=y <= 300. Find the point in the viewport corresponding to the point (1.1,0.8) in the window. In general write down the function wc2dc for this particular arrangement.

5. A trapezium is a four-sided shape, with top and bottom sides horizontal. For example, it would have coordinates (going round anti-clockwise from the bottom left corner): (x1,y1), (x2,y1), (x3,y2), (x4,y2). In this case x1 < x2, and y2 > y1.

(a) Construct a line clipping algorithm for the trapezium as clipping region.

(b) Construct a polygon clipping algorithm on the lines of Sutherland-Hodgman for such a clipping region.

*6. A simple polygon is one where no edges intersect (except at vertices). Show (with diagrams) that any simple polygon can be decomposed into a set of triangles and trapezia. Use this and your previous results to construct an efficient line clipping algorithm for a simple polygon.

**7. Consider a polygon with a hole. This can be easily specified as an outer polygon with vertices going say clockwise, and an inner polygon with vertices anti-clockwise, and where the inner polygon is completely contained within the boundaries of the outer one. Assume that the two polygons are convex.

(a) Using the non-zero winding number rule as the inside test show that this really does specify a polygon with a hole.

(b) Can the Sutherland-Hodgman algorithm be extended to cover such a polygon used as a clipping region?