Professional Documents
Culture Documents
4 Viewing2d
4 Viewing2d
2D Viewing
3D Rendering Pipeline
2D Rendering Pipeline
Clipping
Cohen-Sutherland Line Clipping
Sutherland-Hodgeman Polygon Clipping
Viewport Transformation
Scan Conversion
Summary of Transformation
2D Primitives
Image
cgvr.korea.ac.kr 5 Graphics Lab @ Korea University
2D Rendering Pipeline
CGVR
3D Primitives
2D Primitives
Image
cgvr.korea.ac.kr 6 Graphics Lab @ Korea University
Clipping
CGVR
World
Coordinates
cgvr.korea.ac.kr 7 Graphics Lab @ Korea University
Clipping
CGVR
wy2
Inside
Inside ==
(x>=wx1)
(x>=wx1) &&
&&
(x, y) (x<=wx2)
(x<=wx2) &&
&&
(y>=wy1)
(y>=wy1) &&
&&
(y<=wy2);
(y<=wy2);
wy1
wx1 wx2
P1
P4 P8
P3
P2
P6
P10
P5 P9
Before Clipping
cgvr.korea.ac.kr 11 Graphics Lab @ Korea University
Line Clipping
CGVR
P4 P’8
P3
P6
P’5
After Clipping
cgvr.korea.ac.kr 12 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P1
P4 P8
P3
P2
P6
P10
P5 P9
P4 P8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P5 0010 P9 0110
Bit 1 Bit 2
cgvr.korea.ac.kr 16 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P5 0010 P9 0110
Bit 1 Bit 2
cgvr.korea.ac.kr 17 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P5 0010 P9 0110
Bit 1 Bit 2
cgvr.korea.ac.kr 18 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 0110
P9
Bit 1 Bit 2
cgvr.korea.ac.kr 19 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 0110
P9
Bit 1 Bit 2
cgvr.korea.ac.kr 20 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 0110
P9
Bit 1 Bit 2
cgvr.korea.ac.kr 21 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 0110
P9
Bit 1 Bit 2
cgvr.korea.ac.kr 22 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 0110
P9
Bit 1 Bit 2
cgvr.korea.ac.kr 23 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 0110
P9
Bit 1 Bit 2
cgvr.korea.ac.kr 24 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P’8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 0110
P9
Bit 1 Bit 2
cgvr.korea.ac.kr 25 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P’8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 0110
P9
Bit 1 Bit 2
cgvr.korea.ac.kr 26 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P’8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 0110
P9
Bit 1 Bit 2
cgvr.korea.ac.kr 27 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P’8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 0110
P9
Bit 1 Bit 2
cgvr.korea.ac.kr 28 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P’8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 P’90110
Bit 1 Bit 2
cgvr.korea.ac.kr 29 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P’8
1000 P3 0000 0100
P6
P10
Bit 3
1010 P’5 0010 P’90110
Bit 1 Bit 2
cgvr.korea.ac.kr 30 Graphics Lab @ Korea University
Cohen-Sutherland Line
Clipping CGVR
P4 P’8
1000 P3 0000 0100
P6
Bit 3
1010 P’5 0010 0110
Bit 1 Bit 2
cgvr.korea.ac.kr 31 Graphics Lab @ Korea University
Polygon Clipping
CGVR
Before Clipping
cgvr.korea.ac.kr 32 Graphics Lab @ Korea University
Polygon Clipping
CGVR
After Clipping
cgvr.korea.ac.kr 33 Graphics Lab @ Korea University
Sutherland-Hodgeman Polygon
Clipping CGVR
P2 P1
Window
Boundary Inside
Outside
P3 P5
P4
cgvr.korea.ac.kr 39 Graphics Lab @ Korea University
Clipping to a Boundary
CGVR
P2 P1
Window
Boundary Inside
Outside
P3 P5
P4
cgvr.korea.ac.kr 40 Graphics Lab @ Korea University
Clipping to a Boundary
CGVR
P2 P1
Window
Boundary Inside
Outside
P3 P5
P4
cgvr.korea.ac.kr 41 Graphics Lab @ Korea University
Clipping to a Boundary
CGVR
P2 P1
Window
Boundary Inside
Outside
P3 P5
P4
cgvr.korea.ac.kr 42 Graphics Lab @ Korea University
Clipping to a Boundary
CGVR
P2 P1
Window
Boundary P’ Inside
Outside
P3 P5
P4
cgvr.korea.ac.kr 43 Graphics Lab @ Korea University
Clipping to a Boundary
CGVR
P2 P1
Window
Boundary P’ Inside
Outside
P3 P5
P4
cgvr.korea.ac.kr 44 Graphics Lab @ Korea University
Clipping to a Boundary
CGVR
P2 P1
Window
Boundary P’ Inside
Outside
P3 P5
P4
cgvr.korea.ac.kr 45 Graphics Lab @ Korea University
Clipping to a Boundary
CGVR
P2 P1
Window
Boundary P’ P” Inside
Outside
P3 P5
P4
cgvr.korea.ac.kr 46 Graphics Lab @ Korea University
Clipping to a Boundary
CGVR
P2 P1
Window
Boundary P’ P” Inside
Outside
2D Primitives
Image
cgvr.korea.ac.kr 48 Graphics Lab @ Korea University
Viewport Transformation
CGVR
Viewport
Window
World-coordinate area selected for display
What is to be viewed
Viewport
Area on the display device to which a window is
mapped
Where it is to be displayed
Window-to-Viewport Mapping
Window Viewport
wy2 vy2
vx
vx == vx1
vx1 ++ (wx
(wx –– wx1)
wx1) ** (vx2
(vx2 –– vx1)
vx1) // (wx2
(wx2 –– wx1);
wx1);
vy
vy == vy1
vy1 ++ (wy
(wy –– wy1)
wy1) ** (vy2
(vy2 –– vy1)
vy1) // (wy2
(wy2 –– wy1);
wy1);
2D Primitives
Image
cgvr.korea.ac.kr 52 Graphics Lab @ Korea University
Scan Conversion
CGVR
Definition
Figure out which pixels to fill
Example
Filling the inside of a triangle
P1
P2
P3
cgvr.korea.ac.kr 53 Graphics Lab @ Korea University
Triangle Scan Conversion
CGVR
Simple Algorithm
Color all pixels inside a triangle
Inside triangle test
A point is inside a triangle if it is in the positive halfspace of
all three boundary lines
L1 L3
P
L2
cgvr.korea.ac.kr 54 Graphics Lab @ Korea University
Triangle Scan Conversion
CGVR
dx
dy
L L
1 1
L2 L5 L2 L5B
L5A
L3 L3
L4 L4
Odd-Parity Rule
Any ray from P to infinity crosses odd number of
edges
Triangle Polygon
cgvr.korea.ac.kr 59 Graphics Lab @ Korea University
Polygon Scan Conversion
CGVR