-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrounded.scad
41 lines (35 loc) · 1.26 KB
/
rounded.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
module inverseCorner(radius, length) {
difference() {
cube([radius + 0.01, radius + 0.01, length], center = true);
translate([radius / 2, radius / 2, 0])
cylinder(r = radius, h = length + 1, center = true);
}
}
module roundedCube(width, depth, height, radius) {
difference() {
cube([width, depth, height], center = true);
// Front left
translate([(-width / 2) + (radius / 2),
(-depth / 2) + (radius / 2),
0])
inverseCorner(radius=radius, length=depth * 2);
// Front right
translate([(width / 2) - (radius / 2),
(-depth / 2) + (radius / 2),
0])
rotate([0, 0, 90])
inverseCorner(radius=radius, length=depth * 2);
// Back left
translate([(-width / 2) + (radius / 2),
(depth / 2) - (radius / 2),
0])
rotate([0, 0, -90])
inverseCorner(radius=radius, length=height * 2);
// Back right
translate([(width / 2) - (radius / 2),
(depth / 2) - (radius / 2),
0])
rotate([0, 0, 180])
inverseCorner(radius=radius, length=depth * 2);
}
}