forked from jcrocholl/rostock
-
Notifications
You must be signed in to change notification settings - Fork 2
/
polyholes.scad
43 lines (39 loc) · 1.11 KB
/
polyholes.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// Mendel90
//
// GNU GPL v2
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// See http://hydraraptor.blogspot.com/2011/02/polyholes.html
//
function sides(r) = max(round(4 *r),3);
function corrected_radius(r,n) = 0.1 + r / cos(180 / n);
function corrected_diameter(d) = 0.2 + d / cos(180 / sides(d / 2));
module poly_circle(r, center = false) {
n = sides(r);
circle(r = corrected_radius(r,n), $fn = n, center = center);
}
module poly_cylinder(r, h, center = false) {
n = sides(r);
cylinder(h = h, r = corrected_radius(r,n), $fn = n, center = center);
}
module poly_d_cylinder(r, center = false) {
n = sides(r);
r = corrected_radius(r,n);
cylinder(h = h, r = r, $fn = n, center = center);
translate([0, -r, 0])
cube([r, 2 * r, h]);
}
/**
* Make a thin-walled cylindrical tube.
* @param r outside radius
* @param h height of tube
* @param thickness wall thickness
*/
module poly_tube(r = 5, h = 5, thickness = 1, center = false) {
translate(center ? [0, 0, -h / 2] : 0) linear_extrude(height = h) difference() {
circle(r);
poly_circle(r - thickness);
}
}