1 / 19

2D Viewing & Clipping

2D Viewing & Clipping. 한신대 류승택 2005. 6. Contents. The viewing pipeline Viewing coordinate reference frame Window-to-viewport coordinate transformation Clipping operations Point clipping Line clipping. The viewing pipeline [1/5]. window a world-coordinate area selected for display

kalani
Download Presentation

2D Viewing & Clipping

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 & Clipping 한신대 류승택 2005. 6

  2. Contents • The viewing pipeline • Viewing coordinate reference frame • Window-to-viewport coordinate transformation • Clipping operations • Point clipping • Line clipping

  3. The viewing pipeline [1/5] • window • a world-coordinate area selected for display • define what is to be viewed • view port • an area on a display device to which a window is mapped • define where it is to be displayed • windows & viewport • be rectangles in standard position, with the rectangle edges parallel to the coordinate axes • other geometries : take longer to process

  4. The viewing pipeline [2/5] • viewing transformation • the mapping of a part of a world-coordinate scene to device coordinates • 2D viewing transformation = window-to-viewport, windowing transformation

  5. The viewing pipeline [3/5] • viewing-transformation in several steps • construct the world-coordinate scene using modeling transformations • transform descriptions in world coordinates to viewing coordinates • map the viewing-coordinate description of the scene to normalized coordinates • transfer to device coordinates

  6. The viewing pipeline [4/5] • viewing-transformation • by changing the position of the viewport • can view objects at different positions on the display area of an output device • by varying the size of viewports • can change the size and proportions of displayed objects • zooming effects = panning effects

  7. The viewing pipeline [5/5] • viewport • define within the unit square • device-independent ⇒ separating the viewing & other transformations from specific output-device requirements • the unit square is mapped to the display area for the particular output device in use at that time • viewport clipping • perform in normalized coordinates or in device coordinates • to reduce computations by concatenating the various transformation matrices • provide for specifying the world-coordinate window

  8. Viewing coordinate reference frame • view up vector • define the viewing yv direction • unit vectors v=(vx, vy) and u=(ux, uy) for the viewing yv and xv axes • The composite 2D transformation to convert world coordinates to viewing coordinates MWC,VC = R • T

  9. Window-to-viewport coordinate transformation • transfer to the viewing reference frame • choose the window extents in viewing coordinate • select the viewport limits in normalized coordinate • to maintain the same relative placement in the viewport as in the window

  10. Window-to-viewport coordinate transformation • Relative proportions of objects • sx=xvmax-xvmin/xwmax-xwmin, sy=yvmax-yvmin/ywmax-ywmin • sx=sy : maintain • sx≠sy : stretch or contract in either the x or y direction when displayed on the output device • workstation transformation • select a window area in normalized space and a viewport area in the coordinates of the display device

  11. Clipping operations • clipping algorithm(simply clipping) • identify those portions of picture that are either inside or outside of a specified region of space • clip window • the region against which an object is to clipped • clipping application • extracting part of a defined scene for viewing • identifying visible surfaces in 3D views • antialiasing line segments or object boundaries • creating objects using solid-modeling procedures • displaying a multiwindow environment • drawing & painting operations that allow parts of a picture to be selected for copying,moving,erasing, or duplicating

  12. Clipping operations • world-coordinate clipping • remove those primitives outside the window from further consideration • eliminating the processing necessary to transform those primitives to device space • viewport clipping • reduce calculations by allowing concatenation of viewing and geometric transformation matrices • require that the transformation to device coordinates be performed for all objects, including those outside the window area

  13. Point clipping • Assuming that the clip window is a rectangle in standard position P=(x, y) • the edges of the clip window(xwmin, xwmax, ywmin, ywmax) can be either the world-coordinate window boundaries or viewport boundaries • ex. apply to scenes involving explosions or sea foam

  14. Line clipping • Line clipping procedure • test a given line segment to determine whether it lies completely inside the clipping window • if it doesn’t, we try to determine whether it lies completely outside the window • if we can’t identify a line as completely inside or completely outside, we must perform intersection calculations with one or more clipping boundaries

  15. Line clipping • Checking the line endpoints ⇒ inside-outside test • Line clipping • Cohen-Sutherland line clipping • Liang-Barsky line clipping

  16. Line clipping • Cohen-Sutherland line clipping • one of the oldest and most popular line-clipping procedures • speed up the processing of line segments by performing initial tests that reduce the number of intersections that must be calculated • region code : four-digit binary code • ⇒ bit 1:left, bit 2:right, bit 3:below, bit 4:above • for languages in which bit manipulation is possible

  17. Line clipping • region-code bit values determined • calculate difference between endpoint coordinates and clipping boundaries • use the resultant sign bit of each difference calculation to set the corresponding value in the region code • bit 1 : the sign bit of x – xwmin • bit 2 : the sign bit of xwmax – x • bit 3 : the sign bit of y – ywmin • bit 4 : the sign bit of ywmax – y

  18. Line clipping • Determine which lines are completely inside the clip window and which line are clearly outside • completely inside the clip window • region code of 0000 for both endpoints • trivially accept these lines • clearly outside the clip window • any line that a 1 in the same bit position in region code • trivially reject these lines • by using logical and operation with both region codes

  19. Line clipping • check for intersection with the window boundaries • using the slope-intercept form of the line equation • x value Is set either to xwmin or to xwmax • y value Is set either to ywmin or to ywmax

More Related