@tscircuit/schematic-trace-solver 0.0.27 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -0
- package/dist/index.js +177 -8
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver/SchematicTraceSingleLineSolver.ts +40 -1
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver/generateElbowVariants.ts +129 -6
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver/getRestrictedCenterLines.ts +139 -0
- package/package.json +1 -1
- package/site/SchematicTracePipelineSolver/SchematicTracePipelineSolver01.page.tsx +143 -0
- package/site/examples/example08.page.tsx +1 -1
- package/tests/examples/__snapshots__/example01.snap.svg +29 -32
- package/tests/examples/__snapshots__/example02.snap.svg +5 -5
- package/tests/examples/__snapshots__/example04.snap.svg +12 -12
- package/tests/examples/__snapshots__/example05.snap.svg +35 -35
- package/tests/examples/__snapshots__/example06.snap.svg +14 -14
- package/tests/examples/__snapshots__/example08.snap.svg +23 -29
- package/tests/examples/__snapshots__/example11.snap.svg +33 -39
- package/tests/examples/__snapshots__/example12.snap.svg +29 -32
- package/tests/examples/__snapshots__/example13.snap.svg +86 -83
- package/tests/examples/__snapshots__/example15.snap.svg +235 -0
- package/tests/examples/example15.test.tsx +187 -0
- package/tests/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver_repro03.test.ts +0 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
<svg width="640" height="640" viewBox="0 0 640 640" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="100%" height="100%" fill="white" />
|
|
3
|
+
<g>
|
|
4
|
+
<circle data-type="point" data-label="U3.8
|
|
5
|
+
x-" data-x="-1.4" data-y="0.42500000000000004" cx="209.53357448157186" cy="260.8626527311349" r="3" fill="hsl(88, 100%, 50%, 0.8)" />
|
|
6
|
+
</g>
|
|
7
|
+
<g>
|
|
8
|
+
<circle data-type="point" data-label="U3.4
|
|
9
|
+
x-" data-x="-1.4" data-y="-0.42500000000000004" cx="209.53357448157186" cy="338.1961068519585" r="3" fill="hsl(84, 100%, 50%, 0.8)" />
|
|
10
|
+
</g>
|
|
11
|
+
<g>
|
|
12
|
+
<circle data-type="point" data-label="U3.1
|
|
13
|
+
x+" data-x="1.4" data-y="0.5" cx="464.27907040899066" cy="254.0391126616505" r="3" fill="hsl(81, 100%, 50%, 0.8)" />
|
|
14
|
+
</g>
|
|
15
|
+
<g>
|
|
16
|
+
<circle data-type="point" data-label="U3.6
|
|
17
|
+
x+" data-x="1.4" data-y="0.30000000000000004" cx="464.27907040899066" cy="272.23521951360897" r="3" fill="hsl(86, 100%, 50%, 0.8)" />
|
|
18
|
+
</g>
|
|
19
|
+
<g>
|
|
20
|
+
<circle data-type="point" data-label="U3.5
|
|
21
|
+
x+" data-x="1.4" data-y="0.10000000000000009" cx="464.27907040899066" cy="290.4313263655675" r="3" fill="hsl(85, 100%, 50%, 0.8)" />
|
|
22
|
+
</g>
|
|
23
|
+
<g>
|
|
24
|
+
<circle data-type="point" data-label="U3.2
|
|
25
|
+
x+" data-x="1.4" data-y="-0.09999999999999998" cx="464.27907040899066" cy="308.62743321752595" r="3" fill="hsl(82, 100%, 50%, 0.8)" />
|
|
26
|
+
</g>
|
|
27
|
+
<g>
|
|
28
|
+
<circle data-type="point" data-label="U3.3
|
|
29
|
+
x+" data-x="1.4" data-y="-0.3" cx="464.27907040899066" cy="326.82354006948447" r="3" fill="hsl(83, 100%, 50%, 0.8)" />
|
|
30
|
+
</g>
|
|
31
|
+
<g>
|
|
32
|
+
<circle data-type="point" data-label="U3.7
|
|
33
|
+
x+" data-x="1.4" data-y="-0.5" cx="464.27907040899066" cy="345.0196469214429" r="3" fill="hsl(87, 100%, 50%, 0.8)" />
|
|
34
|
+
</g>
|
|
35
|
+
<g>
|
|
36
|
+
<circle data-type="point" data-label="C20.1
|
|
37
|
+
y+" data-x="-2.3148566499999994" data-y="0.5512093000000002" cx="126.29942769344797" cy="249.3800631885805" r="3" fill="hsl(140, 100%, 50%, 0.8)" />
|
|
38
|
+
</g>
|
|
39
|
+
<g>
|
|
40
|
+
<circle data-type="point" data-label="C20.2
|
|
41
|
+
y-" data-x="-2.31430995" data-y="-0.5512093000000002" cx="126.34916675152772" cy="349.67869639451294" r="3" fill="hsl(141, 100%, 50%, 0.8)" />
|
|
42
|
+
</g>
|
|
43
|
+
<g>
|
|
44
|
+
<circle data-type="point" data-label="R11.1
|
|
45
|
+
y+" data-x="1.7580660749999977" data-y="2.3025814000000002" cx="496.85611321279737" cy="90.03929384288585" r="3" fill="hsl(125, 100%, 50%, 0.8)" />
|
|
46
|
+
</g>
|
|
47
|
+
<g>
|
|
48
|
+
<circle data-type="point" data-label="R11.2
|
|
49
|
+
y-" data-x="1.757519574999999" data-y="1.2" cx="496.8063923508245" cy="190.35273867979578" r="3" fill="hsl(126, 100%, 50%, 0.8)" />
|
|
50
|
+
</g>
|
|
51
|
+
<g>
|
|
52
|
+
<circle data-type="point" data-label="R12.1
|
|
53
|
+
y-" data-x="-1.7580660749999977" data-y="-3.3025814000000002" cx="176.95653167776516" cy="600" r="3" fill="hsl(6, 100%, 50%, 0.8)" />
|
|
54
|
+
</g>
|
|
55
|
+
<g>
|
|
56
|
+
<circle data-type="point" data-label="R12.2
|
|
57
|
+
y+" data-x="-1.757519574999999" data-y="-2.2" cx="177.006252539738" cy="499.6865551630901" r="3" fill="hsl(7, 100%, 50%, 0.8)" />
|
|
58
|
+
</g>
|
|
59
|
+
<g>
|
|
60
|
+
<circle data-type="point" data-label="R13.1
|
|
61
|
+
y-" data-x="1.7580660749999977" data-y="-3.3025814000000002" cx="496.85611321279737" cy="600" r="3" fill="hsl(247, 100%, 50%, 0.8)" />
|
|
62
|
+
</g>
|
|
63
|
+
<g>
|
|
64
|
+
<circle data-type="point" data-label="R13.2
|
|
65
|
+
y+" data-x="1.757519574999999" data-y="-2.2" cx="496.8063923508245" cy="499.6865551630901" r="3" fill="hsl(248, 100%, 50%, 0.8)" />
|
|
66
|
+
</g>
|
|
67
|
+
<g>
|
|
68
|
+
<circle data-type="point" data-label="" data-x="-1.8574283249999997" data-y="0.7512093000000004" cx="167.91650108750991" cy="231.18395633662197" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
69
|
+
</g>
|
|
70
|
+
<g>
|
|
71
|
+
<circle data-type="point" data-label="" data-x="1.7580660749999977" data-y="2.4025814000000003" cx="496.85611321279737" cy="80.94124041690662" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
72
|
+
</g>
|
|
73
|
+
<g>
|
|
74
|
+
<circle data-type="point" data-label="" data-x="-2.31430995" data-y="-0.7512093000000004" cx="126.34916675152772" cy="367.87480324647146" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
75
|
+
</g>
|
|
76
|
+
<g>
|
|
77
|
+
<circle data-type="point" data-label="" data-x="1.757519574999999" data-y="0.85" cx="496.8063923508245" cy="222.19592567072314" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
78
|
+
</g>
|
|
79
|
+
<g>
|
|
80
|
+
<circle data-type="point" data-label="" data-x="1.757519574999999" data-y="-2" cx="496.8063923508245" cy="481.49044831113156" r="3" fill="hsl(40, 100%, 50%, 0.9)" />
|
|
81
|
+
</g>
|
|
82
|
+
<g>
|
|
83
|
+
<polyline data-points="-2.3148566499999994,0.5512093000000002 -1.4,0.42500000000000004" data-type="line" data-label="" points="126.29942769344797,249.3800631885805 209.53357448157186,260.8626527311349" fill="none" stroke="hsl(256, 100%, 50%, 0.8)" stroke-width="1" />
|
|
84
|
+
</g>
|
|
85
|
+
<g>
|
|
86
|
+
<polyline data-points="-2.31430995,-0.5512093000000002 -1.4,-0.42500000000000004" data-type="line" data-label="" points="126.34916675152772,349.67869639451294 209.53357448157186,338.1961068519585" fill="none" stroke="hsl(256, 100%, 50%, 0.8)" stroke-width="1" />
|
|
87
|
+
</g>
|
|
88
|
+
<g>
|
|
89
|
+
<polyline data-points="1.757519574999999,1.2 1.4,0.5" data-type="line" data-label="" points="496.8063923508245,190.35273867979578 464.27907040899066,254.0391126616505" fill="none" stroke="hsl(144, 100%, 50%, 0.8)" stroke-width="1" />
|
|
90
|
+
</g>
|
|
91
|
+
<g>
|
|
92
|
+
<polyline data-points="1.757519574999999,-2.2 -1.757519574999999,-2.2" data-type="line" data-label="" points="496.8063923508245,499.6865551630901 177.006252539738,499.6865551630901" fill="none" stroke="hsl(144, 100%, 50%, 0.8)" stroke-width="1" />
|
|
93
|
+
</g>
|
|
94
|
+
<g>
|
|
95
|
+
<polyline data-points="-1.4,0.42500000000000004 1.4,-0.3" data-type="line" data-label="" points="209.53357448157186,260.8626527311349 464.27907040899066,326.82354006948447" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
96
|
+
</g>
|
|
97
|
+
<g>
|
|
98
|
+
<polyline data-points="-1.4,0.42500000000000004 1.4,-0.5" data-type="line" data-label="" points="209.53357448157186,260.8626527311349 464.27907040899066,345.0196469214429" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
99
|
+
</g>
|
|
100
|
+
<g>
|
|
101
|
+
<polyline data-points="-1.4,0.42500000000000004 -2.3148566499999994,0.5512093000000002" data-type="line" data-label="" points="209.53357448157186,260.8626527311349 126.29942769344797,249.3800631885805" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
102
|
+
</g>
|
|
103
|
+
<g>
|
|
104
|
+
<polyline data-points="-1.4,0.42500000000000004 1.7580660749999977,2.3025814000000002" data-type="line" data-label="" points="209.53357448157186,260.8626527311349 496.85611321279737,90.03929384288585" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
105
|
+
</g>
|
|
106
|
+
<g>
|
|
107
|
+
<polyline data-points="1.4,-0.3 1.4,-0.5" data-type="line" data-label="" points="464.27907040899066,326.82354006948447 464.27907040899066,345.0196469214429" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
108
|
+
</g>
|
|
109
|
+
<g>
|
|
110
|
+
<polyline data-points="1.4,-0.3 -2.3148566499999994,0.5512093000000002" data-type="line" data-label="" points="464.27907040899066,326.82354006948447 126.29942769344797,249.3800631885805" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
111
|
+
</g>
|
|
112
|
+
<g>
|
|
113
|
+
<polyline data-points="1.4,-0.3 1.7580660749999977,2.3025814000000002" data-type="line" data-label="" points="464.27907040899066,326.82354006948447 496.85611321279737,90.03929384288585" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
114
|
+
</g>
|
|
115
|
+
<g>
|
|
116
|
+
<polyline data-points="1.4,-0.5 -2.3148566499999994,0.5512093000000002" data-type="line" data-label="" points="464.27907040899066,345.0196469214429 126.29942769344797,249.3800631885805" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
117
|
+
</g>
|
|
118
|
+
<g>
|
|
119
|
+
<polyline data-points="1.4,-0.5 1.7580660749999977,2.3025814000000002" data-type="line" data-label="" points="464.27907040899066,345.0196469214429 496.85611321279737,90.03929384288585" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
120
|
+
</g>
|
|
121
|
+
<g>
|
|
122
|
+
<polyline data-points="-2.3148566499999994,0.5512093000000002 1.7580660749999977,2.3025814000000002" data-type="line" data-label="" points="126.29942769344797,249.3800631885805 496.85611321279737,90.03929384288585" fill="none" stroke="hsl(73, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
123
|
+
</g>
|
|
124
|
+
<g>
|
|
125
|
+
<polyline data-points="-1.4,-0.42500000000000004 -2.31430995,-0.5512093000000002" data-type="line" data-label="" points="209.53357448157186,338.1961068519585 126.34916675152772,349.67869639451294" fill="none" stroke="hsl(157, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
126
|
+
</g>
|
|
127
|
+
<g>
|
|
128
|
+
<polyline data-points="1.4,0.5 1.757519574999999,1.2" data-type="line" data-label="" points="464.27907040899066,254.0391126616505 496.8063923508245,190.35273867979578" fill="none" stroke="hsl(304, 100%, 50%, 0.8)" stroke-width="1" stroke-dasharray="4 2" />
|
|
129
|
+
</g>
|
|
130
|
+
<g>
|
|
131
|
+
<polyline data-points="-1.4,0.42500000000000004 -1.8574283249999997,0.42500000000000004 -1.8574283249999997,0.7512093000000004 -2.3148566499999994,0.7512093000000004 -2.3148566499999994,0.5512093000000002" data-type="line" data-label="" points="209.53357448157186,260.8626527311349 167.91650108750991,260.8626527311349 167.91650108750991,231.18395633662197 126.29942769344797,231.18395633662197 126.29942769344797,249.3800631885805" fill="none" stroke="purple" stroke-width="1" />
|
|
132
|
+
</g>
|
|
133
|
+
<g>
|
|
134
|
+
<polyline data-points="1.4,-0.5 1.5999999999999999,-0.5 1.5999999999999999,-0.3 1.4,-0.3" data-type="line" data-label="" points="464.27907040899066,345.0196469214429 482.4751772609492,345.0196469214429 482.4751772609492,326.82354006948447 464.27907040899066,326.82354006948447" fill="none" stroke="purple" stroke-width="1" />
|
|
135
|
+
</g>
|
|
136
|
+
<g>
|
|
137
|
+
<polyline data-points="1.7580660749999977,2.3025814000000002 1.7580660749999977,2.4025814000000003 1.5,2.4025814000000003 1.5,-0.3 1.4,-0.3" data-type="line" data-label="" points="496.85611321279737,90.03929384288585 496.85611321279737,80.94124041690662 473.3771238349699,80.94124041690662 473.3771238349699,326.82354006948447 464.27907040899066,326.82354006948447" fill="none" stroke="purple" stroke-width="1" />
|
|
138
|
+
</g>
|
|
139
|
+
<g>
|
|
140
|
+
<polyline data-points="-2.31430995,-0.5512093000000002 -2.31430995,-0.7512093000000004 -1.857154975,-0.7512093000000004 -1.857154975,-0.42500000000000004 -1.4,-0.42500000000000004" data-type="line" data-label="" points="126.34916675152772,349.67869639451294 126.34916675152772,367.87480324647146 167.9413706165498,367.87480324647146 167.9413706165498,338.1961068519585 209.53357448157186,338.1961068519585" fill="none" stroke="purple" stroke-width="1" />
|
|
141
|
+
</g>
|
|
142
|
+
<g>
|
|
143
|
+
<polyline data-points="1.757519574999999,1.2 1.757519574999999,0.5 1.4,0.5" data-type="line" data-label="" points="496.8063923508245,190.35273867979578 496.8063923508245,254.0391126616505 464.27907040899066,254.0391126616505" fill="none" stroke="purple" stroke-width="1" />
|
|
144
|
+
</g>
|
|
145
|
+
<g>
|
|
146
|
+
<polyline data-points="1.757519574999999,-2.2 1.757519574999999,-2 -1.757519574999999,-2 -1.757519574999999,-2.2" data-type="line" data-label="" points="496.8063923508245,499.6865551630901 496.8063923508245,481.49044831113156 177.006252539738,481.49044831113156 177.006252539738,499.6865551630901" fill="none" stroke="purple" stroke-width="1" />
|
|
147
|
+
</g>
|
|
148
|
+
<g>
|
|
149
|
+
<rect data-type="rect" data-label="schematic_component_0" data-x="0" data-y="0" x="209.53357448157186" y="235.84300580969202" width="254.7454959274188" height="127.37274796370937" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.010991362142857144" />
|
|
150
|
+
</g>
|
|
151
|
+
<g>
|
|
152
|
+
<rect data-type="rect" data-label="schematic_component_1" data-x="-2.3145833" data-y="0" x="102.25236723226891" y="249.3800631885805" width="48.14385998043787" height="100.29863320593245" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.010991362142857144" />
|
|
153
|
+
</g>
|
|
154
|
+
<g>
|
|
155
|
+
<rect data-type="rect" data-label="schematic_component_2" data-x="1.7577928249999983" data-y="1.7512907000000002" x="482.4751772609492" y="90.03929384288585" width="28.71215104172353" height="100.31344483690992" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.010991362142857144" />
|
|
156
|
+
</g>
|
|
157
|
+
<g>
|
|
158
|
+
<rect data-type="rect" data-label="schematic_component_3" data-x="-1.7577928249999983" data-y="-2.7512907" x="162.6253165878898" y="499.6865551630901" width="28.71215104172356" height="100.31344483690992" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.010991362142857144" />
|
|
159
|
+
</g>
|
|
160
|
+
<g>
|
|
161
|
+
<rect data-type="rect" data-label="schematic_component_4" data-x="1.7577928249999983" data-y="-2.7512907" x="482.4751772609492" y="499.6865551630901" width="28.71215104172353" height="100.31344483690992" fill="hsl(24, 100%, 50%, 0.8)" stroke="black" stroke-width="0.010991362142857144" />
|
|
162
|
+
</g>
|
|
163
|
+
<g>
|
|
164
|
+
<rect data-type="rect" data-label="" data-x="-1.8574283249999997" data-y="0.9762093000000004" x="158.81844766153066" y="190.2427159197154" width="18.19610685195852" height="40.94124041690657" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.010991362142857144" />
|
|
165
|
+
</g>
|
|
166
|
+
<g>
|
|
167
|
+
<rect data-type="rect" data-label="" data-x="1.7580660749999977" data-y="2.6275814000000004" x="487.7580597868181" y="40" width="18.196106851958575" height="40.94124041690662" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.010991362142857144" />
|
|
168
|
+
</g>
|
|
169
|
+
<g>
|
|
170
|
+
<rect data-type="rect" data-label="" data-x="-2.31430995" data-y="-0.9762093000000004" x="117.25111332554849" y="367.87480324647146" width="18.19610685195849" height="40.94124041690657" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.010991362142857144" />
|
|
171
|
+
</g>
|
|
172
|
+
<g>
|
|
173
|
+
<rect data-type="rect" data-label="" data-x="1.982519574999999" data-y="0.85" x="496.8063923508245" y="213.0978722447439" width="40.94124041690662" height="18.19610685195849" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.010991362142857144" />
|
|
174
|
+
</g>
|
|
175
|
+
<g>
|
|
176
|
+
<rect data-type="rect" data-label="" data-x="1.982519574999999" data-y="-2" x="496.8063923508245" y="472.3923948851523" width="40.94124041690662" height="18.19610685195852" fill="hsl(40, 100%, 50%, 0.35)" stroke="black" stroke-width="0.010991362142857144" />
|
|
177
|
+
</g>
|
|
178
|
+
<g id="crosshair" style="display: none">
|
|
179
|
+
<line id="crosshair-h" y1="0" y2="640" stroke="#666" stroke-width="0.5" />
|
|
180
|
+
<line id="crosshair-v" x1="0" x2="640" stroke="#666" stroke-width="0.5" /><text id="coordinates" font-family="monospace" font-size="12" fill="#666"></text>
|
|
181
|
+
</g>
|
|
182
|
+
<script>
|
|
183
|
+
<![CDATA[
|
|
184
|
+
document.currentScript.parentElement.addEventListener('mousemove', (e) => {
|
|
185
|
+
const svg = e.currentTarget;
|
|
186
|
+
const rect = svg.getBoundingClientRect();
|
|
187
|
+
const x = e.clientX - rect.left;
|
|
188
|
+
const y = e.clientY - rect.top;
|
|
189
|
+
const crosshair = svg.getElementById('crosshair');
|
|
190
|
+
const h = svg.getElementById('crosshair-h');
|
|
191
|
+
const v = svg.getElementById('crosshair-v');
|
|
192
|
+
const coords = svg.getElementById('coordinates');
|
|
193
|
+
|
|
194
|
+
crosshair.style.display = 'block';
|
|
195
|
+
h.setAttribute('x1', '0');
|
|
196
|
+
h.setAttribute('x2', '640');
|
|
197
|
+
h.setAttribute('y1', y);
|
|
198
|
+
h.setAttribute('y2', y);
|
|
199
|
+
v.setAttribute('x1', x);
|
|
200
|
+
v.setAttribute('x2', x);
|
|
201
|
+
v.setAttribute('y1', '0');
|
|
202
|
+
v.setAttribute('y2', '640');
|
|
203
|
+
|
|
204
|
+
// Calculate real coordinates using inverse transformation
|
|
205
|
+
const matrix = {
|
|
206
|
+
"a": 90.98053425979244,
|
|
207
|
+
"c": 0,
|
|
208
|
+
"e": 336.90632244528126,
|
|
209
|
+
"b": 0,
|
|
210
|
+
"d": -90.98053425979244,
|
|
211
|
+
"f": 299.5293797915467
|
|
212
|
+
};
|
|
213
|
+
// Manually invert and apply the affine transform
|
|
214
|
+
// Since we only use translate and scale, we can directly compute:
|
|
215
|
+
// x' = (x - tx) / sx
|
|
216
|
+
// y' = (y - ty) / sy
|
|
217
|
+
const sx = matrix.a;
|
|
218
|
+
const sy = matrix.d;
|
|
219
|
+
const tx = matrix.e;
|
|
220
|
+
const ty = matrix.f;
|
|
221
|
+
const realPoint = {
|
|
222
|
+
x: (x - tx) / sx,
|
|
223
|
+
y: (y - ty) / sy // Flip y back since we used negative scale
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
coords.textContent = `(${realPoint.x.toFixed(2)}, ${realPoint.y.toFixed(2)})`;
|
|
227
|
+
coords.setAttribute('x', (x + 5).toString());
|
|
228
|
+
coords.setAttribute('y', (y - 5).toString());
|
|
229
|
+
});
|
|
230
|
+
document.currentScript.parentElement.addEventListener('mouseleave', () => {
|
|
231
|
+
document.currentScript.parentElement.getElementById('crosshair').style.display = 'none';
|
|
232
|
+
});
|
|
233
|
+
]]>
|
|
234
|
+
</script>
|
|
235
|
+
</svg>
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { expect } from "bun:test"
|
|
2
|
+
import { test } from "bun:test"
|
|
3
|
+
import { SchematicTracePipelineSolver, type InputProblem } from "lib/index"
|
|
4
|
+
import "tests/fixtures/matcher"
|
|
5
|
+
|
|
6
|
+
const inputProblem = {
|
|
7
|
+
chips: [
|
|
8
|
+
{
|
|
9
|
+
chipId: "schematic_component_0",
|
|
10
|
+
center: {
|
|
11
|
+
x: 0,
|
|
12
|
+
y: 0,
|
|
13
|
+
},
|
|
14
|
+
width: 2,
|
|
15
|
+
height: 1.4,
|
|
16
|
+
pins: [
|
|
17
|
+
{
|
|
18
|
+
pinId: "U3.8",
|
|
19
|
+
x: -1.4,
|
|
20
|
+
y: 0.42500000000000004,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
pinId: "U3.4",
|
|
24
|
+
x: -1.4,
|
|
25
|
+
y: -0.42500000000000004,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
pinId: "U3.1",
|
|
29
|
+
x: 1.4,
|
|
30
|
+
y: 0.5,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pinId: "U3.6",
|
|
34
|
+
x: 1.4,
|
|
35
|
+
y: 0.30000000000000004,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
pinId: "U3.5",
|
|
39
|
+
x: 1.4,
|
|
40
|
+
y: 0.10000000000000009,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
pinId: "U3.2",
|
|
44
|
+
x: 1.4,
|
|
45
|
+
y: -0.09999999999999998,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
pinId: "U3.3",
|
|
49
|
+
x: 1.4,
|
|
50
|
+
y: -0.3,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
pinId: "U3.7",
|
|
54
|
+
x: 1.4,
|
|
55
|
+
y: -0.5,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
chipId: "schematic_component_1",
|
|
61
|
+
center: {
|
|
62
|
+
x: -2.3145833,
|
|
63
|
+
y: 0,
|
|
64
|
+
},
|
|
65
|
+
width: 0.5291665999999999,
|
|
66
|
+
height: 1.0583333000000001,
|
|
67
|
+
pins: [
|
|
68
|
+
{
|
|
69
|
+
pinId: "C20.1",
|
|
70
|
+
x: -2.3148566499999994,
|
|
71
|
+
y: 0.5512093000000002,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
pinId: "C20.2",
|
|
75
|
+
x: -2.31430995,
|
|
76
|
+
y: -0.5512093000000002,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
chipId: "schematic_component_2",
|
|
82
|
+
center: {
|
|
83
|
+
x: 1.7577928249999983,
|
|
84
|
+
y: 1.7512907000000002,
|
|
85
|
+
},
|
|
86
|
+
width: 0.3155856499999966,
|
|
87
|
+
height: 1.0583332999999997,
|
|
88
|
+
pins: [
|
|
89
|
+
{
|
|
90
|
+
pinId: "R11.1",
|
|
91
|
+
x: 1.7580660749999977,
|
|
92
|
+
y: 2.3025814000000002,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
pinId: "R11.2",
|
|
96
|
+
x: 1.757519574999999,
|
|
97
|
+
y: 1.2,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
chipId: "schematic_component_3",
|
|
103
|
+
center: {
|
|
104
|
+
x: -1.7577928249999983,
|
|
105
|
+
y: -2.7512907000000002,
|
|
106
|
+
},
|
|
107
|
+
width: 0.3155856499999966,
|
|
108
|
+
height: 1.0583332999999997,
|
|
109
|
+
pins: [
|
|
110
|
+
{
|
|
111
|
+
pinId: "R12.1",
|
|
112
|
+
x: -1.7580660749999977,
|
|
113
|
+
y: -3.3025814000000002,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
pinId: "R12.2",
|
|
117
|
+
x: -1.757519574999999,
|
|
118
|
+
y: -2.2,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
chipId: "schematic_component_4",
|
|
124
|
+
center: {
|
|
125
|
+
x: 1.7577928249999983,
|
|
126
|
+
y: -2.7512907000000002,
|
|
127
|
+
},
|
|
128
|
+
width: 0.3155856499999966,
|
|
129
|
+
height: 1.0583332999999997,
|
|
130
|
+
pins: [
|
|
131
|
+
{
|
|
132
|
+
pinId: "R13.1",
|
|
133
|
+
x: 1.7580660749999977,
|
|
134
|
+
y: -3.3025814000000002,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
pinId: "R13.2",
|
|
138
|
+
x: 1.757519574999999,
|
|
139
|
+
y: -2.2,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
directConnections: [
|
|
145
|
+
{
|
|
146
|
+
pinIds: ["C20.1", "U3.8"],
|
|
147
|
+
netId: "capacitor.C20 > port.pin1 to .U3 > .VDD",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
pinIds: ["C20.2", "U3.4"],
|
|
151
|
+
netId: "capacitor.C20 > port.pin2 to .U3 > .GND",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
pinIds: ["R11.2", "U3.1"],
|
|
155
|
+
netId: "resistor.R11 > port.pin2 to .U3 > .N_CS",
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
pinIds: ["R13.2", "R12.2"],
|
|
159
|
+
netId: "resistor.R11 > port.pin1 to resistor.R12 > port.pin1",
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
netConnections: [
|
|
163
|
+
{
|
|
164
|
+
netId: "V3_3",
|
|
165
|
+
pinIds: ["U3.8", "U3.3", "U3.7", "C20.1", "R11.1"],
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
netId: "GND",
|
|
169
|
+
pinIds: ["U3.4", "C20.2"],
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
netId: "FLASH_N_CS",
|
|
173
|
+
pinIds: ["U3.1", "R11.2"],
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
availableNetLabelOrientations: {
|
|
177
|
+
V3_3: ["y+"],
|
|
178
|
+
GND: ["y-"],
|
|
179
|
+
},
|
|
180
|
+
maxMspPairDistance: 5,
|
|
181
|
+
} as InputProblem
|
|
182
|
+
|
|
183
|
+
test("example14", () => {
|
|
184
|
+
const solver = new SchematicTracePipelineSolver(inputProblem)
|
|
185
|
+
solver.solve()
|
|
186
|
+
expect(solver).toMatchSolverSnapshot(import.meta.path)
|
|
187
|
+
})
|
package/tests/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver_repro03.test.ts
ADDED
|
File without changes
|