Skip to content

Fix missing p_start update in hinge midpoint loop#397

Open
asinghvi17 wants to merge 3 commits intomainfrom
fix/within-hinge-midpoint-tracking
Open

Fix missing p_start update in hinge midpoint loop#397
asinghvi17 wants to merge 3 commits intomainfrom
fix/within-hinge-midpoint-tracking

Conversation

@asinghvi17
Copy link
Copy Markdown
Member

@asinghvi17 asinghvi17 commented Apr 4, 2026

Summary

  • Fixes a bug where _line_filled_curve_interactions failed to advance p_start in the line_hinge midpoint-checking loop, causing all midpoints to be computed from the original line start instead of between consecutive intersection points
  • This caused within (and potentially other DE-9IM predicates) to return incorrect results when polygon edges were collinear with the boundary of another polygon containing a notch/indentation

Details

The hinge handler splits a line segment at all intersection points with a curve, then checks the midpoint of each sub-segment to determine if it's inside, on, or outside the filled curve. Without advancing p_start, the midpoints were wrong — for example, a midpoint that should have been (0, 2.5) (outside the polygon) was instead computed as (0, 3.0) (on the boundary), so the "outside" flag was never set.

The fix is a single line: p_start = p_end at the end of the loop body.

Fixes #396

Test plan

🤖 Generated with Claude Code

asinghvi17 and others added 2 commits April 4, 2026 06:41
…ge handler

The midpoint-checking loop in the `line_hinge` branch never advanced
`p_start`, so every midpoint was computed from the original line start
instead of between consecutive intersection points. This caused
sub-segments outside a curve to go undetected, making predicates like
`within` return incorrect results for polygons sharing collinear edges
with a notch.

Fixes #396

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@asinghvi17 asinghvi17 force-pushed the fix/within-hinge-midpoint-tracking branch from afe7c2a to 92a8d43 Compare April 4, 2026 11:08
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@asinghvi17 asinghvi17 requested a review from skygering April 4, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GeometryOps.within(poly1, poly2) inconsistent with LibGEOS.within(poly1, poly2)

1 participant