0% found this document useful (0 votes)
6 views17 pages

Polygon Clipping

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 17

Sutherland- Hodgman Polygon Clipping

The Sutherland-Hodgman algorithm performs a


clipping of a polygon against each window edge in
turn.
The order to clip the polygon should be:
1. Clipping against the left side of the clip window.
2. Clipping against the top side of the clip window.
3. Clipping against the right side of the clip window.
4. Clipping against the bottom side of the clip window.
Ssutherland- Hodgman Polygon Clipping

Before clipping

(a)( (b) (cj (d)


After Clipped
sutherland- Hodgman Polygon Clipping
It consist of Four Cases:
1. If the first vertex of the edge is outside the window
and second vertex is inside then the intersection
point of the polygon edge with the window
boundary and the second vertex are added to the
output vertex list.
” V2

Save {v’1 and v2} a ae


Sutherland- Hodgman Polygon Clipping
2. If the both vertices of the edge are inside the
window. Then only second vertex is added to the
output vertex list.
V1

Save {v2} |
V2
sutherland- Hodgman Polygon Clipping
3. If the first vertex of the edge is inside the window
and second vertex is outside then only the intersection
point of the polygon edge with the window boundary
is added to the output vertex list.

Save {v’1}
Vi
Ssutherland- Hodgman Polygon Clipping
4. If the both vertices of the edge are outside the
window. Then nothing is added to the output vertex
list. v1

Save {0}
V2
eC Area Clipping (polygons)
To clip a polygon, we cannot directly apply
a fline-clipping method to the individual
polygon edges because this approach would
produce a_ series of unconnected line
segments as shown in figure .
* Area Clipping (polygons)
The clipped polygons must be a bounded area after
clipping as shown in figure.

Concave Polygon _- : A \
/ \

h l/ \ |

‘For polygon clipping, we require an algorithm that


will generate one or more closed areas that are
then scan converted for the area fill.
* The output of a polygon oppor should be a
ie Sg of vertices at defines the clipped
polygon boundaries.
3
© Sutherland-Hodgman Polygon Clipping

‘Clip a polygon by processing the polygon boundary


against each window edge. (Left, Top, Bottom, Right).

* Apply four cases to process ail polygon edges to


produce sequence of vertices. This sequence of
vertices will make a bounded area.
* Beginning with the initial set of polygon vertices, we
could first clip the polygon against the left rectangle
boundary to produce a new sequence of vertices.
* The new set of vertices could be successively passed
to a right boundary clipper, a bottom boundary clipper,
and a top boundary clipper.
eC Sutherland-Hodgman Polygon Clipping

At each step, a new sequence


of output vertices is generated
and passed to the next window
boundary clipper.
© Sutherland-Hodgman Polygon Clipping
There are four possible cases when processing
vertices in sequence around the perimeter of a
polygon.
As each pair of adjacent polygon vertices is
passed to a next window boundary clipper, we
make the following tests:
J Sutherland-Hodgman Polygon Clipping
7. /f the first vertex is outside the window
boundary and the second vertex is inside
Then , both the intersection point of the
polygon edge with the window boundary
and the second vertex are added to the
Output Vertex FISt resumes

Vee ee eee eeeeee eee eeenee


J Sutherland-Hodgman Polygon Clipping
2./f both input vertices are inside the
window boundary.
Then, only the second vertex is added to
the output vertex list.

Veccccccccccccscsocesecs
J Sutherland-Hodgman Polygon Clipping
3./f the first vertex is inside the window
boundary and the second vertex is
outside.

Then, only the edge intersection with the


window boundary is added to the output
vertex list.
oe Sutherland-Hodgman Polygon Clipping
4./f both input vertices are outside the
window boundary.
Then, nothing is added to the output vertex
list.

10
eC Sutherland-Hodgman Polygon Clipping (Example)
We illustrate this algorithm by processing the area in
figure against the left window boundary.

Vertices 1 and 2 are outside of the


boundary.
Vertex 3, which is inside, 1' and 5
vertex 3 are saved.

Vertex 4 and 5 are inside, and they


also saved.

Vertex 6 is outside, 5' is saved.

Using the five saved points, we


would repeat the process for the
next window boundary.
e Sutherland-Hodgman Polygon Clipping
The Sutherland-Hodgman algorithm correctly
clips convex polygons, but concave polygons
may be displayed with extraneous lines as
demonstrated in figure.
Since there is only one output vertex list, the last
vertex in the list is always joined to the first
vertex.

12

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy