calculate-packing 0.0.74 → 0.0.76
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 +12 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -102,14 +102,15 @@ var getComponentBounds = (component, minGap = 0) => {
|
|
|
102
102
|
};
|
|
103
103
|
const angleRad = component.ccwRotationOffset * Math.PI / 180;
|
|
104
104
|
for (const pad of component.pads) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
105
|
+
const rotatedOffset = rotatePoint(pad.offset, angleRad);
|
|
106
|
+
const cx = component.center.x + rotatedOffset.x;
|
|
107
|
+
const cy = component.center.y + rotatedOffset.y;
|
|
108
|
+
const hw = pad.size.x / 2;
|
|
109
|
+
const hh = pad.size.y / 2;
|
|
110
|
+
bounds.minX = Math.min(bounds.minX, cx - hw);
|
|
111
|
+
bounds.maxX = Math.max(bounds.maxX, cx + hw);
|
|
112
|
+
bounds.minY = Math.min(bounds.minY, cy - hh);
|
|
113
|
+
bounds.maxY = Math.max(bounds.maxY, cy + hh);
|
|
113
114
|
}
|
|
114
115
|
if (component.courtyard) {
|
|
115
116
|
expandRotatedRectIntoBounds({
|
|
@@ -2854,7 +2855,7 @@ var PackSolver2 = class extends BaseSolver5 {
|
|
|
2854
2855
|
const packedComponent = {
|
|
2855
2856
|
...component,
|
|
2856
2857
|
center: component.center ?? { x: 0, y: 0 },
|
|
2857
|
-
ccwRotationOffset: component.ccwRotationOffset ?? 0,
|
|
2858
|
+
ccwRotationOffset: component.ccwRotationOffset ?? component.availableRotationDegrees?.[0] ?? 0,
|
|
2858
2859
|
pads: component.pads.map((pad) => ({
|
|
2859
2860
|
...pad,
|
|
2860
2861
|
absoluteCenter: pad.absoluteCenter ?? { x: 0, y: 0 }
|
|
@@ -2878,7 +2879,7 @@ var PackSolver2 = class extends BaseSolver5 {
|
|
|
2878
2879
|
const newPackedComponent = {
|
|
2879
2880
|
...firstComponentToPack,
|
|
2880
2881
|
center: initialPosition,
|
|
2881
|
-
ccwRotationOffset: 0,
|
|
2882
|
+
ccwRotationOffset: firstComponentToPack.ccwRotationOffset ?? firstComponentToPack.availableRotationDegrees?.[0] ?? 0,
|
|
2882
2883
|
pads: firstComponentToPack.pads.map((p) => ({
|
|
2883
2884
|
...p,
|
|
2884
2885
|
absoluteCenter: { x: 0, y: 0 }
|
|
@@ -2981,7 +2982,7 @@ var PackSolver2 = class extends BaseSolver5 {
|
|
|
2981
2982
|
const packedComponent = {
|
|
2982
2983
|
...this.componentToPack,
|
|
2983
2984
|
center: { x: 0, y: 0 },
|
|
2984
|
-
ccwRotationOffset: 0,
|
|
2985
|
+
ccwRotationOffset: this.componentToPack?.ccwRotationOffset ?? this.componentToPack?.availableRotationDegrees?.[0] ?? 0,
|
|
2985
2986
|
pads: this.componentToPack.pads.map((p) => ({
|
|
2986
2987
|
...p,
|
|
2987
2988
|
absoluteCenter: { x: 0, y: 0 }
|
package/package.json
CHANGED