-
Notifications
You must be signed in to change notification settings - Fork 0
/
ThumbWheel.coscad
78 lines (61 loc) · 1.96 KB
/
ThumbWheel.coscad
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
total_radius = 15
base_height = 3
knobbles_num = 7
knobbles_radius = 2
knobbles_height = 4
centerhole_radius = 1.55
centerhex_radus = 3.1
centerhex_height = 2
centerhub_height = 4
centerhub_radius = 4
distance_to_knobbles = total_radius - knobbles_radius
angleA = 360 / knobbles_num
angleARadians = angleA * (3.14159265359 / 180)
# this function calculates the third side of a triangle from two sides(a,b) and an angle(A)
get_sideC = (side_a, side_b, angle_A) -> Math.sqrt (Math.pow(side_a, 2) + Math.pow(side_b, 2) - 2 * side_a * side_b * Math.cos(angle_A))
#the center hub:
hub = new Cylinder
h: centerhub_height
r: centerhub_radius
center: [0, 0, centerhub_height / 2]
#the nut-trap:
hex = new Cylinder
h: centerhex_height
r: centerhex_radus
center: [0, 0, centerhub_height - centerhex_height / 2]
$fn: 6 # This sets the number of sides to six.
nuttrap = new Cylinder
h: centerhub_height
r: centerhole_radius
center: [0, 0, centerhub_height / 2]
nuttrap = nuttrap.union(hex)
#the base
base = new Cylinder
h: base_height
r: distance_to_knobbles
center: [0, 0, base_height / 2]
#the little.... knobs.
knobble = new Cylinder
h: knobbles_height
r: knobbles_radius
center: [0, distance_to_knobbles, knobbles_height / 2]
#distance between the nobbles:
knobble_seperation = get_sideC(distance_to_knobbles, distance_to_knobbles, angleARadians)
#the scooped out section between the nobbles:
scallop = new Cylinder
h: base_height
r: (knobble_seperation - knobbles_radius) / 2
center: [0, distance_to_knobbles, base_height / 2]
scallop = scallop.rotate [0, 0, angleA / 2]
#carving the object
shape = base.union(hub)
shape = shape.subtract(nuttrap)
#cutting out the scallops: (using while loop)
i = 0
while i < knobbles_num
shape = shape.subtract(scallop.rotate [0 ,0 , angleA * i])
i++
#adding the knobs: (using for loop)
for i in [0..knobbles_num]
shape = shape.union(knobble.rotate [0 , 0, angleA * i])
return shape