How to intersect two polygons?
问题 This seems non-trivial (it gets asked quite a lot on various forums), but I absolutely need this as a building block for a more complex algorithm. Input : 2 polygons (A and B) in 2D, given as a list of edges [(x0, y0, x1, y2), ...] each. The points are represented by pairs of double s. I do not know if they are given clockwise, counter-clockwise or in any direction at all. I do know that they are not necessarily convex. Output : 3 polygons representing A, B and the intersecting polygon AB.