diff --git a/readme.md b/readme.md index be8ad06..6806b99 100644 --- a/readme.md +++ b/readme.md @@ -5387,6 +5387,8 @@ Method to print holes in mid air. See +horicylinder() makes cylinders that fit inside a round hole. Layers that are less than 2 filaments wide and layers that need more than a 45 degree overhang are ommitted. + [utils/horiholes.scad](utils/horiholes.scad) Implementation. @@ -5395,11 +5397,13 @@ Utilities for depicting the staircase slicing of horizontal holes made with [`te ### Functions | Function | Description | |:--- |:--- | +| ```teardrop_minus_x(r, y, h)``` | Calculate the ordinate of a compensated teardrop given y and layer height. | | ```teardrop_plus_x(r, y, h)``` | Calculate the ordinate of a compensated teardrop given y and layer height. | ### Modules | Module | Description | |:--- |:--- | +| ```horicylinder(r, z, h = 0, center = true)``` | For making horizontal cylinders that don't need support material and are correct dimensions | | ```horihole(r, z, h = 0, center = true)``` | For making horizontal holes that don't need support material and are correct dimensions | ![horiholes](tests/png/horiholes.png) diff --git a/tests/horiholes.scad b/tests/horiholes.scad index 85f0b68..c3ffeea 100644 --- a/tests/horiholes.scad +++ b/tests/horiholes.scad @@ -69,9 +69,13 @@ module horiholes() { color(silver) cylinder(r = $r, h = eps, center = true, $fn = 360); + hole_positions() + color("blue") + horicylinder(r = $r, z = $z, h = 2 * eps, center = true, $fn = 360); + hole_positions() color("red") - linear_extrude(2 * eps, center = true) + linear_extrude(3 * eps, center = true) intersection() { difference() { square(8, center = true); diff --git a/tests/png/horiholes.png b/tests/png/horiholes.png index 107a476..bf59de2 100644 Binary files a/tests/png/horiholes.png and b/tests/png/horiholes.png differ diff --git a/utils/horiholes.scad b/utils/horiholes.scad index f6a3e3a..9cdd513 100644 --- a/utils/horiholes.scad +++ b/utils/horiholes.scad @@ -19,6 +19,8 @@ // //! Utilities for depicting the staircase slicing of horizontal holes made with [`teardrop_plus()`](#teardrops), see +//! +//! horicylinder() makes cylinders that fit inside a round hole. Layers that are less than 2 filaments wide and layers that need more than a 45 degree overhang are ommitted. // include <../utils/core/core.scad> @@ -53,3 +55,29 @@ module horihole(r, z, h = 0, center = true) { //! For making horizontal holes th } } } + +function teardrop_minus_x(r, y, h) = //! Calculate the ordinate of a compensated teardrop given y and layer height. + let(fr = h / 2, + hpot = r - fr, + x2 = sqr(hpot) - sqr(y), + x = x2 > 0 ? sqrt(x2) : 0, + X = y >= -hpot / sqrt(2) ? x + fr : 0 + ) + X >= extrusion_width ? X : 0; + +module horicylinder(r, z, h = 0, center = true) { //! For making horizontal cylinders that don't need support material and are correct dimensions + bot_layer = floor((z - r) / layer_height); + top_layer = ceil((z + r) / layer_height); + render(convexity = 5) + extrude_if(h, center) + for(i = [bot_layer : top_layer]) { + Z = i * layer_height; + y = Z - z + layer_height / 2; + x = teardrop_minus_x(r, y, layer_height); + if(x >= extrusion_width) + hull() + for(end = [-1, 1]) + translate([end * (x - layer_height / 2), y]) + circle(d = layer_height, $fn = 32); + } +}