@tscircuit/circuit-json-util 0.0.126 → 0.0.128

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 CHANGED
@@ -1105,6 +1105,9 @@ var transformPCBElement = (elm, matrix) => {
1105
1105
  elm.center = applyToPoint(matrix, elm.center);
1106
1106
  } else if (elm.type === "pcb_component") {
1107
1107
  elm.center = applyToPoint(matrix, elm.center);
1108
+ if (elm.footprint_origin) {
1109
+ elm.footprint_origin = applyToPoint(matrix, elm.footprint_origin);
1110
+ }
1108
1111
  elm.rotation = elm.rotation + rotationDegrees;
1109
1112
  elm.rotation = elm.rotation % 360;
1110
1113
  if (elm.cable_insertion_center) {
@@ -2835,6 +2838,7 @@ var computeClearanceBetweenElements = (elm1, elm2) => {
2835
2838
  };
2836
2839
 
2837
2840
  // lib/analyze-pcb-pin1-location.ts
2841
+ var MAX_TWO_PAD_ROW_SKEW_RATIO = 0.01;
2838
2842
  var PIN1_LOCATION_PARTS = {
2839
2843
  leftside_top: { side: "leftside", alignment: "top" },
2840
2844
  leftside_bottom: { side: "leftside", alignment: "bottom" },
@@ -2867,13 +2871,23 @@ var getPinNumber = (pad) => {
2867
2871
  }
2868
2872
  return null;
2869
2873
  };
2870
- var getCanonicalRowLocation = (pin1, pin2, tolerance) => {
2874
+ var getCanonicalRowLocation = ({
2875
+ pin1,
2876
+ pin2,
2877
+ tolerance,
2878
+ maxSkewRatio = 0
2879
+ }) => {
2871
2880
  const dx = pin2.x - pin1.x;
2872
2881
  const dy = pin2.y - pin1.y;
2873
- if (Math.abs(dy) <= tolerance && Math.abs(dx) > tolerance) {
2882
+ const horizontalSkewTolerance = Math.max(
2883
+ tolerance,
2884
+ Math.abs(dx) * maxSkewRatio
2885
+ );
2886
+ const verticalSkewTolerance = Math.max(tolerance, Math.abs(dy) * maxSkewRatio);
2887
+ if (Math.abs(dy) <= horizontalSkewTolerance && Math.abs(dx) > tolerance) {
2874
2888
  return dx > 0 ? "topside_left" : "bottomside_right";
2875
2889
  }
2876
- if (Math.abs(dx) <= tolerance && Math.abs(dy) > tolerance) {
2890
+ if (Math.abs(dx) <= verticalSkewTolerance && Math.abs(dy) > tolerance) {
2877
2891
  return dy > 0 ? "leftside_bottom" : "rightside_top";
2878
2892
  }
2879
2893
  return null;
@@ -2928,11 +2942,12 @@ var analyzePcbPin1Location = (elements) => {
2928
2942
  );
2929
2943
  const tolerance = span * 1e-6;
2930
2944
  if (numberedPads.length === 2 && nextNumberedPad.pinNumber === 2) {
2931
- return getCanonicalRowLocation(
2932
- pin1Center,
2933
- nextNumberedPad.center,
2934
- tolerance
2935
- );
2945
+ return getCanonicalRowLocation({
2946
+ pin1: pin1Center,
2947
+ pin2: nextNumberedPad.center,
2948
+ tolerance,
2949
+ maxSkewRatio: MAX_TWO_PAD_ROW_SKEW_RATIO
2950
+ });
2936
2951
  }
2937
2952
  if (numberedPads.length > 2) {
2938
2953
  const row = [...numberedPads].sort(
@@ -2951,7 +2966,11 @@ var analyzePcbPin1Location = (elements) => {
2951
2966
  const previous = row[index].center;
2952
2967
  return horizontal ? Math.abs(center.y - first.y) <= tolerance && (center.x - previous.x) * Math.sign(dx) > tolerance : Math.abs(center.x - first.x) <= tolerance && (center.y - previous.y) * Math.sign(dy) > tolerance;
2953
2968
  })) {
2954
- return getCanonicalRowLocation(first, row[1].center, tolerance);
2969
+ return getCanonicalRowLocation({
2970
+ pin1: first,
2971
+ pin2: row[1].center,
2972
+ tolerance
2973
+ });
2955
2974
  }
2956
2975
  }
2957
2976
  }