Add optional chamfer to teardrops. Defaults to no chamfer.

This commit is contained in:
Martin Budden 2020-02-23 12:16:40 +00:00
parent 8649d59e8a
commit 7a6210f442
2 changed files with 126 additions and 43 deletions

View File

@ -22,25 +22,47 @@ include <../core.scad>
module teardrops() {
color(pp1_colour)
rotate([90, 0, -45])
linear_extrude(height = 3)
difference() {
square(40);
difference() {
linear_extrude(height = 3) {
difference() {
square([80, 40]);
translate([10, 10])
teardrop(h = 0, r = 3);
translate([10, 20])
teardrop_plus(h = 0, r = 3);
translate([20, 30])
tearslot(h = 0, r = 3, w = 10);
translate([30, 15])
vertical_tearslot(h = 0, r =3, l = 10);
translate([20, 10])
semi_teardrop(h = 0, r = 3);
}
}
translate([40, 0, 1.5]) {
h = 3 + eps;
chamfer = 0.5;
translate([10, 10])
teardrop(h = 0, r = 3);
teardrop(h = h, r = 3, chamfer = chamfer);
translate([10, 20])
teardrop_plus(h = 0, r = 3);
teardrop_plus(h = h, r = 3, chamfer = chamfer);
translate([20, 30])
tearslot(h = 0, r = 3, w = 10);
tearslot(h = h, r = 3, w = 10, chamfer = chamfer);
translate([30, 15])
vertical_tearslot(h = 0, r =3, l = 10);
vertical_tearslot(h = h, r =3, l = 10, chamfer = chamfer);
translate([20, 10])
semi_teardrop(h = 0, r = 3);
semi_teardrop(h = h, r = 3, chamfer = chamfer);
}
}
}
teardrops();

View File

@ -21,45 +21,106 @@
//! For making horizontal holes that don't need support material.
//! Small holes can get away without it, but they print better with truncated teardrops.
//
module teardrop(h, r, center = true, truncate = true) //! For making horizontal holes that don't need support material, set ```truncate = false``` to make traditional RepRap teardrops that don't even need bridging
render(convexity = 5)
extrude_if(h, center)
hull() {
circle4n(r);
if(truncate)
translate([0, r / 2])
square([2 * r * (sqrt(2) - 1), r], center = true);
else
polygon([[0, 0], [eps, 0], [0, r * sqrt(2)]]);
}
module semi_teardrop(h, r, d = undef, center = true) //! A semi teardrop in the positive Y domain
render(convexity = 5)
extrude_if(h, center)
intersection() {
R = is_undef(d) ? r : d / 2;
teardrop(r = R, h = 0);
sq = R + 1;
translate([-sq, 0])
square([2 * sq, sq]);
}
module teardrop_plus(h, r, center = true, truncate = true) //! Slightly bigger teardrop to allow for the 3D printing staircase effect
teardrop(h, r + layer_height / 4, center, truncate);
module tearslot(h, r, w, center = true) //! A horizontal slot that doesn't need support material
extrude_if(h, center)
module teardrop(h, r, center = true, truncate = true, chamfer = 0) { //! For making horizontal holes that don't need support material, set ```truncate = false``` to make traditional RepRap teardrops that don't even need bridging
module teardrop_2d(r, truncate) {
hull() {
translate([-w/2,0,0]) teardrop(r = r, h = 0);
translate([ w/2,0,0]) teardrop(r = r, h = 0);
circle4n(r);
if(truncate)
translate([0, r / 2])
square([2 * r * (sqrt(2) - 1), r], center = true);
else
polygon([[0, 0], [eps, 0], [0, r * sqrt(2)]]);
}
}
render(convexity = 5)
extrude_if(h, center)
teardrop_2d(r, truncate);
teardrop_chamfer(h, center, chamfer) {
linear_extrude(eps, center = true)
teardrop_2d(r + chamfer / 2, truncate);
translate_z(-chamfer / 2)
linear_extrude(eps, center = true)
teardrop_2d(r, truncate);
}
}
module semi_teardrop(h, r, d = undef, center = true, chamfer = 0) { //! A semi teardrop in the positive Y domain
module semi_teardrop_2d(r, d) {
intersection() {
R = is_undef(d) ? r : d / 2;
teardrop(r = R, h = 0);
sq = R + 1;
translate([-sq, 0])
square([2 * sq, sq]);
}
}
render(convexity = 5)
extrude_if(h, center)
semi_teardrop_2d(r, d);
teardrop_chamfer(h, center, chamfer) {
linear_extrude(eps, center = true)
semi_teardrop_2d(r + chamfer / 2, d);
translate_z(-chamfer / 2)
linear_extrude(eps, center = true)
semi_teardrop_2d(r, d);
}
}
module teardrop_plus(h, r, center = true, truncate = true, chamfer = 0) //! Slightly bigger teardrop to allow for the 3D printing staircase effect
teardrop(h, r + layer_height / 4, center, truncate, chamfer);
module tearslot(h, r, w, center = true, chamfer = 0) { //! A horizontal slot that doesn't need support material
module tearslot_2d(r, w) {
hull() {
translate([-w / 2, 0]) teardrop(r = r, h = 0);
translate([w / 2, 0]) teardrop(r = r, h = 0);
}
}
module vertical_tearslot(h, r, l, center = true) //! A vertical slot that doesn't need support material
extrude_if(h, center)
tearslot_2d(r, w);
teardrop_chamfer(h, center, chamfer) {
linear_extrude(eps, center = true)
tearslot_2d(r + chamfer / 2, w);
translate_z(-chamfer / 2)
linear_extrude(eps, center = true)
tearslot_2d(r, w);
}
}
module vertical_tearslot(h, r, l, center = true, chamfer = 0) { //! A vertical slot that doesn't need support material
module vertical_tearslot_2d(r, l) {
hull() {
translate([0, l / 2]) teardrop(0, r, true);
translate([0, -l / 2])
circle4n(r);
translate([0, -l / 2]) circle4n(r);
}
}
extrude_if(h, center)
vertical_tearslot_2d(r, l);
teardrop_chamfer(h, center, chamfer) {
linear_extrude(eps, center = true)
vertical_tearslot_2d(r + chamfer / 2, l);
translate_z(-chamfer / 2)
linear_extrude(eps, center = true)
vertical_tearslot_2d(r, l);
}
}
module teardrop_chamfer(h, center, chamfer) { //! Helper module for adding chamfer to a teardrop
if(h && chamfer)
translate_z(center ? 0 : h / 2)
for(m = [0, 1])
mirror([0, 0, m])
translate_z((h - eps ) / 2)
hull()
children();
}