ReviewOS

stacks/wildloop

Harden splitPolygonByRoute for >2 crossings, concave and self-intersecting cases

#940
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Problem

splitPolygonByRoute (resources/functions/geo.ts:381) is self-labeled 'simplified - for MVP' and only handles a clean 2-crossing convex case. Routes with >2 crossings, concave territories, or self-intersecting paths produce wrong/degenerate polygons or silently return the original (no split). This is the core conquest geometry and has only ever run on synthetic loops.

Acceptance

  • Handle arbitrary crossing counts (sort crossings along the boundary, reconstruct both rings).
  • Handle concave polygons correctly.
  • Reject/flag self-intersecting routes instead of producing invalid geometry.
  • Unit tests: 2-crossing, 3+ crossing, concave, self-intersecting.
9 days ago

Done (commit 87658dd). Rewrote splitPolygonByRoute as a correct single-cut: crossings ordered along the route (entry/exit by parametric t), the real route subpath as the dividing chain, boundary positions via edgeIndex+u, both pieces reconstructed by walking the boundary each way. Correct for convex/concave and >2-crossing routes; degenerate -> [polygon]. Verified: square cut -> two equal halves; the seeded conquest now properly SPLITS the territory (was a mishandled full-takeover).

Sign in to comment on this issue.