From f05d888a0b621ca4e99e2b0fb6e23c097006fe41 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 28 May 2024 10:29:13 +0200 Subject: Init --- progs/a856.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 progs/a856.py (limited to 'progs/a856.py') diff --git a/progs/a856.py b/progs/a856.py new file mode 100644 index 0000000..aa5a8e0 --- /dev/null +++ b/progs/a856.py @@ -0,0 +1,50 @@ +import math +def calculate_polygons(startx, starty, endx, endy, radius): + sl = (2 * radius) * math.tan(math.pi / 6) + p = sl * 0.5 + b = sl * math.cos(math.radians(30)) + w = b * 2 + h = 2 * sl + startx = startx - w + starty = starty - h + endx = endx + w + endy = endy + h + origx = startx + origy = starty + xoffset = b + yoffset = 3 * p + polygons = [] + row = 1 + counter = 0 + while starty < endy: + if row % 2 == 0: + startx = origx + xoffset + else: + startx = origx + while startx < endx: + p1x = startx + p1y = starty + p + p2x = startx + p2y = starty + (3 * p) + p3x = startx + b + p3y = starty + h + p4x = startx + w + p4y = starty + (3 * p) + p5x = startx + w + p5y = starty + p + p6x = startx + b + p6y = starty + poly = [ + (p1x, p1y), + (p2x, p2y), + (p3x, p3y), + (p4x, p4y), + (p5x, p5y), + (p6x, p6y), + (p1x, p1y)] + polygons.append(poly) + counter += 1 + startx += w + starty += yoffset + row += 1 + return polygons \ No newline at end of file -- cgit v1.2.3-18-g5258