Sutherland–Hodgman algorithm

Vertices from the input list are inserted into an output list if they lie on the visible side of the extended clip polygon line, and new vertices are added to the output list where the subject polygon path crosses the extended clip polygon line.

The Weiler–Atherton algorithm overcomes this by returning a set of divided polygons, but is more complex and computationally more expensive, so Sutherland–Hodgman is used for many rendering applications.

The vertices of the clipped polygon are to be found in outputList when the algorithm terminates.

If the vertices of the clip polygon are consistently listed in a counter-clockwise direction, then this is equivalent to testing whether the point lies to the left of the line (left means inside, while right means outside), and can be implemented simply by using a cross product.

ComputeIntersection is a function, omitted here for clarity, which returns the intersection of a line segment and an infinite edge.

All steps for clipping concave polygon 'W' with a 5-sided convex polygon