0
1.5kviews
Window Viewport Transformation
1 Answer
0
30views

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.

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.

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

enter image description here

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.

enter image description here

Using this proportionality, the following ratios must be equal.

$\begin{aligned} \frac{x v-x v_{\min }}{x v_{\max }-x v_{\min }} &=\frac{x w-x w_{\min }}{x w_{\max }-x w_{\min }} \\ \frac{y v-y v_{\min }}{y v_{\max }-y v_{\min }} &=\frac{y w-y w_{\min }}{y w_{\max }-y w_{\min }} \end{aligned}$

By solving these equations for the unknown viewport position (xv, yv),

$x v=S_{x} x w+t_{x}$

$y v=S_{y} y w+t_{y}$

Where, the scale factors $\left(S_{x}, S_{y}\right)$ would be

$\begin{aligned} S_{x} &=\frac{x v_{\max }-x v_{\min }}{x w_{\max }-x w_{\min }} \\ S_{y} &=\frac{y v_{\max }-y v_{\min }}{y w_{\max }-y w_{\min }} \end{aligned}$

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

$\begin{aligned} t_{x} &=\frac{x w_{\max } x v_{\min }-x w_{\min } x v_{\max }}{x w_{\max }-x w_{\min }} \\ t_{y} &=\frac{y w_{\max } y v_{\min }-y w_{\min } y v_{\max }}{y w_{\max }-y w_{\min }} \end{aligned}$

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

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

3D Computer Graphics

In the 2D system, we use only two coordinates X and Y but in 3D, an extra coordinate Z is added. 3D graphics techniques and their application are fundamental to the entertainment, games, and computer-aided design industries. It is a continuing area of research in scientific visualization.

Furthermore, 3D graphics components are now a part of almost every personal computer and, although traditionally intended for graphics-intensive software such as games, they are increasingly being used by other applications.

Please log in to add an answer.