Polygon CLipping
Polygon CLipping
a picture
which is either inside or outside a
picture is referred to as a clipping algorithm or
clipping.
In geometry a polygon is a flat shape
consisting of straight lines that are joined to
form a circuit. A polygon is traditionally a
plane figure that is bounded by a closed path,
composed of a finite sequence of straight line
segments (i.e., by a closed polygonal chain).
These segments are called its edges or sides,
and the points where two edges meet are the
polygon's vertices. The interior of the polygon
is sometimes called its body.
Polygon Clipping
A polygon boundary processed with a line clipper
may be displayed as a series of unconnected line
segments,depending on the orientation of the
polygon to the clipping window. What we really want
to display is a bounded area after clipping. For
polygon clipping, we require an algorithm that will
generate one or more closed areas that are then
scan converted for the appropriate area fill. The
output of a polygon clipper should be a sequence of
vertices that defines the clipped polygon
boundaries.
In 2D graphics for example, if the user of an image
editing program is modifying an image and has
"zoomed in" the view to display only the top half of
the image, there is no need for the program to
spend any CPU time doing any of the calculations or
memory moves needed to display the bottom half.
By clipping the bottom half of the image and
SutherlandHodgeman algorithm
The SutherlandHodgeman algorithm is used for clipping
polygons. It works by extending each line of the convex clip
polygon in turn and selecting only vertices from the subject
polygon that are on the visible side
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
v1
v1
v1
v3
v2
v3
v2
v3
outside
inside
v2
v1
outside
inside
v2
v1
Outside to inside:
Output: v1 and v2
outside
inside
v2
outside
inside
v2
v1
v1
v1
Inside to inside:
Output: v2
Inside to outside:
Output: v1
v1
Outside to outside:
Output: nothing
v2
v3
v2
v1
v3
Left
Clipper
v1
Right
Clipper
Bottom
Clipper
v1v2
v2
v2v2
v2
v2v3
v2v3
v2
v2v3
v3
v3v1
v3v1
v3v1
v1v2
v1
v2
Edges
Output
Edges
Output
v2
Top
Clipper
v2v1
v1
v3v1
v1v2
v2
v1v2
v1v2 v2v2
v2v2
v2
v2v2
Edges
Output
Edges
v2
v2
Output
Final
Sutherland-Hodgman
Weiler-Atherton