Skip to content

Move closing-edge check outside loop in _point_in_polygon - #945

Open
ecomodeller wants to merge 2 commits into
mainfrom
fix/point-in-polygon-perf
Open

Move closing-edge check outside loop in _point_in_polygon#945
ecomodeller wants to merge 2 commits into
mainfrom
fix/point-in-polygon-perf

Conversation

@ecomodeller

Copy link
Copy Markdown
Member

Why

The closing-edge check (last→first vertex) in _point_in_polygon was inside the inner loop, evaluating redundantly on every iteration. While functionally correct, the check is logically part of the polygon boundary test and belongs after the loop. Moving it out makes the code clearer about what each section does.

What this adds

  • Moves the closing-edge cross-product check after the loop
  • 6 tests: triangle/quad point classification, closing-edge cases, centroid-based element lookup, and exhaustive find_index correctness on FakeLake mesh

The closing edge (last→first vertex) was checked inside the loop,
running n-1 redundant times. Move it after the loop. Add tests for
point-in-polygon and element search correctness.
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.

1 participant