1
125kviews
Define window and viewport. Derive window to viewport transformation.

Mumbai university > Comp > SEM 4 > Computer Graphics

Marks: 10M

Year: Dec 2015

1 Answer
21
2.3kviews

Window:

  1. A world-coordinate area selected for display is called a window.

  2. In computer graphics, a window is a graphical control element.

  3. It consists of a visual area containing some of the graphical user interface of the program it belongs to and is framed by a window decoration.

  4. A window defines a rectangular area in world coordinates. You define a window with a GWINDOW statement. You can define the window to be larger than, the same size as, or smaller than the actual range of data values, depending on whether you want to show all of the data or only part of the data.

Viewport:

  1. An area on a display device to which a window is mapped is called a viewport.

  2. A viewport is a polygon viewing region in computer graphics. The viewport is an area expressed in rendering-device-specific coordinates, e.g. pixels for screen coordinates, in which the objects of interest are going to be rendered.

  3. A viewport defines in normalized coordinates a rectangular area on the display device where the image of the data appears. You define a viewport with the GPORT command. You can have your graph take up the entire display device or show it in only a portion, say the upper-right part.

Window to viewport transformation:

  1. Window-to-Viewport transformation is the process of transforming a two-dimensional, world-coordinate scene to device coordinates.

  2. In particular, objects inside the world or clipping window are mapped to the viewport. The viewport is displayed in the interface window on the screen.

  3. In other words, the clipping window is used to select the part of the scene that is to be displayed. The viewport then positions the scene on the output device.

  4. Example:

enter image description here

  1. This transformation involves developing formulas that start with a point in the world window, say (xw, yw).

  2. The formula is used to produce a corresponding point in viewport coordinates, say (xv, yv). We would like for this mapping to be "proportional" in the sense that if xw is 30% of the way from the left edge of the world window, then xv is 30% of the way from the left edge of the viewport.

  3. Similarly, if yw is 30% of the way from the bottom edge of the world window, then yv is 30% of the way from the bottom edge of the viewport. The picture below shows this proportionality.

enter image description here

  1. Using this proportionality, the following ratios must be equal.

$$\frac{xv - xv_{min}}{xv_{max} - xv_{min}} = \frac{xw - xw_{min}}{xw_{max} - xw_{min}}$$

$$\frac{yv - yv_{min}}{yv_{max} - yv_{min}} = \frac{yw - yw_{min}}{yw_{max} - yw_{min}}$$

  1. By solving these equations for the unknown viewport position (xv, yv), the following becomes true:

$$xv = S_xxw + t_x$$

$$yv = S_yyw + t_y$$

  1. The scale factors (Sx, Sy) would be:

$$S_x = \frac{xv_{max} - xv_{min}}{xw_{max} - xw_{min}}$$

$$S_y = \frac{yv_{max} - yv_{min}}{yw_{max} - yw_{min}}$$

  1. And the translation factors (Tx, Ty) would be:

$$t_x = \frac{xw_{max}xv_{min} - xw_{min}xv_{max}}{xw_{max} - xw_{min}}$$

$$t_y = \frac{yw_{max}yv_{min} - yw_{min}yv_{max}}{yw_{max} - yw_{min}}$$

  1. The position of the viewport can be changed allowing objects to be viewed at different positions on the Interface Window.

  2. Multiple viewports can also be used to display different sections of a scene at different screen positions. Also, by changing the dimensions of the viewport, the size and proportions of the objects being displayed can be manipulated.

  3. Thus, a zooming affect can be achieved by successively mapping different dimensioned clipping windows on a fixed sized viewport.

  4. If the aspect ratio of the world window and the viewport are different, then the image may look distorted.

Please log in to add an answer.