Refactor routing internals and archive retry benchmarks
This commit is contained in:
parent
a8720ac8c9
commit
ea5cfe7f31
1 changed files with 3481 additions and 2583 deletions
|
|
@ -63,3 +63,20 @@ ROT2_270 = numpy.array(((0, 1), (-1, 0)), dtype=numpy.int32)
|
|||
def rotation_matrix2(rotation_deg: int | float) -> NDArray[numpy.int32]:
|
||||
quadrant = (_normalize_angle(rotation_deg) // 90) % 4
|
||||
return (ROT2_0, ROT2_90, ROT2_180, ROT2_270)[quadrant]
|
||||
|
||||
|
||||
def rotate_cardinal(x: float, y: float, heading: int) -> tuple[float, float]:
|
||||
"""Rotate by a multiple of 90 degrees without snapping the point."""
|
||||
angle = heading % 360
|
||||
if angle == 0:
|
||||
return x, y
|
||||
if angle == 90:
|
||||
return -y, x
|
||||
if angle == 180:
|
||||
return -x, -y
|
||||
return y, -x
|
||||
|
||||
|
||||
def port_local_coordinates(origin: Port, x: float, y: float) -> tuple[float, float]:
|
||||
"""Project a point into the forward and leftward axes of a port."""
|
||||
return rotate_cardinal(x - origin.x, y - origin.y, -int(origin.r))
|
||||
|
|
|
|||
Loading…
Reference in a new issue