Sei sulla pagina 1di 22

Chapter 6:

Two-Dimensional Viewing

October 4, 2004
Lecture By:
Damon L. Woodard, Ph.D.
Lecture Outline

¡ Brief Overview
¡ The Two-Dimensional Viewing
Pipeline
¡ The Clipping Window
¡ Normalization and Viewport
Transformations
¡ Clipping Algorithms
Brief Overview
¡ Procedures for displaying two dimensional views of a
picture will be discussed

¡ Any Cartesian coordinate system can be used to define


the picture

¡ A single or multiple areas of a picture can be selected


for display by a user.

¡ The selected parts of the picture are mapped to device


coordinates for display

¡ Transformation from world to device coordinates


involve translation, rotation, scaling operations, and
procedures for deleting parts of the picture (clipping).
Two-Dimensional Viewing Pipeline
Clipping Window
A section of a two dimensional scene that is selected
for display

Viewport
Used to control the placement of the clipping
window within the display window

Two-Dimensional Viewing Transformation


The mapping of a two-dimensional, world-
coordinate scene description to device coordinates
Two-Dimensional Viewing Pipeline
(cont.)
Two-Dimensional Viewing Pipeline
(cont.)

¡ Changing the viewport position


allows for viewing objects at
different locations on the display
device.
¡ By changing clipping window size or
position, zooming, overview, or
panning effects can be achieved
Two-Dimensional Viewing Pipeline
(cont.)

1. Construct World Coordinate Scene using


Model-Coordinate Transformations
2. Convert World Coordinates to Viewing
Coordinates (clipping window)
3. Transform Viewing Coordinates to
Normalized Coordinates
4. Map Normalized Coordinates to Device
Coordinates
The Clipping Window
¡ Most applications allow only a rectangular clipping
window aligned with the x and y axes.

¡ Rectangular clipping windows in standard


positions are easily defined by giving the
coordinates of two opposite corners of each
rectangle.

¡ We could design our own clipping window with


any shape, size, or orientation

¡ A concave polygon clipping window or one with


nonlinear boundaries, requires more processing.
Clipping Window (cont.)

Two general types of clipping


window

1. Viewing-Coordinate Clipping Window

2. World-Coordinate Clipping Window


Viewing-Coordinate Clipping Window

¡ A viewing-coordinate system is set


up within the world-coordinate
frame to define the clipping window

¡ A clipping window in any orientation


can be defined
Viewing-Coordinate Clipping Window
(cont.)

1. Translate viewing coordinate origin


to the world coordinate origin

2. Rotate the viewing coordinate


system to align it with the world
frame.

3. Convert object positions in world


coordinates to viewing coordinates
World-Coordinate Clipping Window
¡ A routine for defining a standard,
rectangular clipping window in world
coordinates is provided in a graphics
programming library

¡ World-coordinate positions are used to


define the clipping window

¡ Once the clipping window has been


established, the screen description is
processed to the output device.
Normalization and Viewport
Transformations

¡ Many applications combine normalization


and window-to-viewpoint transformations
l The coordinates of the viewport are given in
the range [0,1] so that the viewport is position
within a unit square.
l After clipping, the unit square viewport is
mapped to the output device
¡ In other systems, the normalization and
clipping is performed before viewport
transformation.
l The viewport boundaries are given in screen
coordinates relative to the display-window
position
Mapping the Clipping Window into
Normalized Viewport

¡ Viewport is defined with normalized


coordinate values between 0 and 1.
¡ Object descriptions are transferred to this
normalized space.
¡ The transformation used maintains the
same relative placement of a point in the
viewport as it had in the clipping window.
¡ Relative proportions are only maintained
if the aspect ratio of the viewport is the
same as the clipping window.
Mapping the Clipping Window into
Normalized Viewport (cont.)
Mapping the Clipping Window to a
Normalized Square

¡ Transform the clipping window to a


normalized square.
¡ Clip in normalized coordinates
¡ Transfer screen description to
viewport specified screen
coordinates.
Mapping the Clipping Window to a
Normalized Square (cont.)
Clipping Algorithms
¡ Any procedure that eliminates portions of a
picture inside or outside a specific region of space
¡ Commonly used in the viewing pipeline to extract
a portion of a scene to be displayed on output
device
¡ Everything outside a clipping window is eliminated
from the scene prior to transfer to an output
device
¡ Efficient implementation of clipping involves
applying algorithms to normalized boundaries of
clipping window.
Clipping Algorithms (cont.)
¡ Point Clipping*
¡ Line Clipping (straight-line segments)*
¡ Fill-Area Clipping (polygons)*
¡ Curve Clipping
¡ Text Clipping

* Standard components in graphics


packages
Clipping Algorithms (cont.)
¡ We assume that clipping window is
rectangular and in standard position.

¡ Boundary edges are at xwmin, xwmax,


ywmin, and ywmax.

¡ Boundary edges correspond to a


normalized square where x and y values
are on the intervals [0,1] or [-1,1].
Clipping Algorithms (cont.)
Two-Dimensional Point Clipping

For a two-dimensional point P=(x,y)


to be saved for display it must
satisfy the following inequalities:

xwmin · x · xw
max
yw · y · yw
min max

Potrebbero piacerti anche