Computer Graphics Clipping Algorithms Review

Slide Note
Embed
Share

In this material, Cohen-Sutherland and Liang-Barsky clipping algorithms are reviewed with examples and solutions. Points are classified using outcodes, and line segments are determined to be entirely rendered, clipped, or discarded based on intersection points. Liang-Barsky clipping is applied to calculate clipping values for given line segments, showing where they are clipped or discarded. The DDA algorithm is also discussed for line drawing scenarios.


Uploaded on Sep 13, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Graphics CSCI 343, Fall 2023 Lecture 27 Final Exam Review Partial Solutions to problems 1

  2. 1. Cohen-Sutherland Clipping Given a clipping rectangle defined by (xmin, ymin) = (3, 2) (xmax, ymax) = (6, 4) For the pairs of points in parts a and b: i) Indicate the Cohen-Sutherland outcode for each point ii) State what the algorithm will dictate concerning the rendering of the line- segment (entirely rendered, clipped with part rendered, entirely clipped (i.e. not rendered) or not known) iii) Briefly state why the algorithm gives this output. iv) If clipping is required, or if it is not known, calculate the intersection points to determine where to clip. 2

  3. 1. Cohen-Sutherland Clipping a) P0 = (2, 3), P1 = (5, 5) P0 outcode = 0001 P1 outcode = 10000 Case 4: May or may not have to clip Intersection with left border at (3, 3.67) Intersection with top border at (3.5, 4) Clip at these two points b) P0 = (7, 1), P1 = (8, 3) P0 outcode = 0110 P1 outcode = 0010 Case3: Discard entire segment 3

  4. 1c. Liang-Barsky Clipping Problem 1 (continued) For the following pair of points i) Determine the clipping values using Liang-Barsky clipping. ii) Indicate whether the line is discarded entirely, rendered entirely, or clipped. iii) If the line is clipped, indicate the (x, y) value(s) at which it is clipped. c) P0 = (4, 3), P1 = (5,1) See next slide 4

  5. 1c. Liang-Barsky Clipping c) P0 = (4, 3), P1 = (5,1) Left border: p1 = -1, q1 = 1, 1 = -1 Right border: p2 = 1, q2 = 2, 2 = 2 Bottom border: p3 = 2, q3 = 1, 3 = 1/2 Top border: p4 = -2, q4 = 1, 4 = -1/2 Negative pk's: p1 and p4, max of 's and 0 is 0, so clip at = 0 Positive pk's: p2 and p3, min of 's and 1 is 3 = , so clip at = = 0 is beginning of line segment (4, 3) = : x = x1 + (x2 x1) = 4 + y = y1 + (y2 y1) = 3 2 Clip at x = 4 + = 4.5; y = 3 -1 = 2, So clip at (4.5, 2) 5

  6. 2. Line Drawing Given the line, y = 1/3x + 2 and the starting and ending points of a line segment: (x1, y1) = (0,2) (x2, y2) = (6,4) For each pixel between x = 0 and x = 6, what y value will be colored as part of the line in: a) The DDA algorithm? (0, 2) (1, 2) (2, 3) (3, 3) (4, 3) (5, 4) (6, 4) 6

  7. 2. Line Drawing b) The Bresenham algorithm? (Show your work, indicating the values of pk at each step). Plot (0, 2) to begin. k pk plot pk+1 0 -2 (1, 2) 2 1 2 (2, 3) -6 2 -6 (3, 3) -2 3 -2 (4, 3) 2 4 2 (5, 4) -6 5 -6 (6, 4) -2. Done. 7

  8. 3. Curves Given the following four points: P0 = (1, 1, 1) P1 = (3, 5, 2) P2 = (5, 5, 3) P3 = (8, 2, 4) Find the parametric representations, x(u), y(u), z(u) for the Bezier (also know Interpolation, Hermite and Spline techniques) curve that fits these points. We went over this in class. 8

  9. 4. Texture Mapping Suppose you are texture mapping an image that has width = 256 pixels and height = 128 pixels. This image is represented by a texture mapping with s (width) ranging from 0 to 1.0 and t (height) ranging from 0 to 1.0. a) What region of the image (in pixels) is mapped by the rectangle in the texture map with lower left corner at (0.5, 0.5) and upper right corner at (0.75, 0.75)? Lower left: (128, 64) Upper right: (192, 96) b) Suppose you are mapping this image onto a rectangle that, when rendered, has lower left corner at (100, 100) with width and height that are both 100 pixels. What region of the rectangle will the region given in a) map to? Lower left: (150, 150) Upper right: (175, 175) c) Will the image be distorted? Why or why not? Yes. The aspect ratio is different between the image and the object that is being mapped onto. 9

Related