"""[feetech_calib] Which yoke placement actually mates to the servo horn?
Compare joint-offset (-25.5) vs zero-offset by nearest-surface distance to st3215."""
import numpy as np, trimesh
servo = trimesh.load("st3215.stl", force="mesh")
for off in [(-25.5, 0, 0), (0, 0, 0)]:
    y = trimesh.load("yoke_fillet.stl", force="mesh")
    y.apply_translation(off)
    # nearest distance from yoke sample points to servo surface
    pts = y.sample(4000)
    d = trimesh.proximity.closest_point(servo, pts)[1]
    inter = servo.bounds  # quick overlap check
    ylo, yhi = y.bounds
    ovl = np.maximum(0, np.minimum(servo.bounds[1], yhi) - np.maximum(servo.bounds[0], ylo))
    print(f"offset {off}: yoke_X=({ylo[0]:.1f},{yhi[0]:.1f})  min_gap_to_servo={d.min():.2f}mm  "
          f"frac_pts_within_1mm={(d<1.0).mean():.3f}  xyz_bbox_overlap={np.round(ovl,1)}")
