Presentation is loading. Please wait.

Presentation is loading. Please wait.

2 D viewing Prepared by Elizabeth Isaac DCS, RSET.

Similar presentations

Presentation on theme: "2 D viewing Prepared by Elizabeth Isaac DCS, RSET."— Presentation transcript:

1 2 D viewing Prepared by Elizabeth Isaac DCS, RSET

2 The Viewing Pipeline Viewing transformations in several steps Window to Viewport. Window: A region of the scene selected for viewing (also called clipping window) Viewport: A region on display device for mapping to window 2-D viewing transformation referred to as Window –to-Viewport Transformation or windowing transformation

3 World Coordinates Viewing Coordinates Window Viewport The Viewing Pipeline

4 A viewing transformation using standard rectangles for the window and viewport World Coordinates xv min xv max yw max yw min Device Coordinate xv min xv max yv max yv min

5 The two-dimensional viewing- transformation pipeline Construct World Coordinate Scene Using Modeling-Coordinate Transformation Convert World-Coordinates to Viewing Coordinates Map Viewing Coordinates to Normalized Viewing Coordinates using Window-Viewport Specifications Map Normalized Viewport to Device Coordinates

6 Setting up a rotated world window in viewing coordinates and the corresponding normalized- coordinate viewport Normalized Device Coordinates Viewpoint 0 1 1 World Coordinates y view x view y world y0y0 x0x0 x world

7 Viewing Coordinate Reference Frame The steps in this coordinate transformation – A viewing coordinate frame is moved into coincidence with the world frame in two steps a)Translate the viewing origin to the world origin, then b)Rotate to align the axes of the two systems

8 Viewing Coordinate Reference Frame

9 Matrix for converting world-coordinate positions to viewing coordinate R: rotation matrix T: translation matrix

10 Window-To-Viewport Coordinate Transformation A point at position (xw, yw) in a designated window is mapped to viewport coordinates (xv, yv) so that relative positions in the two areas are the same

11 Window-To-Viewport Coordinate Transformation To maintain the same relative placement

12 Window-To-Viewport Coordinate Transformation Solving these expressions The scaling factors

13 Window-To-Viewport Coordinate Transformation Conversion sequence of transformation 1.Perform a scaling transformation using a fixed- point position of (xw min, yw min ) that scales the window area to the size of the viewport 2.Translate the scaled window area to the position of the viewport

14 Window-To-Viewport Coordinate Transformation Workstation transformation – Opening any number of output devices in a particular application – Performing another window-to-viewport transformation for each open output device

15 Window-To-Viewport Coordinate Transformation

16 Two-Dimensional Viewing Functions Setting up the elements of a window-to- viewport mapping matrix evaluateViewMappingMatrix (xwmin, xwmax, ywmin, ywmax, xvmin, xvmax, yvmin, yvmax, error, viewMappingMatrix)

17 Two-Dimensional Viewing Functions Selection of a workstation window-viewport pair – setWorkstationWindow (ws, xwsWindmin, xwsWindmax, ywsWindmin, ywsWindmax) – setWorkstationViewport (ws, xwsVPortmin, xwsVPortmax, ywsVPortmin, ywsVPortmax)

18 Clipping Any procedure that identifies those portions of a picture that are either inside or outside of a specified region of space is referred to as a clipping algorithm or clipping Clip window

19 Clipping – Point – Line – Area (or Polygons) – Curve – Text

20 Clipping Point Clipping Assuming that the clip window is a rectangle in standard position Saving a point P=(x, y) for display

21 Line Clipping Line clipping against a rectangular clip window

22 Line Clipping

23 Cohen-Sutherland Line Clipping Four digit binary code - Region Code Identifies the location of the point relative to the boundaries of the clipping rectangle Bit 1: left Bit 2: right Bit 3: below Bit 4: above 4321

24 Cohen-Sutherland Line Clipping

25 – Calculate differences between endpoint coordinates and clipping boundaries – Use the resultant sign bit of each difference calculation to set the corresponding value in the region code

26 Region code divide space into 9 regions Computation of region code requires at most 4 subtractions b 0 = 1 if y > y max, 0 otherwise b 1 = 1 if y < y min, 0 otherwise b 2 = 1 if x > x max, 0 otherwise b 3 = 1 if x < x min, 0 otherwise

27 Cohen-Sutherland Line Clipping Outside Line Removal Test – A method that can be used to test lines total clipping is to perform the logical and operation with both region codes – Not 0000 Completely outside the clipping region!! Lines that cannot be identified as completely inside or outside a clip window by this test

28 Cohen-Sutherland Line Clipping

29 Intersection Point Calculate Intersection Point – Using the slope-intercept form – Vertical Boundary – Horizontal Boundary

30 1. Start 2. Read two end points of a line P1,P2 (x1,y1) and (x2,y2) 3. Read two corners of window(wx1,wy1) and(wx2,wy2) 4. Assign the region codes for two end points using following steps – a. Set bit 1 if x < wx1 – b. Set bit 2 if x>wx2 – c. Set bit 3 if y<wy2 – d. Set bit 4 if y> wy1

31 5. Check for the visibility of the line – a. If region codes for both end points are 0 then the line is completely visible. Draw the line. Go to 10 – b. If the region codes are not zero and the logical AND ing of them is also non zero then the line is completely invisible. Go to 10 – c. If the region codes for two end points do not satisfy the conditions in 5 a and 5 b the line is partially visible

32 6. Determine the intersecting edge of the clipping window by inspecting the region codes of two end points – a. If the region codes foe both end points are non zero find the intersection point P1’ and P2’ with boundary edges of clipping window with respect to P1 and P2 respectively – b. If the region code for any one end point is non zero then find intersection point P1’ or P2’ with the boundary edge of the clipping window with respect to it.

33 7. Divide the line segments considering the intersection points 8. Reject the line segment if any one end point of it appears outside the clipping window 9. Draw the remaining line segments 10. Stop.

34 Polygon Clipping


36 36 Sutherland-Hodgman Clipping

37 37 Sutherland-Hodgman Clipping

38 38 Sutherland-Hodgman Clipping

39 39 Sutherland-Hodgman Clipping

40 40 Sutherland-Hodgman Clipping

41 41 Sutherland-Hodgman Clipping

42 42 Sutherland-Hodgman Clipping

43 43 Sutherland-Hodgman Clipping

44 Sutherland-Hodgeman Polygon Clipping

45 4 possible cases

46 Sutherland-Hodgeman Polygon Clipping


48 Weiler-Atherton Polygon Clipping Rules – For an outside-to-inside pair of vertices, follow the polygon boundary – For an inside-to-outside pair of vertices, follow the window boundary in clockwise direction

49 Other Polygon-Clipping Algorithm Clipping a polygon by determining the intersection of two polygon areas

50 Text clipping

51 All-or-none string clipping – No text is retained after clipping since part of text is outside clip window

52 Text clipping All-or-none character clipping – Only “ B ” and “ C ” are retained after clipping since part of “ A ” is outside clip window

53 Text clipping Character component clipping – All of “ B ” and “ C ” are retained, and those parts of “ A ” inside clip window are also retained

54 interior clipping – what is to be saved is inside the clip window exterior clipping – what is to be saved is outside clip window Interior clipping - keep point P2 P2 (x2, y2)

55 Exterior Clipping Exterior clipping - keep point P1 Clip window P1 (x1, y1)

Download ppt "2 D viewing Prepared by Elizabeth Isaac DCS, RSET."

Similar presentations

Ads by Google