@tscircuit/core 0.0.261 → 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 +41 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4246,26 +4246,45 @@ var createSchematicTraceCrossingSegments = ({
|
|
|
4246
4246
|
};
|
|
4247
4247
|
|
|
4248
4248
|
// lib/components/primitive-components/Trace/create-schematic-trace-junctions.ts
|
|
4249
|
-
var isOrthogonal = (edge1, edge2) => {
|
|
4250
|
-
const isVertical1 = edge1.from.x === edge1.to.x;
|
|
4251
|
-
const isVertical2 = edge2.from.x === edge2.to.x;
|
|
4252
|
-
return isVertical1 !== isVertical2;
|
|
4253
|
-
};
|
|
4254
4249
|
var getIntersectionPoint = (edge1, edge2) => {
|
|
4255
|
-
if (
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
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;
|
|
4269
4288
|
};
|
|
4270
4289
|
var createSchematicTraceJunctions = ({
|
|
4271
4290
|
edges: myEdges,
|
|
@@ -4282,14 +4301,12 @@ var createSchematicTraceJunctions = ({
|
|
|
4282
4301
|
for (const otherEdge of otherEdges) {
|
|
4283
4302
|
const intersection = getIntersectionPoint(myEdge, otherEdge);
|
|
4284
4303
|
if (intersection) {
|
|
4285
|
-
|
|
4304
|
+
const pointKey = `${intersection.x},${intersection.y}`;
|
|
4305
|
+
return [{ x: intersection.x, y: intersection.y }];
|
|
4286
4306
|
}
|
|
4287
4307
|
}
|
|
4288
4308
|
}
|
|
4289
|
-
return
|
|
4290
|
-
const [x, y] = key.split(",").map(Number);
|
|
4291
|
-
return { x, y };
|
|
4292
|
-
});
|
|
4309
|
+
return [];
|
|
4293
4310
|
};
|
|
4294
4311
|
|
|
4295
4312
|
// lib/components/primitive-components/Trace/push-edges-of-schematic-trace-to-prevent-overlap.ts
|