written 7.2 years ago by | • modified 7.2 years ago |

Mumbai university > Comp > SEM 4 > Computer Graphics

**Marks:** 10M

**Year:** Dec 2015

**1 Answer**

1

121kviews

Define window and viewport. Derive window to viewport transformation.

written 7.2 years ago by | • modified 7.2 years ago |

Mumbai university > Comp > SEM 4 > Computer Graphics

**Marks:** 10M

**Year:** Dec 2015

ADD COMMENT
EDIT

20

2.1kviews

written 7.2 years ago by |

**Window:**

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

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

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.

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:**

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

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.

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:**

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

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.

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.

**Example:**

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

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.

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.

- 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}}$$

- 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$$

- 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}}$$

- 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}}$$

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

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.

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

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

ADD COMMENT
EDIT

Please log in to add an answer.