@tscircuit/circuit-json-util 0.0.127 → 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 +25 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2838,6 +2838,7 @@ var computeClearanceBetweenElements = (elm1, elm2) => {
|
|
|
2838
2838
|
};
|
|
2839
2839
|
|
|
2840
2840
|
// lib/analyze-pcb-pin1-location.ts
|
|
2841
|
+
var MAX_TWO_PAD_ROW_SKEW_RATIO = 0.01;
|
|
2841
2842
|
var PIN1_LOCATION_PARTS = {
|
|
2842
2843
|
leftside_top: { side: "leftside", alignment: "top" },
|
|
2843
2844
|
leftside_bottom: { side: "leftside", alignment: "bottom" },
|
|
@@ -2870,13 +2871,23 @@ var getPinNumber = (pad) => {
|
|
|
2870
2871
|
}
|
|
2871
2872
|
return null;
|
|
2872
2873
|
};
|
|
2873
|
-
var getCanonicalRowLocation = (
|
|
2874
|
+
var getCanonicalRowLocation = ({
|
|
2875
|
+
pin1,
|
|
2876
|
+
pin2,
|
|
2877
|
+
tolerance,
|
|
2878
|
+
maxSkewRatio = 0
|
|
2879
|
+
}) => {
|
|
2874
2880
|
const dx = pin2.x - pin1.x;
|
|
2875
2881
|
const dy = pin2.y - pin1.y;
|
|
2876
|
-
|
|
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) {
|
|
2877
2888
|
return dx > 0 ? "topside_left" : "bottomside_right";
|
|
2878
2889
|
}
|
|
2879
|
-
if (Math.abs(dx) <=
|
|
2890
|
+
if (Math.abs(dx) <= verticalSkewTolerance && Math.abs(dy) > tolerance) {
|
|
2880
2891
|
return dy > 0 ? "leftside_bottom" : "rightside_top";
|
|
2881
2892
|
}
|
|
2882
2893
|
return null;
|
|
@@ -2931,11 +2942,12 @@ var analyzePcbPin1Location = (elements) => {
|
|
|
2931
2942
|
);
|
|
2932
2943
|
const tolerance = span * 1e-6;
|
|
2933
2944
|
if (numberedPads.length === 2 && nextNumberedPad.pinNumber === 2) {
|
|
2934
|
-
return getCanonicalRowLocation(
|
|
2935
|
-
pin1Center,
|
|
2936
|
-
nextNumberedPad.center,
|
|
2937
|
-
tolerance
|
|
2938
|
-
|
|
2945
|
+
return getCanonicalRowLocation({
|
|
2946
|
+
pin1: pin1Center,
|
|
2947
|
+
pin2: nextNumberedPad.center,
|
|
2948
|
+
tolerance,
|
|
2949
|
+
maxSkewRatio: MAX_TWO_PAD_ROW_SKEW_RATIO
|
|
2950
|
+
});
|
|
2939
2951
|
}
|
|
2940
2952
|
if (numberedPads.length > 2) {
|
|
2941
2953
|
const row = [...numberedPads].sort(
|
|
@@ -2954,7 +2966,11 @@ var analyzePcbPin1Location = (elements) => {
|
|
|
2954
2966
|
const previous = row[index].center;
|
|
2955
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;
|
|
2956
2968
|
})) {
|
|
2957
|
-
return getCanonicalRowLocation(
|
|
2969
|
+
return getCanonicalRowLocation({
|
|
2970
|
+
pin1: first,
|
|
2971
|
+
pin2: row[1].center,
|
|
2972
|
+
tolerance
|
|
2973
|
+
});
|
|
2958
2974
|
}
|
|
2959
2975
|
}
|
|
2960
2976
|
}
|