Professional Documents
Culture Documents
McGraw-Hill
2D Viewing
To display a picture on the screen, we must determine what part of the "world" is to be displayed where it should be displayed on the screen
Interface Window
Terminology
World Coordinate System (Object Space) Representation of an object measured in some physical units. Window - The rectangle defining the part of the world we wish to display. Screen Coordinate System (Image Space) - The space within the image is displayed Interface Window - The visual representation of the screen coordinate system for window displays (coordinate system moves with interface window). Viewport - The rectangle on the raster graphics screen (or interface window for window displays) defining where the image will appear. (Default is usually entire screen or interface window.)
Viewing Transformation
Translate to origin
Viewing Pipeline
Construct World Construct World Coordinate Scene Using Coordinate Scene Using Modeling Coordinate Modeling Coordinate Transformation Transformation
WC
Convert World Convert World Coordinates to Coordinates to Viewing Coordinates Viewing Coordinates
VC
Transform Viewing Transform Viewing Coordinates to Coordinates to Normalized Normalized Coordinates Coordinates
NC
Map Normalized Map Normalized Coordinates to Device Coordinates to Device Coordinates Coordinates
DC
Two-Dimensional Viewing
Two dimensional viewing transformation
From world coordinate scene description to device (screen) coordinates
xv = xvmin + ( xw xwmin ) sx
yv = yvmin + ( yw ywmin ) sy
This conversion is performed by 1.Perform scaling using fixed point (xwmin,ywmin) that scales window to size of viewport 2.Translate scaled window area to position of viewport
Clipping
Remove portion of output primitives outside clipping window
Two-Dimensional Clipping
Point clipping Line clipping
Cohen-Sutherland Liang-Barsky
Fill-area clipping
Sutherland-Hodgeman Weiler-Atherton
Line Clipping
Basic calculations: Is an endpoint inside or outside the clipping window? Find the point of intersection, if any, between a line segment and an edge of the clipping window.
Both endpoints inside: trivial accept One inside: find intersection and clip Both outside: either clip or reject
1010
< Region code for each endpoint >
0000 0100
0010 0110
above below
right
left
1000
Clipping window
0000 0100
Cohen-Sutherland Line Clipping Fixed order testing and clipping cause needless clipping (external intersection)
Cohen-Sutherland Line Clipping This algorithm can be very efficient if it can accept and reject primitives trivially
Clip window is much larger than scene data
Most primitives are accepted trivially
P(t ) = P0 + t (P P0 ), 0 t 1 1
Reduce the number of calculating intersections by exploiting the parametric form Notations Ei : edge of the clipping window Ni : outward normal of Ei An arbitrary point PEi on edge Ei
N i [ P0 PEi ] t= Ni D
N i P0 P < 0 PE 1 N i P0 P > 0 PL 1
Vector Method for Concave Splitting Calculate edge-vector cross products in a counterclockwise order If any z component turns out to be negative, the polygon is concave
Sutherland-Hodgman Polygon Clipping Accept a series of vertices (polygon) and outputs another series of vertices Four possible outputs
Sutherland-Hodgman Polygon Clipping The algorithm correctly clips convex polygons, but may display extraneous lines for concave polygons
Weiler-Atherton Polygon Clipping Polygon clipping using nonrectangular polygon clip windows
Text Clipping
All-or-none text clipping Using boundary box for the entire text All-or-non character clipping Using boundary box for each individual character Character clipping Vector font: Clip boundary polygons or curves Bitmap font: Clip individual pixels