Skip to content

fix: near-axis-aligned segments no longer escape obstacle collision - #1109

Open
tbontb-iaq wants to merge 1 commit into
tscircuit:mainfrom
tbontb-iaq:fix/near-axis-collision-escape
Open

tbontb-iaq wants to merge 1 commit into
tscircuit:mainfrom
tbontb-iaq:fix/near-axis-collision-escape

Conversation

@tbontb-iaq

Copy link
Copy Markdown

Fixes #1099

/attempt #1099

Root cause

segmentIntersectsRect returned false for every segment that is neither exactly vertical nor exactly horizontal. Real pin coordinates are not always exactly on the routing grid — a pin at x = 5.3999378 connected to one at x = 5.4 produces a segment with dx = 6.22e-5: far below the schematic grid, yet five orders of magnitude above the 1e-9 axis-alignment EPS. Such segments passed every obstacle check, and UnroutedTraceRecoverySolver accepted the first skewed candidate as collision-free.

Fix

Non-axis-aligned segments now run a slab (Liang-Barsky) clip against the obstacle rect. The axis-aligned fast paths keep their historical semantics:

  • a real interior overlap counts as a collision,
  • a segment that merely touches an edge or corner does not (tMax - tMin > eps on the slanted path).

Verification

  • New regression tests in tests/solvers/SchematicTraceSingleLineSolver2/segment-intersects-rect-near-axis.test.ts cover: near-vertical/near-horizontal segments crossing a chip body (previously false, now true), near-axis segments outside the rect, slanted crossings, and corner-touching glances (still collision-free).
  • Full suite: 353 pass, 0 fail (347 pass pre-existing + 6 new tests); no snapshot changes — routing output is unchanged for exactly axis-aligned inputs.

@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
schematic-trace-solver Ready Ready Preview Sep 9, 2026 3:14am UTC

Request Review

segmentIntersectsRect declared any segment that is neither exactly
vertical nor exactly horizontal collision-free. Real pin coordinates
are not always exactly on the routing grid (e.g. x = 5.3999378 next to
x = 5.4), so nearly axis-aligned segments sailed through chip bodies
and were accepted by UnroutedTraceRecoverySolver as collision-free.

Non-axis-aligned segments now run a slab (Liang-Barsky) clip against
the rect. Axis-aligned fast paths keep their historical semantics:
a real interior overlap counts, a segment that merely touches an edge
or corner does not (tMax - tMin > eps for the slanted path).

Fixes tscircuit#1099
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.

bug: nearly axis-aligned segments escape all obstacle collision checks, letting traces pass through chips

1 participant