2d viewing - hallym.ac.krgraphics.hallym.ac.kr/teach/2008/cg/src/14viewing2d.pdf · 4 computer...
TRANSCRIPT
Sun-Jeong Kim
2D Viewing
11th Week, 2008
Computer Graphics2
Two-Dimensional Viewing
The procedures for displaying views of a two-dimensional picture on an output device
To specify which part of a defined picture is to be displayed and where that part is to be placed on the display device
Computer Graphics3
2D Viewing Pipeline (1)
Clipping windowClipping windowA section of a 2D scene that is selected for display
World windowWorld window or viewing windowviewing window
ViewportViewportThe placement within the display window
Clipping WindowClipping Window ViewportViewport
What we want to see Where to be viewed on the output device
Computer Graphics4
2D Viewing Pipeline (2)
The mapping of a 2D, world-coordinate scene description to device coordinates
Computer Graphics5
Normalization and ViewportTransformations (1)
[Case 1] mapping the clipping window into a normalized viewport (0~1)
Scale translate
Computer Graphics6
Normalization and ViewportTransformations (2)
[Case 2] mapping the clipping window into a normalized square (–1~+1)
Scale translate scale translate
Computer Graphics7
Clipping Algorithms
Procedures that eliminate those portions of a picture that are either inside or outside of a specified region of space
Point clipping
Line clipping (straight-line segments)
Fill-area clipping (polygons)
Curve clipping
Text clipping
Computer Graphics8
2D Point Clipping
A 2D point P=(x, y) is inside the clipping window, if the following inequalities are satisfied:
If any one of these four inequalities is not satisfied, the point is clipped
maxmin
maxmin
ywyyw
xwxxw
≤≤≤≤
Computer Graphics9
2D Line Clipping
Clipping straight-line segments using a standard rectangular clipping window
Computer Graphics10
Cohen-Sutherland Line Clipping (1)
Every line endpoint in a picture is assigned a four-digit binary value
Region codeRegion code
True (or 1) – endpoint is outside of that window border
Computer Graphics11
Cohen-Sutherland Line Clipping (2)
The nine binary region codes
Computer Graphics12
Cohen-Sutherland Line Clipping (3)
Classifying some lines quickly by AND of region codes of two endpoints (must be 0)
P10
P5
P6
P9
1000P7
P8
1010
0010
01100100
0000
0101
0001
P1
P2
1001
P4
P3
Computer Graphics13
Cohen-Sutherland Line Clipping (4)
To clip a line segment, several intersection calculations might be necessary
P6
1000 1010
0010
01100100
0000
0101
0001
1001
P4
P3
P’5
P’7
P’8
Computer Graphics14
Polygon Fill-Area Clipping
Processing a polygon fill area against successive clipping-window boundaries (left, right, bottom, and top)