Skip to content

fix(sch): round schematic wire coordinates to prevent floating-point disconnections#300

Open
watcharaponthod-code wants to merge 4 commits intotscircuit:mainfrom
watcharaponthod-code:fix/schematic-wire-floating-point-precision
Open

fix(sch): round schematic wire coordinates to prevent floating-point disconnections#300
watcharaponthod-code wants to merge 4 commits intotscircuit:mainfrom
watcharaponthod-code:fix/schematic-wire-floating-point-precision

Conversation

@watcharaponthod-code
Copy link
Copy Markdown

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 of 10.16
  • 3.9999999... instead of 4.0

Because 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

… 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
@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

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

Project Deployment Actions Updated (UTC)
circuit-json-to-kicad Ready Ready Preview, Comment May 10, 2026 3:57pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant