Content deleted Content added
Cooperised (talk | contribs) →Description: Improved algorithm description, changed to passive voice |
Cooperised (talk | contribs) →Pseudo Code: Completely rewritten for consistency with the algorithm description (see talk page) |
||
Line 12:
==Pseudo Code==
Given a
List outputList = subjectPolygon;
for (Edge clipEdge in clipPolygon) do
outputList.clear();
if (E inside clipEdge) then
{▼
if
outputList.add(ComputeIntersection(S,E,clipEdge));
▲ Output( ComputeIntersection( P, S, clip_plane ) )
The vertices of the clipped polygon are to be found in ''outputList'' when the algorithm terminates. Note that a point is defined as being ''inside'' an edge if it lies on the same side of the edge as the remainder of the polygon. If the vertices of the clip polygon are consistently listed in a clockwise direction, then this is equivalent to testing whether the point lies to the right of the line, and can be implemented simply by using a [[dot product]].
''ComputeIntersection'' is a trivial function, omitted here for clarity, which returns the intersection of a line segment and an infinite edge. Note that it is only called if such an intersection is known to exist, and hence can simply treat both lines as being infinitely long.
==See also==
|