back to working after bend-aware straights

This commit is contained in:
Jan Petykiewicz 2026-03-18 12:10:14 -07:00
commit 51d8ddca51

View file

@ -269,25 +269,26 @@ def _clip_bbox(
# Define vertices in local space (center at 0,0, symmetry axis along +X)
# 1. Start Inner
# 2. Start Outer
# 3. Peak Outer (intersection of tangents at start/end)
# 4. End Outer
# 5. End Inner
# 6. Peak Inner (ensures convexity and inner clipping)
# 3. Peak Outer Start (tangent intersection approximation)
# 4. Peak Outer End
# 5. End Outer
# 6. End Inner
# 7. Peak Inner (ensures convexity and inner clipping)
# Outer tangent intersection point
# Tangent at -hs: x*cos(hs) - y*sin(hs) = r_out
# Tangent at +hs: x*cos(hs) + y*sin(hs) = r_out
# Intersection: y=0, x = r_out / cos(hs)
# To clip the outer corner, we use two peak vertices that follow the arc tighter.
cos_hs = numpy.cos(half_sweep)
if cos_hs < 1e-3: # Sweep near 180 deg
peak_out_x = r_out * 2.0 # Fallback
else:
peak_out_x = r_out / cos_hs
cos_hs2 = numpy.cos(half_sweep / 2.0)
tan_hs2 = numpy.tan(half_sweep / 2.0)
# Distance to peak from center: r_out / cos(hs/2)
# At angles +/- hs/2
peak_r = r_out / cos_hs2
local_verts = [
[r_in * numpy.cos(-half_sweep), r_in * numpy.sin(-half_sweep)],
[r_out * numpy.cos(-half_sweep), r_out * numpy.sin(-half_sweep)],
[peak_out_x, 0.0],
[peak_r * numpy.cos(-half_sweep/2), peak_r * numpy.sin(-half_sweep/2)],
[peak_r * numpy.cos(half_sweep/2), peak_r * numpy.sin(half_sweep/2)],
[r_out * numpy.cos(half_sweep), r_out * numpy.sin(half_sweep)],
[r_in * numpy.cos(half_sweep), r_in * numpy.sin(half_sweep)],
[r_in, 0.0]