From dc11929258a0ecac9802ec5f7924d1938c5d0743 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Sun, 7 Apr 2019 17:27:29 +0200 Subject: [PATCH] Fix _polygonWallExtend for corners with negative angles --- boxes/__init__.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/boxes/__init__.py b/boxes/__init__.py index 06e1354..254702f 100755 --- a/boxes/__init__.py +++ b/boxes/__init__.py @@ -1827,18 +1827,31 @@ class Boxes: except TypeError: angle = (angle + borders[i]) % 360 continue - centerx = posx + r * math.cos(math.radians(angle+90)) - centery = posy + r * math.sin(math.radians(angle+90)) + if a > 0: + centerx = posx + r * math.cos(math.radians(angle+90)) + centery = posy + r * math.sin(math.radians(angle+90)) + else: + centerx = posx + r * math.cos(math.radians(angle-90)) + centery = posy + r * math.sin(math.radians(angle-90)) for direction in (0, 90, 180, 270): - if ((a > 0 and - angle <= direction and angle + a >= direction) or - (a < 0 and - angle >= direction and angle + a <= direction)): - checkpoint(ext, centerx + r * math.cos(math.radians(direction)), centery + r * math.sin(math.radians(direction))) + if (a > 0 and + angle <= direction and (angle + a) % 360 >= direction): + direction -= 90 + elif (a < 0 and + angle >= direction and (angle + a) % 360 <= direction): + direction -= 90 + else: + continue + checkpoint(ext, centerx + r * math.cos(math.radians(direction)), centery + r * math.sin(math.radians(direction))) + #print("%4s %4s %4s %f %f" % (angle, direction+90, angle+a, centerx + r * math.cos(math.radians(direction)), centery + r * math.sin(math.radians(direction)))) angle = (angle + a) % 360 - posx = centerx + r * math.cos(math.radians(angle-90)) - posy = centery + r * math.sin(math.radians(angle-90)) + if a > 0: + posx = centerx + r * math.cos(math.radians(angle-90)) + posy = centery + r * math.sin(math.radians(angle-90)) + else: + posx = centerx + r * math.cos(math.radians(angle+90)) + posy = centery + r * math.sin(math.radians(angle+90)) else: posx += borders[i] * math.cos(math.radians(angle)) posy += borders[i] * math.sin(math.radians(angle))