-
Notifications
You must be signed in to change notification settings - Fork 47
/
MinkowskiRound.scad
113 lines (101 loc) · 3.56 KB
/
MinkowskiRound.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Library: MinkowskiRound.scad
// Version: 1.0
// Author: IrevDev
// Copyright: 2020
// License: MIT
/*
---Modules
round2d(outside radius,internal radius) -> takes 2d children
This module will round 2d any shape
minkowskiRound(outsideRadius,internalRadius,enable,envelopecube[x,y,z]) -> takes 3d children
This module will round any 3d shape though it takes a long time, possibly more than 12 hours (use a low $fn value, 10-15 to begin with) so make sure enable is set to 0 untill you are ready for final render,the envelopecube must be bigger than the object you are rounding, default values are [500,500,500].
minkowskiOutsideRound(radius,enable,envelopecube[x,y,z])
minkowskiInsideRound(radius,enable,envelopecube[x,y,z])
Both this modules do the same thing as minkowskiRound() but focus on either inside or outside radiuses, which means these modules use one less minkowski() (two instead of three) making them quicker if you don't want both inside and outside radiuses.
--Examples
*/
//round2d(1,6)difference(){square([20,20]);square([10,10]);}
//minkowskiRound(3,1.5,1)theshape();
//minkowskiInsideRound(3,1)theshape();
//minkowskiOutsideRound(3,1)theshape();
//---good test child for examples
//module theshape(){//example shape
// difference(){
// cube([20,20,20]);
// cube([10,10,10]);
// }
//}
// $fn=20;
// minkowskiRound(0.7,1.5,1,[50,50,50])union(){//--example in the thiniverse thumbnail/main image
// cube([6,6,22]);
// rotate([30,45,10])cylinder(h=22,d=10);
// }//--I rendered this out with a $fn=25 and it took more than 12 hours on my computer
module round2d(OR=3,IR=1){
offset(OR){
offset(-IR-OR){
offset(IR){
children();
}
}
}
}
module minkowskiRound(OR=1,IR=1,enable=1,boundingEnvelope=[500,500,500]){
if(enable==0){//do nothing if not enabled
children();
} else {
minkowski(){//expand the now positive shape back out
difference(){//make the negative shape positive again
cube(boundingEnvelope-[0.1,0.1,0.1],center=true);
minkowski(){//expand the negative shape inwards
difference(){//create a negative of the children
cube(boundingEnvelope,center=true);
minkowski(){//expand the children
children();
sphere(IR);
}
}
sphere(OR+IR);
}
}
sphere(OR);
}
}
}
module minkowskiOutsideRound(r=1,enable=1,boundingEnvelope=[500,500,500]){
if(enable==0){//do nothing if not enabled
children();
} else {
minkowski(){//expand the now positive shape
difference(){//make the negative positive
cube(boundingEnvelope-[0.1,0.1,0.1],center=true);
minkowski(){//expand the negative inwards
difference(){//create a negative of the children
cube(boundingEnvelope,center=true);
children();
}
sphere(r);
}
}
sphere(r);
}
}
}
module minkowskiInsideRound(r=1,enable=1,boundingEnvelope=[500,500,500]){
if(enable==0){//do nothing if not enabled
children();
} else {
difference(){//make the negative positive again
cube(boundingEnvelope-[0.1,0.1,0.1],center=true);
minkowski(){//expand the negative shape inwards
difference(){//make the expanded children a negative shape
cube(boundingEnvelope,center=true);
minkowski(){//expand the children
children();
sphere(r);
}
}
sphere(r);
}
}
}
}