1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-08-31 19:13:33 +02:00

Added tesrdrop_minus() and horicylinder().

This commit is contained in:
Chris Palmer
2020-10-05 10:59:50 +01:00
parent 1529759406
commit 8c2b4a20fe
4 changed files with 37 additions and 1 deletions

View File

@@ -19,6 +19,8 @@
//
//! Utilities for depicting the staircase slicing of horizontal holes made with [`teardrop_plus()`](#teardrops), see <https://hydraraptor.blogspot.com/2020/07/horiholes-2.html>
//!
//! 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);
}
}