Next: Normalized Device Coordinates Up: Device Independence Previous: How a Monitor

# Window to Viewport Mapping

• 2D scene is infinite plane. Device has a finite visible rectangle.
What do we do?
• Answer: map rectangular region of 2D device scene to device.
Window:
rectangular region of interest in scene.
Viewport:
rectangular region on device.

Usually, both rectangles are aligned with the coordinate axes.

\

• Window point maps to viewport point .

Window has corners and ;
Viewport has corners and .

Length and height of the window are and ,
Length and heigth of the viewport are and .

• Proportionally map each of the coordinates according to:

• To map to :

and similarily for .

• If the image will be distorted.
These quantities are called the aspect ratios of the window and viewport.

Readings: Hearn and Baker: Section 6-3. Red book: 5.5. White book: 5.4, Blinn: 16.

Intuitively, the window-to-viewport formula can be read as:

• Convert to a distance from the window corner.
• Scale this w distance to get a v distance.
• Add to viewport corner to get .

CS488/688: Introduction to Interactive Computer Graphics
University of Waterloo
Computer Graphics Lab

cs488@cgl.uwaterloo.ca