Professional Documents
Culture Documents
Contents
o Point
o Line Clipping
o Polygon Clipping
o Text Clipping
xL
yV
yS
xS xV Center of
V
zV Projection,
U Viewer’s
N Position
xwc
ywc
window pixel
viewport
Window definition Viewport definition Window’s content Scan conversion onto the
in projection plane in projection plane inside the viewport raster screen
Viewport
yvmax
ywmin
yvmin
Window definition: (xwmin, xwmin, xwmax, ywmax) Viewport def: (xvmin, xvmin, xvmax, yvmax)
yw
(-60.5, 82.5) (41.25, 82.5)
1
Window 0.87
Viewport
0.50
0 xw
1 ymax
1 xmax
0 1
WC NDC PDC
y P8 y
P2
P7 Window Window
ywmax ywmax
P3
P9 P3 P4 P1 P4 P1
P’9
P10
P’10
P5 P5
ywmin ywmin
P6 P’6
y
C D
ywmax
B
A
ywmin
xwmin xwmax x
ywmax B
D
A C
ywmin
xwmin xwmax x
Basic Idea
n Encode the line endpoints
Region outcodes:
1000
D
1001 C
1010 S
B G H R
F
A 0000
0001 Q 0010
E P
N
M
0101 0100 0110
P1
tline
V4 tedge V3
P0
V1 V2
o Outside Inside
clipping clipping
rectangle rectangle
Edge Ei
PEi
P1
Ni ∙ [Pi(t) – PEi] = 0
Ni
P1
φ
t=1
N
PE P1 P1
N
φ Line 2 t=1 t=1
PL PL
PL PE Line 1
P0 Line 3
t=0
P0 PL
t=0
PE
Clipping rectangle
PE
P0
t=0
E1 L1
P Q E2
B
n
Computing normal vector of the edge: C
1. Compute the normal vector of the plane
N = AB x BC
(cross product of two consecutive edges)
2. Normal vector of the edge
n = AB x N
(cross product of the edge and normal
vector of the plane)
D
E1 L3
Q E2 L1 E3
P B
E
P5
P3
Cyrus-Beck algorithm:
o Simplifies the Cyrus-Beck algorithm for the particular case of clipping window as
an horizontal rectangle:
2. The dot product Ni ∙ (P0 – PEi) determining whether the endpoint P0 lies
inside or outside a specific edge, reduces to the directed horizontal or
vertical distance from the point to the edge.
If dx >0, the line moves from left to right and is PE for the left edge, PL
for the right edge, and so on.
o General definition:
n Sequence of vertices with implicit relationships
n By clipping: 1 polygon (v1, v2, …., vn) ®
p polygons (A11, A12, …, A1k; …Ap1, Ap2, …,Apq)
o Display:
n set of points
n set of lines (wire-frame)
n closed multicolor polyline
n set of polygons
n filled polygons
Original
Polygon
I
P S P
S
P S
I
P S
Window
3
Window
2 3 1’ 2’
2’ (8’)
2 1’
1 4 3’
5 4’
1 4
3’ 5’
6 6’
5’ 7’
6 4’
7
5 (a) (b)
Before Clipping
After Clipping
o 4 cases:
2
a) out - > in
b) in -> in
c) in -> out 1
d) out - > out
e) follow clip edge
4 3
2 2 2
2
1’ 1’ 1’ 1’
3’ 3 3
3
3’
2 2 2 2
1’ 1’ 1’ 1’
3 3’ 3 3’ 3 3’ 3
4 4 4
3’
4 4’ 4’ 4’
5 5 5
5’ 5’
2 2 2
1’
1’ 1 1’
3 3 3’ 3
3’ 3’ 4’
4 4 4’ 5
4’ 5 5
6 6 5’
5’ 5’
Final Result:
Continue from Nothing added. 2 unconnected
cached vertex and Finished polygons
direction
B A4 B4
A2 A3 A6 A5 B5
A7
A6
B4
A7
B2 A8 A9
A8
A9
B3 A10
A2 A3 C3 A6 A5 B5
A7
A6
B4
A7
B2 A8 A9
C4 A8
A9
B3 A10
A8
A9
A10
A8
A9
A10
A8
A9
A10
A8
A9
A10
A8
Entering vertex
Leaving vertex
A9
A10
Clipped polygons: A8
Polygon 1: C1, A2, A3, C2
Polygon2: C3, A7, A8, C4, B5 A9
A10
STRING1
All or none
text clipping
STRING2 STRING2
STRING1 ING1
All or none
character clipping
STRING3 TRING3
STRING4 STRING4
STRING1 STRING1
Clipping individual
character
Figure 1
E
B
P Q Q1 Q2
C D
Figure 2
A
A
b.
a.
Figure 3
c.
a. b.
Figure 4
a. b.
Figure 5
c.
a. B
A b. B
A
B
Figure 6
Figure 7
Figure 8
C