Listing 1 Part 1 of the clipping algorithm, applied to every vertex

enter with vertex CurrentPoint
IF first point THEN
       store CurrentPoint as FirstPoint for later use
ELSEIF the line from LastPoint to CurrentPoint
             intersects edge THEN
       output the intersection point
ENDIF
IF CurrentPoint is on visible side of edge THEN
       output CurrentPoint
ENDIF
store CurrentPoint as LastPoint for later use

* End of File */