"""Find the smallest sweep-relief radius (= maximum body wrap) that keeps the holder
swept-clear of the rotating yoke over +-100 deg. More wrap = closer to Cameron's
"fully wraps" goal, for the current yoke.
"""
import sys
sys.path.insert(0, "/data/cameron/repos/smith300_para_stuff")
import wrap_holder as wh
from yoke_exact import make_yoke_exact
from build123d import Axis, Vector

yoke0 = make_yoke_exact()
axis = Axis(Vector(-25.5, 0, 0), Vector(0, 1, 0))
rotated = {deg: yoke0.rotate(axis, deg) for deg in range(-100, 101, 25)}

for R in [18, 19, 20, 21, 22, 24]:
    wh.R_SWEEP = R
    holder = wh.make_wrap_holder()
    worst = 0.0
    for deg, y in rotated.items():
        try:
            c = holder & y
            v = 0.0 if c is None else float(c.volume)
        except Exception:
            v = -1.0
        worst = max(worst, v)
    tag = "CLEAR" if worst < 1.0 else "hit"
    print(f"R_SWEEP={R}: vol={holder.volume:6.0f}  solids={len(holder.solids())}  worst_swept={worst:7.1f}  {tag}")
