From 41dd123efe6f6fa4a854095608c55534de2d4b60 Mon Sep 17 00:00:00 2001 From: jan Date: Wed, 12 Apr 2023 22:40:08 -0700 Subject: [PATCH] fix bounds --- masque/pattern.py | 7 +++++-- masque/repetition.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/masque/pattern.py b/masque/pattern.py index 223d23f..6019cf0 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -368,8 +368,11 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable): mirr_x, rot2 = normalize_mirror(ref.mirrored) if mirr_x: ubounds[:, 1] *= -1 - bounds = numpy.round(rotation_matrix_2d(ref.rotation + rot2)) @ ubounds - # note: rounding fixes up + + # note: rounding fixes up sin/cos inaccuracy, probably unnecessary + corners = (numpy.round(rotation_matrix_2d(ref.rotation + rot2)) @ ubounds.T).T + bounds = numpy.vstack((numpy.min(corners, axis=0), + numpy.max(corners, axis=0))) * ref.scale + [ref.offset] else: # Non-manhattan rotation, have to figure out bounds by rotating the pattern diff --git a/masque/repetition.py b/masque/repetition.py index cb20883..6bad8a4 100644 --- a/masque/repetition.py +++ b/masque/repetition.py @@ -236,8 +236,8 @@ class Grid(Repetition): Returns: `[[x_min, y_min], [x_max, y_max]]` or `None` """ - a_extent = self.a_vector * self.a_count - b_extent = self.b_vector * self.b_count if (self.b_vector is not None) else 0 # type: NDArray[numpy.float64] | float + a_extent = self.a_vector * (self.a_count - 1) + b_extent = self.b_vector * ((self.b_count - 1) if (self.b_vector is not None) else 0) # type: NDArray[numpy.float64] | float corners = numpy.stack(((0, 0), a_extent, b_extent, a_extent + b_extent)) xy_min = numpy.min(corners, axis=0)