feat(cam): exact distance-to-boundary and inscribed-circle seed finding #57

Merged
patman merged 1 commit from patman/cam-seed into main 2026-07-09 23:27:52 +00:00 AGit
Owner

PR5 of the adaptive-clearing roadmap: distance_to_segment (exact planar point-to-line/arc distance, proven correct across the angular-range transition and at the arc center), distance_to_boundary over a StockState (same coplanarity contract as the other queries), and largest_inscribed_circle — the spiral-seed primitive (coarse grid + 6-round shrinking-window refinement, running-best monotone, accuracy ~final cell size of a local optimum, documented limits on sub-pitch features). Reviewer-verified highlight: the square-with-island seed optimum is the diagonal three-constraint balance (L+r0)/(1+1/sqrt(2)) − r0 ≈ 2.1005, independently re-derived. Also exposes arc_angle_hit/plane() as pub(crate) and adds QueryError::{EmptyBoundary, InvalidGrid, NoSeedFound} (empty stock is an error here by design — engagement returns Ok(0) for the same input; rationale documented). Stacked on patman/cam-offset-guards (#54).

PR5 of the adaptive-clearing roadmap: distance_to_segment (exact planar point-to-line/arc distance, proven correct across the angular-range transition and at the arc center), distance_to_boundary over a StockState (same coplanarity contract as the other queries), and largest_inscribed_circle — the spiral-seed primitive (coarse grid + 6-round shrinking-window refinement, running-best monotone, accuracy ~final cell size of a local optimum, documented limits on sub-pitch features). Reviewer-verified highlight: the square-with-island seed optimum is the diagonal three-constraint balance (L+r0)/(1+1/sqrt(2)) − r0 ≈ 2.1005, independently re-derived. Also exposes arc_angle_hit/plane() as pub(crate) and adds QueryError::{EmptyBoundary, InvalidGrid, NoSeedFound} (empty stock is an error here by design — engagement returns Ok(0) for the same input; rationale documented). Stacked on patman/cam-offset-guards (#54).
Adds CAM/geom/src/distance.rs: distance_to_segment (exact planar
distance to a line or arc segment), distance_to_boundary (min over a
StockState's boundary contours), and largest_inscribed_circle (coarse
grid + iterative local refinement to seed spiral/adaptive clearing).
Makes query::arc_angle_hit and StockState::plane pub(crate) for reuse
instead of duplicating their logic, and adds QueryError::EmptyBoundary,
InvalidGrid, and NoSeedFound to cover the new failure modes.

Co-authored-by: patman-assist <patrick-ai@kgroo.co>
patman changed target branch from patman/cam-offset-guards to main 2026-07-09 23:27:50 +00:00
patman merged commit be4c26b347 into main 2026-07-09 23:27:52 +00:00
Sign in to join this conversation.
No description provided.