Skip to main content
QUICK REVIEW

[Paper Review] A Simple and Correct Even-Odd Algorithm for the Point-in-Polygon Problem for Complex Polygons

Michael Galetzka, Patrick Glauner|arXiv (Cornell University)|Jul 15, 2012
Computational Geometry and Mesh Generation4 citations
TL;DR

This paper presents a simple, correct, and O(n)-time even-odd algorithm for the point-in-polygon problem in complex polygons—those with self-intersecting edges and holes. By using auxiliary edges to safely handle vertices on the x-axis and extending the ray to the full x-axis when needed, the algorithm avoids special-case failures and guarantees correct even-odd intersection counting for all inputs.

ABSTRACT

Determining if a point is in a polygon or not is used by a lot of applications in computer graphics, computer games and geoinformatics. Implementing this check is error-prone since there are many special cases to be considered. This holds true in particular for complex polygons whose edges intersect each other creating holes. In this paper we present a simple even-odd algorithm to solve this problem for complex polygons in linear time and prove its correctness for all possible points and polygons. We furthermore provide examples and implementation notes for this algorithm.

Motivation & Objective

  • To address the high error rate in implementing point-in-polygon checks for complex polygons with self-intersecting edges and holes.
  • To eliminate special-case handling for points on edges or vertices, which commonly break existing algorithms.
  • To provide a provably correct even-odd algorithm that works for all possible polygon configurations, including complex ones.
  • To ensure linear time complexity O(n) while maintaining simplicity and correctness.

Proposed method

  • The algorithm casts a ray from the point Q along the positive x-axis and counts edge intersections.
  • Vertices lying on the x-axis are skipped, and auxiliary edges are created between non-collinear vertices across the x-axis.
  • When a vertex on the positive x-axis is skipped, the ray is extended to the full x-axis to preserve correct intersection count.
  • The algorithm checks for point equality with vertices or edge containment first, returning 'inside' immediately if true.
  • Intersection detection uses robust geometric functions to determine if an auxiliary edge crosses the x-axis.
  • The final decision is based on whether the total number of intersections is odd (inside) or even (outside).

Experimental results

Research questions

  • RQ1Can a simple even-odd algorithm be designed that correctly handles all edge cases in complex polygons without special-case workarounds?
  • RQ2How can vertices lying on the ray (e.g., the x-axis) be safely handled to preserve intersection count accuracy?
  • RQ3Is it possible to maintain O(n) time complexity while ensuring correctness across all polygon types, including self-intersecting ones?
  • RQ4Can auxiliary edges be used as valid substitutes for original polygon edges in intersection counting without introducing errors?

Key findings

  • The algorithm is proven correct for all possible points and complex polygons, including those with self-intersections and holes.
  • The use of auxiliary edges when skipping x-axis vertices ensures accurate intersection counting, even when original edges do not cross the positive x-axis.
  • Extending the ray to the full x-axis when a positive x-axis vertex is skipped correctly captures necessary intersections, as verified across 10 distinct geometric configurations.
  • The algorithm avoids special-case checks by design, eliminating common failure modes in existing implementations.
  • The time complexity is O(n), as each vertex is visited exactly once during traversal.
  • The open-source implementation confirms the algorithm's correctness and practicality for real-world use.

Better researchstarts right now

From reading papers to final review, dramatically reduce your research time.

No credit card · Free plan available

This review was created by AI and reviewed by human editors.