Virendra Singh Kushwah Assistant Professor Department of Computer Science
A convex polygon will always have an interior angle with a measure that is less than 180 degrees.
A concave polygon will always have an interior angle with a measure that is greater than 180 degrees.
v1
v1
v1 v3 v3
v2
v3
v2
Note: Need to consider each of 4 edge boundaries
Input each edge (vertex pair) successively. Output is a new list of vertices. Each edge goes through 4 clippers. The rule for each edge for each clipper is:
If first input vertex is outside, and second is inside, output the intersection and the second vertex If first both input vertices are inside, then just output second vertex If first input vertex is inside, and second is outside, output is the intersection If both vertices are outside, output is nothing
outside
inside v2
outside
inside v2
outside v2 v1
inside
outside v2
inside
v1
v1 v1
Inside to inside: Output: v2
v1
v1
Outside to outside: Output: nothing
Outside to inside: Output: v1 and v2
Inside to outside: Output: v1
before clipping
after clipping
before clipping
after clipping
original polygon
left clip
right clip
bottom clip
top clip
D
S
I
D
D
I
D
S
S
Save D. (a)
Save I. (b)
No Points Saved. (c)
Save I and P. (d)
window
3
window
2 1
1
3
5
4
5
(a)
(b)
Similar methods as for lines and polygons but more processing is required due to nonlinear equations. For a curved object a bounding rectangle can be used to make a first test for overlap.
before clipping
after clipping
Line clipping using nonrectangular polygon clip windows
Convex polygon
Cyrus-Beck algorithm can be readily extended
Concave polygon
Split the concave polygon into convex polygons
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
Polyline vs polygon fill-area
Early rejection is useful
Bounding box of polygon fill area
Clipping Window
Clip against 4 infinite clip edges in succession
Accept a series of vertices (polygon) and outputs another series of vertices Four possible outputs
The algorithm correctly clips polygons, but may display extraneous lines for polygons
For an outside-to-inside pair of vertices, follow the polygon boundary For an inside-to-outside pair of vertices, follow the window boundary in a clockwise direction
Polygon clipping using nonrectangular polygon clip windows
In general, methods depend on how characters are represented However, three strategies can be followed: all-or-none string clipping
all-or-none character clipping
use a bounding rectangle for the string
individual character clipping
use a bounding rectangle for the character like line/curve clipping (outlined chars) compare individual pixels (bit-mapped)
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