From 814405f0be45a9e95736e381adb8f3fb35a634b6 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Tue, 6 Dec 2022 20:10:32 +0100 Subject: [PATCH] DisplayShelf: Fix shelf placement for negative angles Resolves: #463 --- boxes/generators/displayshelf.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/boxes/generators/displayshelf.py b/boxes/generators/displayshelf.py index 5cc0170..411388c 100644 --- a/boxes/generators/displayshelf.py +++ b/boxes/generators/displayshelf.py @@ -41,12 +41,15 @@ class DisplayShelf(Boxes): # change class name here and below t = self.thickness a = math.radians(self.angle) - + hs = (self.sl+t) * math.sin(a) + math.cos(a) * t for i in range(self.num): pos_x = abs(0.5*t*math.sin(a)) - pos_y = hs - math.cos(a)*0.5*t + i * (self.h-hs) / (self.num - 0.5) + pos_y = hs - math.cos(a)*0.5*t + i * (self.h-abs(hs)) / (self.num - 0.5) + if a < 0: + pos_y += -math.sin(a) * self.sl + self.fingerHolesAt(pos_x, pos_y, self.sl, -self.angle) pos_x += math.cos(-a) * (self.sl+0.5*t) + math.sin(a)*0.5*t pos_y += math.sin(-a) * (self.sl+0.5*t) + math.cos(a)*0.5*t