Point | Coordinates | outcode |
---|---|---|
A | (.3, .3) | 0000 |
B | (.5, .8) | 0000 |
C | (-1.2, .4) | 0001 |
D | (1.5, .4) | 0010 |
E | (-1.1, 1.2) | 1001 |
F | (.9, -.2) | 0100 |
G | (1.1, 1.1) | 1010 |
List outputList = subjectPolygon; for (Edge clipEdge in clipPolygon) do List inputList = outputList; outputList.clear(); Point S = inputList.last; for (Point E in inputList) do if (E inside clipEdge) then if (S not inside clipEdge) then outputList.add(ComputeIntersection(S,E,clipEdge)); end if outputList.add(E); else if (S inside clipEdge) then outputList.add(ComputeIntersection(S,E,clipEdge)); end if S = E; done done