How to intersect two polygons?

Arash Partow’s FastGEO library contains implementations of many interesting algorithms in computational geometry. Polygon intersection is one of them. It’s written in Pascal, but it’s only implementing math so it’s pretty readable. Note that you will certainly need to preprocess your edges a little, to get them into clockwise or counterclockwise order.

ETA: But really, the best way to do this is to not do this. Find another way to approach your problem that doesn’t involve arbitrary polygon intersections.

Leave a Comment