fix(sch): round schematic wire coordinates to prevent floating-point disconnections#300
Open
watcharaponthod-code wants to merge 4 commits intotscircuit:mainfrom
Conversation
… drift Coordinates from applyToPoint(c2kMatSch, ...) can accumulate floating-point errors (e.g., 10.1599999 instead of 10.16), causing wires to appear visually connected but electrically disconnected in KiCad schematic files. Round all transformed coordinates to 4 decimal places (0.0001mm precision) to eliminate drift while preserving sub-micron positional accuracy. Fixes tscircuit#292 tscircuit#283
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes schematic wire-to-pin disconnections caused by floating-point precision errors in coordinate transformations (issues #283, #292).
Root Cause
After
applyToPoint(c2kMatSch, ...), coordinates can accumulate floating-point drift:10.1599999...instead of10.163.9999999...instead of4.0Because KiCad determines connectivity by exact coordinate matching, these tiny errors cause wires to appear visually connected but register as electrically disconnected in the netlist.
Fix
Round all transformed wire endpoint and junction coordinates to 4 decimal places (0.0001mm = 100nm precision) in
AddSchematicTracesStage.ts. This eliminates drift artifacts while preserving far more accuracy than KiCad's actual grid resolution (0.25mm).Test
Added
repro11-wire-floating-point-precision.test.tsx: verifies all exported wire(xy ...)coordinates have ≤ 4 decimal places.Closes #292
Closes #283