From 23dc11bc5f9122ecc707ff4ab97128abecc75151 Mon Sep 17 00:00:00 2001 From: Rock Storm Date: Sun, 30 Sep 2018 19:49:08 +0100 Subject: [PATCH] regular_shapes: Extend hexagon module Allow the hexagon to be defined by the distance between sides, which is also the diameter of the inscribed circle. --- regular_shapes.scad | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/regular_shapes.scad b/regular_shapes.scad index 667d272..f744022 100644 --- a/regular_shapes.scad +++ b/regular_shapes.scad @@ -41,9 +41,12 @@ module pentagon(radius) reg_polygon(5,radius); } -module hexagon(radius) +module hexagon(radius, diameter, across_flats) { - reg_polygon(6,radius); + r = radius; + r = diameter ? diameter/2 : radius; + r = across_flats ? across_flats/2/cos(30) : radius; + reg_polygon(6,r); } module heptagon(radius) @@ -154,9 +157,11 @@ module pentagon_tube(height,radius,wall) tubify(radius,wall) pentagon_prism(height,radius); } -module hexagon_prism(height,radius) +module hexagon_prism(height, radius, across_flats) { - linear_extrude(height=height) hexagon(radius); + r = radius; + r = across_flats ? across_flats/2/cos(30) : radius; + linear_extrude(height=height) hexagon(r); } module hexagon_tube(height,radius,wall)