Merge pull request #70 from lordofhyphens/polyhole-centering
@nophead 's polyhole function could use a little more love and attention to make it act a little more like cylinder. This PR adds the center and r parameters, defaulting them to existing behavior if they aren't specified.
This commit is contained in:
commit
830ce58e41
|
@ -2,22 +2,28 @@
|
||||||
// This file is licensed under the terms of Creative Commons Attribution 3.0 Unported.
|
// This file is licensed under the terms of Creative Commons Attribution 3.0 Unported.
|
||||||
|
|
||||||
// Using this holes should come out approximately right when printed
|
// Using this holes should come out approximately right when printed
|
||||||
module polyhole(h, d) {
|
module polyhole(h, d=0, r=0, center=false) {
|
||||||
n = max(round(2 * d),3);
|
_r = (r == 0 ? d / 2 : r);
|
||||||
rotate([0,0,180])
|
_d = (d == 0 ? r * 2 : d);
|
||||||
cylinder(h = h, r = (d / 2) / cos (180 / n), $fn = n);
|
|
||||||
|
n = max(round(2 * _d),3);
|
||||||
|
|
||||||
|
rotate([0,0,180])
|
||||||
|
cylinder(h = h, r = (_d / 2) / cos (180 / n), $fn = n, center=center);
|
||||||
}
|
}
|
||||||
|
|
||||||
module test_polyhole(){
|
module test_polyhole(){
|
||||||
difference() {
|
difference() {
|
||||||
cube(size = [100,27,3]);
|
cube(size = [100,27,3]);
|
||||||
for(i = [1:10]) {
|
union() {
|
||||||
translate([(i * i + i)/2 + 3 * i , 8,-1])
|
for(i = [1:10]) {
|
||||||
polyhole(h = 5, d = i);
|
translate([(i * i + i)/2 + 3 * i , 8,-1])
|
||||||
d = i + 0.5;
|
polyhole(h = 5, d = i);
|
||||||
translate([(d * d + d)/2 + 3 * d, 19,-1])
|
|
||||||
polyhole(h = 5, d = d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
assign(d = i + 0.5)
|
||||||
|
translate([(d * d + d)/2 + 3 * d, 19,-1])
|
||||||
|
polyhole(h = 5, d = d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue