Sutherland–Hodgman algorithm: Difference between revisions

Content deleted Content added
m Cleaning up a randomly generated list, removed stub tag using AWB
No edit summary
Line 14:
Given a list of edges in a clip polygon, and a list of vertices in a subject polygon, the following procedure clips the subject polygon against the clip polygon.
 
List outputList = subjectPolygon;
for (Edge clipEdge in clipPolygon) do
List inputList = outputList;
outputList.clear();
Point Slast_point = inputList.last;
//
for (Point Ecurrent_point in inputList) do
if (Ecurrent_point inside clipEdge) then
if (Slast_point not inside clipEdge) then
outputList.add(ComputeIntersection(Slast_point,Ecurrent_point,clipEdge));
end if
outputList.add(Epoint);
else if (Slast_point inside clipEdge) then
outputList.add(ComputeIntersection(Slast_point,Ecurrent_point,clipEdge));
end if
Slast_point = Ecurrent_point;
done
done