From d4fbdd8d27167cfcb94016dc563c1b0b487f428a Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Tue, 11 Aug 2020 01:17:23 -0700 Subject: [PATCH] add fast-path for 0-degree rotations --- masque/shapes/path.py | 3 ++- masque/shapes/polygon.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/masque/shapes/path.py b/masque/shapes/path.py index db7831a..b618001 100644 --- a/masque/shapes/path.py +++ b/masque/shapes/path.py @@ -314,7 +314,8 @@ class Path(Shape): return bounds def rotate(self, theta: float) -> 'Path': - self.vertices = numpy.dot(rotation_matrix_2d(theta), self.vertices.T).T + if theta != 0: + self.vertices = numpy.dot(rotation_matrix_2d(theta), self.vertices.T).T return self def mirror(self, axis: int) -> 'Path': diff --git a/masque/shapes/polygon.py b/masque/shapes/polygon.py index 71c9491..97cc66c 100644 --- a/masque/shapes/polygon.py +++ b/masque/shapes/polygon.py @@ -262,7 +262,8 @@ class Polygon(Shape): self.offset + numpy.max(self.vertices, axis=0))) def rotate(self, theta: float) -> 'Polygon': - self.vertices = numpy.dot(rotation_matrix_2d(theta), self.vertices.T).T + if theta != 0: + self.vertices = numpy.dot(rotation_matrix_2d(theta), self.vertices.T).T return self def mirror(self, axis: int) -> 'Polygon':