-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.kcl
83 lines (70 loc) · 2.17 KB
/
main.kcl
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
// Hollow Dodecahedron
// A regular dodecahedron or pentagonal dodecahedron is a dodecahedron composed of regular pentagonal faces, three meeting at each vertex. This example shows constructing the individual faces of the dodecahedron and extruding inwards.
// Set units
@settings(defaultLengthUnit = in)
// Input parameters
// circumscribed radius
circR = 25
// Calculated parameters
// thickness of the dodecahedron
wallThickness = circR * 0.2
// angle between faces in radians
dihedral = acos(-(sqrt(5) / 5))
// inscribed radius
inscR = circR / 15 * sqrt(75 + 30 * sqrt(5))
// pentagon edge length
edgeL = 4 * circR / (sqrt(3) * (1 + sqrt(5)))
// pentagon radius
pentR = edgeL / 2 / sin(toRadians(36))
// define a function for a polygon
fn ngon(plane, numSides, radius) {
step = 1 / numSides * tau()
sketch001 = startSketchOn(plane)
|> startProfileAt([cos(0) * radius, sin(0) * radius], %)
return reduce([1..numSides], sketch001, fn(i, sg) {
x = cos(step * i) * radius
y = sin(step * i) * radius
return line(sg, endAbsolute = [x, y])
})
|> close()
}
// Define a plane for the bottom angled face
planeBottomSide = {
plane = {
origin = [
-inscR * cos(toRadians(toDegrees(dihedral) - 90)),
0,
inscR - (inscR * sin(toRadians(toDegrees(dihedral) - 90)))
],
xAxis = [cos(dihedral), 0.0, sin(dihedral)],
yAxis = [0, 1, 0],
zAxis = [sin(dihedral), 0, -cos(dihedral)]
}
}
// Extrude the faces in each plane
bottom = extrude(ngon("XY", 5, pentR), length = wallThickness)
bottomSide = extrude(ngon(planeBottomSide, 5, pentR), length = wallThickness)
// Pattern the sides so we have a full dodecahedron
bottomBowl = patternCircular3d({
instances = 5,
axis = [0, 0, 1],
center = [0, 0, 0],
arcDegrees = 360,
rotateDuplicates = true
}, bottomSide)
// pattern the bottom to create the top face
patternCircular3d({
instances = 2,
axis = [0, 1, 0],
center = [0, 0, inscR],
arcDegrees = 360,
rotateDuplicates = true
}, bottom)
// pattern the bottom angled faces to create the top
patternCircular3d({
instances = 2,
axis = [0, 1, 0],
center = [0, 0, inscR],
arcDegrees = 360,
rotateDuplicates = true
}, bottomBowl)