add s-bend example and surface config
This commit is contained in:
parent
82aaf066e2
commit
18b2f83a7b
2 changed files with 212 additions and 39 deletions
|
|
@ -16,9 +16,10 @@ if TYPE_CHECKING:
|
|||
class CollisionEngine:
|
||||
"""Manages spatial queries for collision detection."""
|
||||
|
||||
def __init__(self, clearance: float, max_net_width: float = 2.0) -> None:
|
||||
def __init__(self, clearance: float, max_net_width: float = 2.0, safety_zone_radius: float = 0.0021) -> None:
|
||||
self.clearance = clearance
|
||||
self.max_net_width = max_net_width
|
||||
self.safety_zone_radius = safety_zone_radius
|
||||
self.static_obstacles = rtree.index.Index()
|
||||
# To store geometries for precise checks
|
||||
self.obstacle_geometries: dict[int, Polygon] = {} # ID -> Polygon
|
||||
|
|
@ -131,14 +132,14 @@ class CollisionEngine:
|
|||
|
||||
is_near_start = False
|
||||
if start_port:
|
||||
if (abs(ix_minx - start_port.x) < 0.0021 and abs(ix_maxx - start_port.x) < 0.0021 and
|
||||
abs(ix_miny - start_port.y) < 0.0021 and abs(ix_maxy - start_port.y) < 0.0021):
|
||||
if (abs(ix_minx - start_port.x) < self.safety_zone_radius and abs(ix_maxx - start_port.x) < self.safety_zone_radius and
|
||||
abs(ix_miny - start_port.y) < self.safety_zone_radius and abs(ix_maxy - start_port.y) < self.safety_zone_radius):
|
||||
is_near_start = True
|
||||
|
||||
is_near_end = False
|
||||
if end_port:
|
||||
if (abs(ix_minx - end_port.x) < 0.0021 and abs(ix_maxx - end_port.x) < 0.0021 and
|
||||
abs(ix_miny - end_port.y) < 0.0021 and abs(ix_maxy - end_port.y) < 0.0021):
|
||||
if (abs(ix_minx - end_port.x) < self.safety_zone_radius and abs(ix_maxx - end_port.x) < self.safety_zone_radius and
|
||||
abs(ix_miny - end_port.y) < self.safety_zone_radius and abs(ix_maxy - end_port.y) < self.safety_zone_radius):
|
||||
is_near_end = True
|
||||
|
||||
if is_near_start or is_near_end:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Straight:
|
|||
|
||||
ex = start_port.x + dx
|
||||
ey = start_port.y + dy
|
||||
|
||||
|
||||
if snap_to_grid:
|
||||
ex = snap_search_grid(ex)
|
||||
ey = snap_search_grid(ey)
|
||||
|
|
@ -89,10 +89,10 @@ class Bend90:
|
|||
# End port (snapped to lattice)
|
||||
ex = snap_search_grid(cx + radius * np.cos(t_end))
|
||||
ey = snap_search_grid(cy + radius * np.sin(t_end))
|
||||
|
||||
|
||||
end_orientation = (start_port.orientation + turn_angle) % 360
|
||||
end_port = Port(ex, ey, float(end_orientation))
|
||||
|
||||
|
||||
actual_length = radius * np.pi / 2.0
|
||||
|
||||
# Generate arc geometry
|
||||
|
|
@ -124,12 +124,12 @@ class SBend:
|
|||
ex = snap_search_grid(start_port.x + dx * np.cos(rad_start) - dy * np.sin(rad_start))
|
||||
ey = snap_search_grid(start_port.y + dx * np.sin(rad_start) + dy * np.cos(rad_start))
|
||||
end_port = Port(ex, ey, start_port.orientation)
|
||||
|
||||
|
||||
actual_length = 2 * radius * theta
|
||||
|
||||
# Arc centers and angles (Relative to start orientation)
|
||||
direction = 1 if offset > 0 else -1
|
||||
|
||||
|
||||
# Arc 1
|
||||
c1_angle = rad_start + direction * np.pi / 2
|
||||
cx1 = start_port.x + radius * np.cos(c1_angle)
|
||||
|
|
|
|||
Loading…
Reference in a new issue