fix custom poly transform

This commit is contained in:
Jan Petykiewicz 2026-03-21 01:30:51 -07:00
commit 7455917b4a
3 changed files with 4 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 89 KiB

Before After
Before After

View file

@ -34,7 +34,8 @@ def main() -> None:
# 4. Define a custom 'trapezoid' bend model
# (Just for demonstration - we override the collision model during search)
custom_poly = Polygon([(0, 0), (20, 0), (20, 20), (0, 20)]) # Oversized box
# Define a custom centered 20x20 box
custom_poly = Polygon([(-10, -10), (10, -10), (10, 10), (-10, 10)])
print("Routing with custom collision model...")
# Override bend_collision_type with a literal Polygon

View file

@ -434,7 +434,8 @@ def _apply_collision_model(
Applies the specified collision model to an arc geometry.
"""
if isinstance(collision_type, Polygon):
return [collision_type]
# Translate the custom polygon to the bend center (cx, cy)
return [shapely.transform(collision_type, lambda x: x + [cx, cy])]
if collision_type == "arc":
return [arc_poly]