diff --git a/lib/utils/getTunedTotalCapacity1.ts b/lib/utils/getTunedTotalCapacity1.ts index 308ff05c3..64f2e2aed 100644 --- a/lib/utils/getTunedTotalCapacity1.ts +++ b/lib/utils/getTunedTotalCapacity1.ts @@ -11,16 +11,27 @@ import { CapacityMeshNode } from "lib/types/capacity-mesh-types" * @returns The calculated capacity */ export const getTunedTotalCapacity1 = ( - nodeOrWidth: CapacityMeshNode | { width: number; availableZ?: number[] }, + nodeOrWidth: + | CapacityMeshNode + | { width: number; height?: number; availableZ?: number[] }, maxCapacityFactor = 1, opts: { viaDiameter?: number; obstacleMargin?: number } = {}, ) => { const VIA_DIAMETER = opts.viaDiameter ?? 0.3 const TRACE_WIDTH = 0.15 + const width = "width" in nodeOrWidth ? nodeOrWidth.width : nodeOrWidth const obstacleMargin = opts.obstacleMargin ?? 0.2 + const height = + "height" in nodeOrWidth && typeof nodeOrWidth.height === "number" + ? nodeOrWidth.height + : width - const width = "width" in nodeOrWidth ? nodeOrWidth.width : nodeOrWidth - const viaLengthAcross = width / (VIA_DIAMETER / 2 + obstacleMargin) + // Use the geometric mean so thin rectangular nodes are assigned less capacity + // than similarly wide square nodes while preserving previous behavior when only + // width is provided. + const effectiveNodeSpan = Math.sqrt(width * height) + const viaLengthAcross = + effectiveNodeSpan / (VIA_DIAMETER / 2 + obstacleMargin) const tunedTotalCapacity = (viaLengthAcross / 2) ** 1.1 * maxCapacityFactor diff --git a/tests/__snapshots__/e2e3-jumpers.snap.svg b/tests/__snapshots__/e2e3-jumpers.snap.svg index 2573b78ed..62bd2e362 100644 --- a/tests/__snapshots__/e2e3-jumpers.snap.svg +++ b/tests/__snapshots__/e2e3-jumpers.snap.svg @@ -1,4 +1,4 @@ -