module

PolygonContains::Spherical

Instance methods

contains?(polygon : Array(Array(Point)), point : Point) : Bool

Spherical Winding Number Method Based on Chamberlain & Duquette (2007) and D3-Geo

Chamberlain-Duquette algorithm steps (adapted for meridian-crossing approach):

  1. Convert polygon vertices and test point to Cartesian coordinates on unit sphere
  2. For each edge, check if it crosses the test point's meridian
  3. For crossing edges, compute the geodesic arc and its intersection with the meridian
  4. Update winding number based on crossing direction (clockwise/counter-clockwise)
  5. Determine containment: odd winding number = inside, even = outside
Source