1 / 23

2D Viewing and Projection

2D Viewing and Projection. Dr. Aree Ali Mohammed Assistant Professor 2013-2014 3 rd Stage aree.ali@univsul.net. Windowing and Clipping. The process of selecting and viewing the picture with different views is called windowing.

kirby
Download Presentation

2D Viewing and Projection

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2D Viewing and Projection Dr. Aree Ali Mohammed Assistant Professor 2013-2014 3rd Stage aree.ali@univsul.net University of Sulaimani - School of Science - Computer Dept.

  2. Windowing and Clipping • The process of selecting and viewing the picture with different views is called windowing. • The process which divides each element of the picture into its visible and invisible portions, allowing the invisible portion to be discarded is called clipping. Window wymax wymin wxmax wxmin World Coordinates World Coordinates

  3. Viewing Transformation I • Picture stored in a computer  WCS (World Coordinate System) • Picture displayed on a device  PDCS (Physical Device CS) Mapping from WCS to PDCS  Viewing Transformation Normalization Transformation  Device independent University of Sulaimani - School of Science - Computer Dept.

  4. Viewing Transformation II 1. Normalization Transformation  Device independent An interpreter is used to convert the normalized device coordinates to the actual device coordinates. The transformation which maps the world coordinate to normalized device coordinate is called normalization transformation. It involves scaling of x and y, thus it is also referred to as scaling transformation University of Sulaimani - School of Science - Computer Dept.

  5. Viewing Transformation III 2. Workstation Transformation Maps normalized device coordinates  physical device coordinates The viewing transformation is the combination of normalization transformation and workstation transformation. 00000000000000 NC Normalization Transformation Workstation Transformation WC DC 2D Viewing V=N.W University of Sulaimani - School of Science - Computer Dept.

  6. Viewing Transformation IV • Workstation Transformation WCS  infinite  finite  window Device display  finite  viewport The window defines what is to be viewed; the viewport defines where it is to be displays. University of Sulaimani - School of Science - Computer Dept.

  7. Viewing Transformation V Workstation Transformation Steps

  8. Viewing Transformation VI

  9. Viewing Transformation VII Normalization Transformation DC NC WC Ex: Find the normalization transformation window to viewport, with window, lower left corner at (1,1) and upper right corner at (3,5) onto a viewpoint with lower left corner at (0,0) and upper right corner at (1/2,1/2). Sol:

  10. 2D Clipping • For the image below consider which lines and points should be kept and which ones should be clipped P4 Window P2 wymax P6 P3 P1 P5 P7 P9 P8 wymin P10 wxmin wxmax University of Sulaimani - School of Science - Computer Dept.

  11. Point Clipping • Easy - a point (x,y) is not clipped if: • wxmin≤ x ≤ wxmax AND wymin≤ y ≤ wymax • otherwise it is clipped P4 Clipped Clipped Window P2 wymax Clipped P5 P1 P7 Points Within the Window are Not Clipped P9 P8 wymin P10 Clipped wxmin wxmax University of Sulaimani - School of Science - Computer Dept.

  12. Line Clipping • Harder - examine the end-points of each line to see if they are in the window or not

  13. Line Clipping Algorithms (I) • Sutherland and Cohen Subdivision Algorithm • Reduce the number of intersections  speed up • Use four digit (bit) code to indicate which of nine regions contain the end point of line. • Called region code or outcodes. 4 3 1 2 above below right left Region Code Legend University of Sulaimani - School of Science - Computer Dept.

  14. Line Clipping Algorithms (II) Ex: Consider the clipping window and the lines shown in figure. Find the region codes for each end point and identify whether the line is completely visible, partially visible or completely invisible. University of Sulaimani - School of Science - Computer Dept.

  15. University of Sulaimani - School of Science - Computer Dept.

  16. Calculating Line Intersections I • Intersection points with the window boundaries are calculated using the line-equation parameters • Consider a line with the end-points (x1, y1) and (x2, y2) • The y-coordinate of an intersection with a vertical window boundary can be calculated using: y = y1 + m (xboundary - x1) where xboundary can be set to either wxmin or wxmax University of Sulaimani - School of Science - Computer Dept.

  17. Calculating Line Intersections II • The x-coordinate of an intersection with a horizontal window boundary can be calculated using: x = x1 + (yboundary - y1)/ m where yboundary can be set to either wymin or wymax • m is the slope of the line in question and can be calculated as m = (y2 - y1) / (x2 - x1) University of Sulaimani - School of Science - Computer Dept.

  18. Area Clipping • Similarly to lines, areas must be clipped to a window boundary • Consideration must be taken as to which portions of the area must be clipped University of Sulaimani - School of Science - Computer Dept.

  19. Sutherland-Hodgman Area Clipping Algorithm • A technique for clipping areas developed by Sutherland & Hodgman • Put simply the polygon is clipped by comparing it against each boundary in turn Clip Bottom Original Area Clip Left Clip Right Clip Top University of Sulaimani - School of Science - Computer Dept.

  20. 2D Polygon Clipping University of Sulaimani - School of Science - Computer Dept.

  21. Review Questions • Write short note on viewing transformation. • Distinguish between viewport and window. • What do you mean by normalization transformation? Why it is needed? • Derive the transformation matrix for 2D viewing transformation. • What is point and line clipping? • Explain the Sutherland and Cohen Subdivision Algorithm for line clipping. • Use Sutherland and Cohen outcode Algorithm to clip two lines P1 (40,50) – P2 (75,45) and P3(70,20), P4(100,10) against a window A(50,10), B(80,10), C(80,40), D(50,40). • Clip the line P1(-3/2,1/6) and P2(1/2,3/2) against window A(-1,-1), B(-1,1), C(1,1) and D(1,-1) using Sutherland and Cohen Subdivision Algorithm University of Sulaimani - School of Science - Computer Dept.

  22. Group Discussion

More Related