computer graphics - two-dimensional viewing

22
Chapter 6: Two-Dimensional Viewing October 4, 2004 Lecture By: Damon L. Woodard, Ph.D.

Upload: syedkareemhkg

Post on 28-Mar-2015

746 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Computer Graphics - Two-Dimensional Viewing

Chapter 6: Two-Dimensional Viewing

October 4, 2004Lecture By:

Damon L. Woodard, Ph.D.

Page 2: Computer Graphics - Two-Dimensional Viewing

Lecture Outline

¡ Brief Overview¡ The Two-Dimensional Viewing

Pipeline¡ The Clipping Window¡ Normalization and Viewport

Transformations¡ Clipping Algorithms

Page 3: Computer Graphics - Two-Dimensional Viewing

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).

Page 4: Computer Graphics - Two-Dimensional Viewing

Two-Dimensional Viewing Pipeline

Clipping WindowA section of a two dimensional scene that is selectedfor display

ViewportUsed to control the placement of the clipping window within the display window

Two-Dimensional Viewing TransformationThe mapping of a two-dimensional, world-coordinate scene description to device coordinates

Page 5: Computer Graphics - Two-Dimensional Viewing

Two-Dimensional Viewing Pipeline (cont.)

Page 6: Computer Graphics - Two-Dimensional Viewing

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

Page 7: Computer Graphics - Two-Dimensional Viewing

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

Page 8: Computer Graphics - Two-Dimensional Viewing

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.

Page 9: Computer Graphics - Two-Dimensional Viewing

Clipping Window (cont.)

Two general types of clipping window

1. Viewing-Coordinate Clipping Window

2. World-Coordinate Clipping Window

Page 10: Computer Graphics - Two-Dimensional Viewing

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

Page 11: Computer Graphics - Two-Dimensional Viewing

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

Page 12: Computer Graphics - Two-Dimensional Viewing

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.

Page 13: Computer Graphics - Two-Dimensional Viewing

Normalization and Viewport Transformations

¡ Many applications combine normalization and window-to-viewpoint transformationsl 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

Page 14: Computer Graphics - Two-Dimensional Viewing

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.

Page 15: Computer Graphics - Two-Dimensional Viewing

Mapping the Clipping Window into Normalized Viewport (cont.)

Page 16: Computer Graphics - Two-Dimensional Viewing

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.

Page 17: Computer Graphics - Two-Dimensional Viewing

Mapping the Clipping Window to a Normalized Square (cont.)

Page 18: Computer Graphics - Two-Dimensional Viewing

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.

Page 19: Computer Graphics - Two-Dimensional Viewing

Clipping Algorithms (cont.)

¡ Point Clipping*¡ Line Clipping (straight-line segments)*¡ Fill-Area Clipping (polygons)*¡ Curve Clipping¡ Text Clipping

* Standard components in graphics packages

Page 20: Computer Graphics - Two-Dimensional Viewing

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].

Page 21: Computer Graphics - Two-Dimensional Viewing

Clipping Algorithms (cont.)

Page 22: Computer Graphics - Two-Dimensional Viewing

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 · xwmax

ywmin

· y · ywmax