-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgear
More file actions
50 lines (41 loc) · 1.2 KB
/
gear
File metadata and controls
50 lines (41 loc) · 1.2 KB
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
def MakeGear(x as Number y as Number
radius as Number
n_cogs as Number
cog_space as Number
cog_height as Number ) = {
def pi = 3.14159265359
def outer_radius = radius
def inner_radius = 30
def length = (pi * 2) / n_cogs
def radian = pi * outer_radius
def space_radian = (cog_space / radian) * pi
def cog_radian = length - space_radian
arc(x y inner_radius 0 pi * 2)
repeat 0 to n_cogs using i {
def start = (length * i) - cog_radian
def end = length * i
def middle = (space_radian / 2)
arc(x y outer_radius start end)
def sx = cos(length * i)
def sy = sin(length * i)
def cx = cos(end - middle)
def cy = sin(end - middle)
def ex = cos(end - space_radian)
def ey = sin(end - space_radian)
def p1x = x + sx * outer_radius
def p1y = y + sy * outer_radius
def p2x = x + ex * outer_radius
def p2y = y + ey * outer_radius
line(p1x p1y
p1x - cx * cog_height
p1y - cy * cog_height)
line(p2x p2y
p2x - cx * cog_height
p2y - cy * cog_height)
line(p1x - cx * cog_height
p1y - cy * cog_height
p2x - cx * cog_height
p2y - cy * cog_height)
}
}
MakeGear(10 10 50 10 3 10)