[Arc] improve some edge cases when calculating arclengths

This commit is contained in:
Jan Petykiewicz 2026-02-15 01:37:53 -08:00
commit 9bb0d5190d

View file

@ -272,13 +272,16 @@ class Arc(PositionableImpl, Shape):
arc_lengths, thetas = get_arclens(n_pts, *a_ranges[0 if inner else 1], dr=dr) arc_lengths, thetas = get_arclens(n_pts, *a_ranges[0 if inner else 1], dr=dr)
keep = [0] keep = [0]
removable = (numpy.cumsum(arc_lengths) <= max_arclen) start = 0
start = 1
while start < arc_lengths.size: while start < arc_lengths.size:
next_to_keep = start + numpy.where(removable)[0][-1] # TODO: any chance we haven't sampled finely enough? removable = (numpy.cumsum(arc_lengths[start:]) <= max_arclen)
if not removable.any():
next_to_keep = start + 1
else:
next_to_keep = start + numpy.where(removable)[0][-1] + 1
keep.append(next_to_keep) keep.append(next_to_keep)
removable = (numpy.cumsum(arc_lengths[next_to_keep + 1:]) <= max_arclen) start = next_to_keep
start = next_to_keep + 1
if keep[-1] != thetas.size - 1: if keep[-1] != thetas.size - 1:
keep.append(thetas.size - 1) keep.append(thetas.size - 1)