@tscircuit/core 0.0.1155 → 0.0.1156

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.
Files changed (2) hide show
  1. package/dist/index.js +23 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2679,6 +2679,25 @@ function fillCircleWithRects(circle, options = {}) {
2679
2679
 
2680
2680
  // lib/utils/obstacles/getObstaclesFromCircuitJson.ts
2681
2681
  var EVERY_LAYER = ["top", "inner1", "inner2", "bottom"];
2682
+ var QUARTER_TURN_TOLERANCE_DEGREES = 0.01;
2683
+ var getAxisAlignedRectFromRotatedRect = (rotatedRect) => {
2684
+ const normalizedRotation = (rotatedRect.rotation % 360 + 360) % 360;
2685
+ const axisAlignedAngles = [0, 90, 180, 270];
2686
+ for (const angle of axisAlignedAngles) {
2687
+ const angularDistance = Math.min(
2688
+ Math.abs(normalizedRotation - angle),
2689
+ 360 - Math.abs(normalizedRotation - angle)
2690
+ );
2691
+ if (angularDistance > QUARTER_TURN_TOLERANCE_DEGREES) continue;
2692
+ const isVertical = angle === 90 || angle === 270;
2693
+ return {
2694
+ center: rotatedRect.center,
2695
+ width: isVertical ? rotatedRect.height : rotatedRect.width,
2696
+ height: isVertical ? rotatedRect.width : rotatedRect.height
2697
+ };
2698
+ }
2699
+ return null;
2700
+ };
2682
2701
  var getObstaclesFromCircuitJson = (soup, connMap) => {
2683
2702
  const withNetId = (idList) => connMap ? idList.concat(
2684
2703
  idList.map((id) => connMap?.getNetConnectedToId(id)).filter(Boolean)
@@ -2718,8 +2737,9 @@ var getObstaclesFromCircuitJson = (soup, connMap) => {
2718
2737
  height: element.height,
2719
2738
  rotation: element.ccw_rotation
2720
2739
  };
2721
- const approximatingRects = generateApproximatingRects(rotatedRect);
2722
- for (const rect of approximatingRects) {
2740
+ const singleRect = getAxisAlignedRectFromRotatedRect(rotatedRect);
2741
+ const rects = singleRect ? [singleRect] : generateApproximatingRects(rotatedRect);
2742
+ for (const rect of rects) {
2723
2743
  obstacles.push({
2724
2744
  type: "rect",
2725
2745
  layers: [element.layer],
@@ -19276,7 +19296,7 @@ import { identity as identity5 } from "transformation-matrix";
19276
19296
  var package_default = {
19277
19297
  name: "@tscircuit/core",
19278
19298
  type: "module",
19279
- version: "0.0.1154",
19299
+ version: "0.0.1155",
19280
19300
  types: "dist/index.d.ts",
19281
19301
  main: "dist/index.js",
19282
19302
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1155",
4
+ "version": "0.0.1156",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",