Home | | Syllabus | |
Assignments | |
Documentation
Assignment 7
Due: Tuesday, November 25, in class
Note: This assignment is worth 1/2 of a homework grade (50 points total)
Problem 1: Cohen-Sutherland Clipping
Given the following clipping rectangle:
(xmin, ymin) = (50, 50); (xmax, ymax) = (150, 100)
Determine the outcodes for each of the endpoints in the following line segments.
Use the Cohen-Sutherland clipping method to determine whether or not the segment should
clipped. Explain your answer based on the Cohen-Sutherland method. If the segment should
be clipped (or if it is uncertain), compute the points of intersection with the clipping window
boundaries,
and state whether the line should be clipped at each of these points
a) P0 = (25, 75), P1 = (30, 125)
b) P0 = (100, 70), P1 = (125, 120)
c) P0 = (100, 25), P1 = (175, 75)
Problem 2: Liang-Barsky Clipping
Given the same clipping rectangle as used in Problem 1:
(xmin, ymin) = (50, 50); (xmax, ymax) = (150, 100)
Use the Liang-Barsky algorithm, as described in lecture (not the book), to determine
whether the following line segment should be clipped, and if so, where it should be clipped.
P1 = (30, 80), P2 = (90, 110)
In your answer, you should compute the following:
- Compute the parametric representation for x and y components of the line segment.
(i.e. x = x1 + alpha(x2 - x1), similar for y )
- Compute the values of pk for each of the 4 clipping boundaries:
p1: Left border, p2: right border, p3: bottom border, p4: top border.
- Compute the values of qk for each of the for clipping boundaries.
- Compute the value of alpha (= qk/pk) for each of the clipping boundaries.
- Find the potential clipping values of alpha, u1 and u2, where u1 is the
maximum alpha for all boundaries where pk < 0 and u2 is the minimum alpha
for all boundaries where pk>0.
- Based on u1 and u2, determine whether the line needs to be clipped (u1 < u2)
- If the line needs to be clipped, determine the (x, y) values of the intersection
points for clipping by substituting u1 and u2 (for alpha) in the parametric equations
derived above.
Problem 3: Scan conversion
a) Use the DDA algorithm to plot the individual pixels of a line segment between the following
two endpoints:
Show your work for each pixel plotted. Sketch the result on a grid.
b) Use the Bresenham algorithm as described in class to plot the individual pixels of a line
segment defined by the following two endpoints:
P1 = (x1, y1) = (2, 3); Pf = (xf, yf) = (8, 7)
In your answer, show the following:
- Compute delta x, delta y, 2(delta y), 2(delta y) - 2(delta x),
p1 = 2(delta y) - delta x
- Plot x1, y1
- Compute each successive pixel value based on the current pk.
- Compute the next pk value based on the current pk.
- Continue until the final pixel is plotted. Show your work for each pixel.
- Sketch the result on a grid.
Turning in this assignment
Turn in your answers to theis assignment in class, Tuesday, November 25.
Home | | Syllabus | |
Assignments | |
Documentation
Constance Royden--croyden@mathcs.holycross.edu
Computer Science 384
Date Created: August 17, 1999
Last Modified: November 18, 2003
Page Expires: August 17, 2004
|