Commit Graph
9 Commits
Author SHA1 Message Date
94xhn 20b9e346e5 AP_Math: fix Polygon_closest_distance_line to include closing edge
Polygon_closest_distance_line()'s fallback loop (used whenever the
query line does not cross the polygon) iterated i=0..N-2 and never
tested the closing edge V[N-1]->V[0]. Every other polygon helper in
this file (Polygon_outside, Polygon_intersects) and the sibling
Polygon_closest_distance_point() already wrap around to include this
edge; this function was the one left behind.

The only caller, AP_OABendyRuler::calc_margin_from_inclusion_and_exclusion_polygons(),
passes in AC_Fence polygons in their raw unclosed form (no duplicated
closing vertex), so in real fences this is a genuine edge that was
silently skipped, causing the reported clearance/margin to the fence
boundary to be overestimated near that edge.

Fix mirrors the existing wrap-around pattern from Polygon_intersects()
a few lines above in the same file. Added a regression test using a
simple square fence to confirm the closing edge is now considered and
that behaviour near unaffected edges is unchanged.

Assisted-by: Claude:claude-sonnet-5
2026-07-13 09:43:45 +10:00
Andy Piper 14bc825f74 AP_Math: remove new distance to point code 2025-04-09 17:01:04 +01:00
Andy Piper abaa64a754 AP_Math: correct Polygon_closest_distance_point() for use with lat/lng at small distances
add polygon proximity tests
2025-04-09 17:01:04 +01:00
Peter Barker 977fe09276 AP_Math: add a more complex polygon for Polygon_outside tests 2019-05-29 15:34:02 +10:00
Peter Barker d3971c18fa AP_Math: more tests for closed-vs-open polygons 2019-05-29 15:34:02 +10:00
Peter Barker d74e6db12e AP_Math: add more tests for Polygon_outside 2019-05-29 15:34:02 +10:00
Peter Barker 36fe9a18a0 AP_Math: make Polygon_outside cope with being passed unclosed polygons 2019-05-29 15:34:02 +10:00
Peter Barker 64aafb2af2 AP_Math: add Polygon_outside tests for long template instantiation 2019-05-28 09:08:07 +10:00
Peter Barker b35b65eed1 AP_Math: add GTEST suite for Polygon_outside 2019-05-28 09:08:07 +10:00