warm start and some perf
This commit is contained in:
parent
7e6be50a86
commit
f505694523
1 changed files with 251 additions and 111 deletions
|
|
@ -25,10 +25,20 @@ class Port:
|
|||
x: float,
|
||||
y: float,
|
||||
orientation: float,
|
||||
snap: bool = True
|
||||
) -> None:
|
||||
self.x = snap_nm(x)
|
||||
self.y = snap_nm(y)
|
||||
self.orientation = float(orientation % 360)
|
||||
if snap:
|
||||
self.x = round(x * 1000) / 1000
|
||||
self.y = round(y * 1000) / 1000
|
||||
# Faster orientation normalization for common cases
|
||||
if 0 <= orientation < 360:
|
||||
self.orientation = float(orientation)
|
||||
else:
|
||||
self.orientation = float(orientation % 360)
|
||||
else:
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.orientation = float(orientation)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f'Port(x={self.x}, y={self.y}, orientation={self.orientation})'
|
||||
|
|
|
|||
Loading…
Reference in a new issue