This applet was created for course Webovská grafika (Web Graphics). Applet should implement Sutherland-Hodgeman algorithm for clipping polgyon according to rectangle.
Algorithm is based on in clipping of polygon step by step in four phases. It clippes according to given rectangle, always from one side at the time.
In i-iteration we take i and i+1 point of (not yet clipped) polygon.
Always according to one co-ordinate of clipping area may 4 cases occur:
We repeat these steps for entire sequence of points according to every side of clipping area (rectangle). After end of loop, we overwrite original sequence of points of polygon with new (clipped) sequence of points of polygon. When algorithm ends polygon is clipped.
This algorithm is used in this applet. Selection of what polygon side will be clipped at first is up to user. Functionality and result of algorithm is not depending on side from which is polygon clipped.
Two persons work on this project. Me (Marek Sivčo) and Michal Stanko. Link to site of my colleague:
michalstanko.net.