forked from openscad/openscad
-
Notifications
You must be signed in to change notification settings - Fork 2
/
minkowski.scad
49 lines (39 loc) · 967 Bytes
/
minkowski.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
from openscad import *
def dilate(obj,se):
return minkowski([
obj,
se
])
def erode(obj,se):
maxl = 1000
r = 10
invobj = difference([cube(maxl,center=True),obj])
dinvobj = dilate(invobj,se)
invdinvobj = difference([cube(maxl-3*r, center=True), dinvobj])
return invdinvobj
def morphOpen(obj,se):
return dilate(erode(obj,se),se )
def morphClose(obj,se):
return erode(dilate(obj, se), se)
def bevel(obj):
return intersection([
obj,
rotate(45,[0,0,1],obj),
rotate(45,[0,1,0],obj),
rotate(45,[1,0,0],obj),
rotate(90,[1,1,0],obj),
rotate(90,[1,0,1],obj),
rotate(90,[0,1,1],obj),
rotate(90,[1,-1,0],obj),
rotate(90,[1,0,-1],obj),
rotate(90,[0,1,-1],obj),
rotate(90,[-1,1,0],obj),
rotate(90,[-1,0,1],obj),
rotate(90,[0,-1,1],obj),
])
se = render( bevel( bevel( cube(10, True) ) ))
thing = union([cube(50, True),
rotate([20,30,40], cube([10,10,100], True))
])
#openscad.result = se
openscad.result = morphClose(thing,se)