@tscircuit/core 0.0.260 → 0.0.262
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.js +54 -33
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4178,14 +4178,9 @@ var getOtherSchematicTraces = ({
|
|
|
4178
4178
|
import { getUnitVectorFromPointAToB } from "@tscircuit/math-utils";
|
|
4179
4179
|
var createSchematicTraceCrossingSegments = ({
|
|
4180
4180
|
edges,
|
|
4181
|
-
|
|
4182
|
-
source_trace_id
|
|
4181
|
+
otherEdges
|
|
4183
4182
|
}) => {
|
|
4184
|
-
|
|
4185
|
-
db,
|
|
4186
|
-
source_trace_id,
|
|
4187
|
-
differentNetOnly: true
|
|
4188
|
-
}).flatMap((t) => t.edges);
|
|
4183
|
+
edges = [...edges];
|
|
4189
4184
|
for (let i = 0; i < edges.length; i++) {
|
|
4190
4185
|
if (i > 2e3) {
|
|
4191
4186
|
throw new Error(
|
|
@@ -4223,6 +4218,9 @@ var createSchematicTraceCrossingSegments = ({
|
|
|
4223
4218
|
}
|
|
4224
4219
|
const crossingPoint = closestIntersection.crossingPoint;
|
|
4225
4220
|
const crossingSegmentLength = 0.075;
|
|
4221
|
+
if (crossingPoint.x === edge.from.x && crossingPoint.y === edge.from.y) {
|
|
4222
|
+
continue;
|
|
4223
|
+
}
|
|
4226
4224
|
const crossingUnitVec = getUnitVectorFromPointAToB(edge.from, crossingPoint);
|
|
4227
4225
|
const beforeCrossing = {
|
|
4228
4226
|
x: crossingPoint.x - crossingUnitVec.x * crossingSegmentLength / 2,
|
|
@@ -4244,29 +4242,49 @@ var createSchematicTraceCrossingSegments = ({
|
|
|
4244
4242
|
i++;
|
|
4245
4243
|
}
|
|
4246
4244
|
}
|
|
4245
|
+
return edges;
|
|
4247
4246
|
};
|
|
4248
4247
|
|
|
4249
4248
|
// lib/components/primitive-components/Trace/create-schematic-trace-junctions.ts
|
|
4250
|
-
var isOrthogonal = (edge1, edge2) => {
|
|
4251
|
-
const isVertical1 = edge1.from.x === edge1.to.x;
|
|
4252
|
-
const isVertical2 = edge2.from.x === edge2.to.x;
|
|
4253
|
-
return isVertical1 !== isVertical2;
|
|
4254
|
-
};
|
|
4255
4249
|
var getIntersectionPoint = (edge1, edge2) => {
|
|
4256
|
-
if (
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4250
|
+
if (edge1.from.x === edge1.to.x && edge2.from.x === edge2.to.x) {
|
|
4251
|
+
return null;
|
|
4252
|
+
}
|
|
4253
|
+
if (edge1.from.x === edge1.to.x) {
|
|
4254
|
+
const x2 = edge1.from.x;
|
|
4255
|
+
const m22 = (edge2.to.y - edge2.from.y) / (edge2.to.x - edge2.from.x);
|
|
4256
|
+
const b22 = edge2.from.y - m22 * edge2.from.x;
|
|
4257
|
+
const y2 = m22 * x2 + b22;
|
|
4258
|
+
if (x2 >= Math.min(edge2.from.x, edge2.to.x) && x2 <= Math.max(edge2.from.x, edge2.to.x) && y2 >= Math.min(edge2.from.y, edge2.to.y) && y2 <= Math.max(edge2.from.y, edge2.to.y)) {
|
|
4259
|
+
return { x: x2, y: y2 };
|
|
4260
|
+
}
|
|
4261
|
+
return null;
|
|
4262
|
+
}
|
|
4263
|
+
if (edge2.from.x === edge2.to.x) {
|
|
4264
|
+
const x2 = edge2.from.x;
|
|
4265
|
+
const m12 = (edge1.to.y - edge1.from.y) / (edge1.to.x - edge1.from.x);
|
|
4266
|
+
const b12 = edge1.from.y - m12 * edge1.from.x;
|
|
4267
|
+
const y2 = m12 * x2 + b12;
|
|
4268
|
+
if (x2 >= Math.min(edge1.from.x, edge1.to.x) && x2 <= Math.max(edge1.from.x, edge1.to.x) && y2 >= Math.min(edge1.from.y, edge1.to.y) && y2 <= Math.max(edge1.from.y, edge1.to.y)) {
|
|
4269
|
+
return { x: x2, y: y2 };
|
|
4270
|
+
}
|
|
4271
|
+
return null;
|
|
4272
|
+
}
|
|
4273
|
+
const m1 = (edge1.to.y - edge1.from.y) / (edge1.to.x - edge1.from.x);
|
|
4274
|
+
const b1 = edge1.from.y - m1 * edge1.from.x;
|
|
4275
|
+
const m2 = (edge2.to.y - edge2.from.y) / (edge2.to.x - edge2.from.x);
|
|
4276
|
+
const b2 = edge2.from.y - m2 * edge2.from.x;
|
|
4277
|
+
if (m1 === m2) {
|
|
4278
|
+
return null;
|
|
4279
|
+
}
|
|
4280
|
+
const x = (b2 - b1) / (m1 - m2);
|
|
4281
|
+
const y = m1 * x + b1;
|
|
4282
|
+
const isWithinEdge1 = x >= Math.min(edge1.from.x, edge1.to.x) && x <= Math.max(edge1.from.x, edge1.to.x) && y >= Math.min(edge1.from.y, edge1.to.y) && y <= Math.max(edge1.from.y, edge1.to.y);
|
|
4283
|
+
const isWithinEdge2 = x >= Math.min(edge2.from.x, edge2.to.x) && x <= Math.max(edge2.from.x, edge2.to.x) && y >= Math.min(edge2.from.y, edge2.to.y) && y <= Math.max(edge2.from.y, edge2.to.y);
|
|
4284
|
+
if (isWithinEdge1 && isWithinEdge2) {
|
|
4285
|
+
return { x, y };
|
|
4286
|
+
}
|
|
4287
|
+
return null;
|
|
4270
4288
|
};
|
|
4271
4289
|
var createSchematicTraceJunctions = ({
|
|
4272
4290
|
edges: myEdges,
|
|
@@ -4283,14 +4301,12 @@ var createSchematicTraceJunctions = ({
|
|
|
4283
4301
|
for (const otherEdge of otherEdges) {
|
|
4284
4302
|
const intersection = getIntersectionPoint(myEdge, otherEdge);
|
|
4285
4303
|
if (intersection) {
|
|
4286
|
-
|
|
4304
|
+
const pointKey = `${intersection.x},${intersection.y}`;
|
|
4305
|
+
return [{ x: intersection.x, y: intersection.y }];
|
|
4287
4306
|
}
|
|
4288
4307
|
}
|
|
4289
4308
|
}
|
|
4290
|
-
return
|
|
4291
|
-
const [x, y] = key.split(",").map(Number);
|
|
4292
|
-
return { x, y };
|
|
4293
|
-
});
|
|
4309
|
+
return [];
|
|
4294
4310
|
};
|
|
4295
4311
|
|
|
4296
4312
|
// lib/components/primitive-components/Trace/push-edges-of-schematic-trace-to-prevent-overlap.ts
|
|
@@ -5197,7 +5213,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
5197
5213
|
skipOtherTraceInteraction = true;
|
|
5198
5214
|
}
|
|
5199
5215
|
const [{ route }] = results;
|
|
5200
|
-
|
|
5216
|
+
let edges = [];
|
|
5201
5217
|
for (let i = 0; i < route.length - 1; i++) {
|
|
5202
5218
|
edges.push({
|
|
5203
5219
|
from: route[i],
|
|
@@ -5208,7 +5224,12 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
|
|
|
5208
5224
|
let junctions = [];
|
|
5209
5225
|
if (!skipOtherTraceInteraction) {
|
|
5210
5226
|
pushEdgesOfSchematicTraceToPreventOverlap({ edges, db, source_trace_id });
|
|
5211
|
-
|
|
5227
|
+
const otherEdges = getOtherSchematicTraces({
|
|
5228
|
+
db,
|
|
5229
|
+
source_trace_id,
|
|
5230
|
+
differentNetOnly: true
|
|
5231
|
+
}).flatMap((t) => t.edges);
|
|
5232
|
+
edges = createSchematicTraceCrossingSegments({ edges, otherEdges });
|
|
5212
5233
|
junctions = createSchematicTraceJunctions({
|
|
5213
5234
|
edges,
|
|
5214
5235
|
db,
|