Download presentation

1
**2D Viewing and Projection**

Dr. Aree Ali Mohammed Assistant Professor 3rd Stage 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. Windowing and Clipping Window wymax wymin wxmin wxmax 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 Normalization Transformation NC 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 NC DC 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
**University of Sulaimani - School of Science - Computer Dept.**

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 P7 P5 P9 P8 wymin P10 wxmin wxmax University of Sulaimani - School of Science - Computer Dept.

11
**University of Sulaimani - School of Science - Computer Dept.**

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 Clipped P10 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 Situation Solution Example Both end-points inside the window Don’t clip One end-point inside the window, one outside Must clip Both end-points outside the window Don’t know!

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. 1001 1000 1010 0001 0000 Window 0010 0101 0100 0110 4 3 2 1 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.

16
**University of Sulaimani - School of Science - Computer Dept.**

17
**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.

18
**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.

19
**University of Sulaimani - School of Science - Computer Dept.**

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.

20
**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.

21
**University of Sulaimani - School of Science - Computer Dept.**

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

22
**University of Sulaimani - School of Science - Computer Dept.**

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.

23
Group Discussion

Similar presentations

© 2021 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google