"""Footing rebar layer rule of the Ungok frame (2026-10-20; was tools/infer_footing_rebar.py). The rules were read off the template pier (운곡교 P1) and reproduced there: bars run (footing - 200) long; the dense layers (B2/B4, B6/B8) have the two end bars, one bar 200 (X-position axis) / 175 (Y) inside, then a 125 grid; the sparse layers (B3, B7, B1, B5) the same with a 250 grid. The result equals the bar counts of the pier's own rebar schedule (P3, P4).""" def dense(half, first_gap): inner = half - first_gap k = int((inner - 125) // 125) g = [i * 125.0 for i in range(-k, k + 1)] return sorted({-half, half, -inner, inner, *g}) def sparse(half, first_gap): inner = half - first_gap n = int(round(2 * inner / 250)) return sorted({-half, half, *[-inner + 250.0 * i for i in range(n + 1)]}) def infer(size_x, size_y): lx, ly = size_x - 200, size_y - 200 hx, hy = lx / 2, ly / 2 return {"bottom_Y1": dense(hx, 200), "bottom_X2": dense(hy, 175), "bottom_Y3": sparse(hx, 200), "bottom_X4": sparse(hy, 175), "top_Y": sparse(hx, 200), "top_X": sparse(hy, 175), "a_y": ly, "a_x": lx}