Verify route continuity and simplify automatic search setup

This commit is contained in:
Jan Petykiewicz 2026-11-27 15:21:37 -08:00
commit def1e4ea1d

View file

@ -1,10 +1,10 @@
from __future__ import annotations
from itertools import pairwise
from math import isclose
from typing import TYPE_CHECKING
from inire.geometry.primitives import Port
from inire.geometry.sbend import sbend_grid_span
from inire.seeds import Bend90Seed, PathSeed, SBendSeed, StraightSeed
if TYPE_CHECKING:
@ -44,7 +44,7 @@ def compile_waypoints(points: tuple[XY, ...], start: Port, radius: float) -> tup
ux, uy = _HEADINGS[heading // 90]
offset = dy * ux - dx * uy
span = dx * ux + dy * uy
if not 0 < abs(offset) < 2 * radius or not isclose(span**2, abs(offset) * (4 * radius - abs(offset))) or span <= 0:
if not 0 < abs(offset) < 2 * radius or span <= 0 or span != sbend_grid_span(offset, radius):
raise ValueError(f"Invalid S-bend from {a} to {b}")
segments.append(SBendSeed(offset, radius))
continue