# Complexity of polygon intersection test

In the book "Spatial Databases: With Application to GIS (The Morgan Kaufmann Series in Data Management Systems)", there's a section on simple polygon intersection detection , and it mentions

...The cost is dominated by the LINEINTERSECTIONTEST algorithm. Therefore, detecting whether two simple polygons intersect is O(n log n). This is optimal...

But it doesn't provide a source for the claim that this is optimal. Does anyone know if this is indeed the case, and if so, how it's proven?

• This is not a research level question, so it does not belong to the website. If $P_1, P_2$ are polygons with $n_1, n_2$ vertices respectively with $n=n_1+n_2$ , then you can compute the union, intersection, and symetric difference in $O(n\log n)$ using sweeping + map overlays. This is standard in most computational geometry books (see for example the Berg book, Chapter 2). Commented May 23, 2023 at 8:52
• Your second comment is also false. I had a look at the Chapter you mention. The authors correctly state that they give algorithms for computing the intersection of two convex polygons in $O(n)$, not if there is an intersection. The classic Chazelle $O(\log n)$ algorithm is for detecting if the polygons intersect, not for computing their intersection. The intersection complexity can be $\Omega(n)$ and so $O(n)$ is indeed optimal. Commented May 23, 2023 at 8:54
• Thanks for your answer. I think you're misunderstanding my question. I understand why the algorithm they proposed is O(n log n), I'm curious about their claim that this is optimal. This seems far from trivial to me, so if it's indeed true, then I'm curious to see a proof. Commented May 23, 2023 at 9:03
• "In the next section, it provides a linear time algorithm to determine whether" This is just false, this is not what the authors say. The authors write: "We present a simple algorithm for computing the intersection of two convex polygons, which achieves the optimal O(n) complexity" Commented May 23, 2023 at 9:07
• That doesn't proof it. The line segment intersection test works with any arbitrary set of segments, while in our case, we know the segments form two simple polygons, so we have a lot more information. Commented May 23, 2023 at 9:10

TL;DR: Yes, in principle this can be done in $$O(n)$$ and the book is inaccurate.
This is quite subtle, the first statement is not correct. Returning all intersections has a $$\Omega(n\log n)$$ lower bound, but detecting intersections (if any) can be done in $$O(n)$$ time.
Chazelle proved that detecting a polygon curve self intersection can be done in $$O(n)$$ time via his linear time triangulation. You simply assume a curve is not self intersecting and try to triangulate it. The algorithm will detect if something goes wrong (because of the self intersection).
You can reduce detecting if two polygons $$P,Q$$ intersect into detecting if a polygonal curve $$R$$ self intersects by "connecting" the two polygons in $$O(n)$$ time. I remember this trick from a paper by David Mount but I do not remember the reference. The proof idea is connecting the two polygons by a very thin slab (in red) and checking if the resulting polygonal curve self intersects: