From d98d23f8b5d61bb9d20e743a3c44bf04b6b2330a Mon Sep 17 00:00:00 2001 From: Hamilton Kibbe Date: Mon, 2 Feb 2015 00:43:08 -0500 Subject: More tests and bugfixes --- gerber/primitives.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'gerber/primitives.py') diff --git a/gerber/primitives.py b/gerber/primitives.py index 61df7c1..da05127 100644 --- a/gerber/primitives.py +++ b/gerber/primitives.py @@ -345,20 +345,25 @@ class Obround(Primitive): self.position = position self.width = width self.height = height - - @property - def orientation(self): - return 'vertical' if self.height > self.width else 'horizontal' + # Axis-aligned width and height + self._abs_width = (math.cos(math.radians(self.rotation)) * self.width + + math.sin(math.radians(self.rotation)) * self.height) + self._abs_height = (math.cos(math.radians(self.rotation)) * self.height + + math.sin(math.radians(self.rotation)) * self.width) @property def lower_left(self): - return (self.position[0] - (self.width / 2.), - self.position[1] - (self.height / 2.)) + return (self.position[0] - (self._abs_width / 2.), + self.position[1] - (self._abs_height / 2.)) @property def upper_right(self): - return (self.position[0] + (self.width / 2.), - self.position[1] + (self.height / 2.)) + return (self.position[0] + (self._abs_width / 2.), + self.position[1] + (self._abs_height / 2.)) + + @property + def orientation(self): + return 'vertical' if self.height > self.width else 'horizontal' @property def bounding_box(self): @@ -380,7 +385,7 @@ class Obround(Primitive): else: circle1 = Circle((self.position[0] - (self.height - self.width) / 2., self.position[1]), self.height) - circle2 = Circle((self.position[0] - (self.height - self.width) / 2., + circle2 = Circle((self.position[0] + (self.height - self.width) / 2., self.position[1]), self.height) rect = Rectangle(self.position, (self.width - self.height), self.height) -- cgit