5. 2D Viewing

Embed Size (px)

Citation preview

  • 8/12/2019 5. 2D Viewing

    1/13

    Shri P. M. Agrawal

    Shri V. J. Patel

  • 8/12/2019 5. 2D Viewing

    2/13

    A world-coordinate area selected for display is calleda window.

    An area on display device to which a window ismapped is called a viewport. The window defines what is to be viewed; the

    viewport defines where it is to be displayed. -

    device coordinates is referred to as a viewingtransformation.

    Sometimes the 2D viewing transformation is simplyreferred to as the window-to-viewport

    transformation or the windowing transformation. But, in general, viewing involves more than just the

    transformation from the window to the viewport.

    2/9/2011 2P.M.Agrawal & V.J.Patel

  • 8/12/2019 5. 2D Viewing

    3/13

    Fig 5.1 illustrates the window-to-viewport

    mapping. A point at position (xw, yw) in thewindow is mapped into position (xv, yv) in theassociated viewport.

    viewport as in the window we require that

    2/9/2011P.M.Agrawal & V.J.Patel 3

  • 8/12/2019 5. 2D Viewing

    4/13

    2/9/2011P.M.Agrawal & V.J.Patel 4

  • 8/12/2019 5. 2D Viewing

    5/13

    Solving these equations for the viewportpostion (xv, yv), we have

    xv = xvmin + (xw xwmin)sx

    yv = yvmin + (yw ywmin)sy 5.1

    Where the scalin factors are

    2/9/2011P.M.Agrawal & V.J.Patel 5

  • 8/12/2019 5. 2D Viewing

    6/13

    Equation 5.1 can also be derived with a set oftransformations that converts the window area in to

    the viewport area. This conversion is performed withthe following sequence of transformations:1. Perform a scaling transformation using fir-point position

    of (xwmin, ywmin) that scales the window are to the size ofe v ewpor .

    2. Translate the scaled window area to the position of theviewport.

    Relative proportions of objects are maintained if thescaling factors are the same (sx = sy). Otherwise,

    world objects will be stretched or contracted inwither the x or y direction when displayed on theoutput device.

    2/9/2011P.M.Agrawal & V.J.Patel 6

  • 8/12/2019 5. 2D Viewing

    7/13

    Generally, any procedure that identifies thoseportions of a picture that are either inside oroutside of a specified region of space isreferred to as clipping algorithm or simply

    .

    is to clipped is called a clip window. Point clipping

    Line clipping

    Area clipping (polygon) Curve clipping

    Text clipping

    2/9/2011P.M.Agrawal & V.J.Patel 7

  • 8/12/2019 5. 2D Viewing

    8/13

    Assuming that the clip window is a rectangle instandard position, we save a point P = (x, y) for

    display if the following inequalities are satisfied:xwmin x xwmaxywmin y ywmax

    ,

    xwmax, ywmin, ywmax) can either the world-coordinate window boundaries or viewportboundaries.

    If any one of these four inequalities is notsatisfied, the point is clipped (not saved fordisplay).

    2/9/2011P.M.Agrawal & V.J.Patel 8

  • 8/12/2019 5. 2D Viewing

    9/13

    2/9/2011P.M.Agrawal & V.J.Patel 9

  • 8/12/2019 5. 2D Viewing

    10/13

    2/9/2011P.M.Agrawal & V.J.Patel 10

  • 8/12/2019 5. 2D Viewing

    11/13

    2/9/2011P.M.Agrawal & V.J.Patel 11

  • 8/12/2019 5. 2D Viewing

    12/13

    2/9/2011P.M.Agrawal & V.J.Patel 12

  • 8/12/2019 5. 2D Viewing

    13/13

    2/9/2011P.M.Agrawal & V.J.Patel 13