speed up get_bounds when called on a manhattan ref
This commit is contained in:
parent
bb986ffc1c
commit
3fa124d13f
@ -174,7 +174,21 @@ class Ref(
|
||||
if pattern.is_empty():
|
||||
# no need to run as_pattern()
|
||||
return None
|
||||
return self.as_pattern(pattern=pattern).get_bounds(library) # TODO can just take pattern's bounds and then transform those!
|
||||
|
||||
# if rotation is manhattan, can take pattern's bounds and transform them
|
||||
if numpy.isclose(self.rotation % (pi / 2), 0):
|
||||
unrot_bounds = pattern.get_bounds(library)
|
||||
if unrot_bounds is None:
|
||||
return None
|
||||
|
||||
if self.mirrored:
|
||||
unrot_bounds[:, 1] *= -1
|
||||
|
||||
corners = (rotation_matrix_2d(self.rotation) @ unrot_bounds.T).T
|
||||
bounds = numpy.vstack((numpy.min(corners, axis=0),
|
||||
numpy.max(corners, axis=0))) * self.scale + [self.offset]
|
||||
return bounds
|
||||
return self.as_pattern(pattern=pattern).get_bounds(library)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
rotation = f' r{numpy.rad2deg(self.rotation):g}' if self.rotation != 0 else ''
|
||||
|
Loading…
Reference in New Issue
Block a user