rubyscad 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -21
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +322 -322
- data/Rakefile +1 -1
- data/examples/BasicCube.rb +50 -50
- data/examples/ChamferCube.rb +96 -96
- data/examples/FilletCube.rb +317 -317
- data/examples/example001.rb +33 -33
- data/examples/example001.scad +11 -11
- data/examples/example002.rb +23 -23
- data/examples/example002.scad +18 -18
- data/examples/example003.rb +19 -19
- data/examples/example003.scad +15 -15
- data/examples/example004.rb +11 -11
- data/examples/example004.scad +6 -6
- data/examples/example005.rb +22 -22
- data/examples/example005.scad +31 -31
- data/examples/example006.rb +46 -46
- data/examples/example006.scad +221 -221
- data/examples/example007.dxf +2410 -2410
- data/examples/example007.rb +53 -53
- data/examples/example007.scad +30 -30
- data/examples/example008.dxf +3238 -3238
- data/examples/example008.rb +34 -34
- data/examples/example008.scad +26 -26
- data/examples/example009.dxf +3894 -3894
- data/examples/example009.rb +33 -33
- data/examples/example009.scad +15 -15
- data/examples/example010.dat +51 -51
- data/examples/example010.rb +12 -12
- data/examples/example010.scad +7 -7
- data/examples/example011.rb +22 -22
- data/examples/example011.scad +3 -3
- data/examples/example012.rb +16 -16
- data/examples/example012.scad +8 -8
- data/examples/example013.dxf +2276 -2276
- data/examples/example013.rb +16 -16
- data/examples/example013.scad +12 -12
- data/examples/example014.rb +14 -14
- data/examples/example014.scad +12 -12
- data/examples/example015.rb +33 -33
- data/examples/example015.scad +22 -22
- data/examples/example016.rb +43 -43
- data/examples/example016.scad +49 -49
- data/examples/example017.rb +170 -170
- data/examples/example017.scad +124 -124
- data/examples/example018.rb +29 -29
- data/examples/example018.scad +74 -74
- data/examples/example019.rb +22 -22
- data/examples/example019.scad +84 -84
- data/examples/example020.rb +92 -92
- data/examples/example020.scad +62 -62
- data/examples/example021.rb +42 -42
- data/examples/example021.scad +159 -159
- data/examples/example022.rb +44 -44
- data/examples/example022.scad +103 -103
- data/lib/rubyscad.rb +2 -2
- data/lib/rubyscad/RubyScad.rb +369 -361
- data/lib/rubyscad/version.rb +3 -3
- data/rubyscad.gemspec +20 -20
- metadata +7 -9
data/examples/example019.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require "rubyscad"
|
2
|
-
|
3
|
-
module Example019
|
4
|
-
extend RubyScad
|
5
|
-
|
6
|
-
def self.get_cylinder_h(p)
|
7
|
-
lookup(p, {
|
8
|
-
-200=>5,
|
9
|
-
-50=>20,
|
10
|
-
-20=>18,
|
11
|
-
80=>25,
|
12
|
-
150=>2
|
13
|
-
})
|
14
|
-
end
|
15
|
-
|
16
|
-
(-100..100).step(5) do |i|
|
17
|
-
#echo(i, get_cylinder_h(i));
|
18
|
-
translate(v: [ i, 0, -30 ])
|
19
|
-
cylinder(r1: 6, r2: 2, h: get_cylinder_h(i)*3)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
1
|
+
require "rubyscad"
|
2
|
+
|
3
|
+
module Example019
|
4
|
+
extend RubyScad
|
5
|
+
|
6
|
+
def self.get_cylinder_h(p)
|
7
|
+
lookup(p, {
|
8
|
+
-200=>5,
|
9
|
+
-50=>20,
|
10
|
+
-20=>18,
|
11
|
+
80=>25,
|
12
|
+
150=>2
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
(-100..100).step(5) do |i|
|
17
|
+
#echo(i, get_cylinder_h(i));
|
18
|
+
translate(v: [ i, 0, -30 ])
|
19
|
+
cylinder(r1: 6, r2: 2, h: get_cylinder_h(i)*3)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
data/examples/example019.scad
CHANGED
@@ -1,84 +1,84 @@
|
|
1
|
-
//created with rubyscad 1.0
|
2
|
-
|
3
|
-
translate(v = [-100, 0, -30])
|
4
|
-
cylinder(r1 = 6, r2 = 2, h = 45);
|
5
|
-
translate(v = [-95, 0, -30])
|
6
|
-
cylinder(r1 = 6, r2 = 2, h = 45);
|
7
|
-
translate(v = [-90, 0, -30])
|
8
|
-
cylinder(r1 = 6, r2 = 2, h = 48);
|
9
|
-
translate(v = [-85, 0, -30])
|
10
|
-
cylinder(r1 = 6, r2 = 2, h = 48);
|
11
|
-
translate(v = [-80, 0, -30])
|
12
|
-
cylinder(r1 = 6, r2 = 2, h = 51);
|
13
|
-
translate(v = [-75, 0, -30])
|
14
|
-
cylinder(r1 = 6, r2 = 2, h = 51);
|
15
|
-
translate(v = [-70, 0, -30])
|
16
|
-
cylinder(r1 = 6, r2 = 2, h = 54);
|
17
|
-
translate(v = [-65, 0, -30])
|
18
|
-
cylinder(r1 = 6, r2 = 2, h = 54);
|
19
|
-
translate(v = [-60, 0, -30])
|
20
|
-
cylinder(r1 = 6, r2 = 2, h = 57);
|
21
|
-
translate(v = [-55, 0, -30])
|
22
|
-
cylinder(r1 = 6, r2 = 2, h = 57);
|
23
|
-
translate(v = [-50, 0, -30])
|
24
|
-
cylinder(r1 = 6, r2 = 2, h = 60);
|
25
|
-
translate(v = [-45, 0, -30])
|
26
|
-
cylinder(r1 = 6, r2 = 2, h = 57);
|
27
|
-
translate(v = [-40, 0, -30])
|
28
|
-
cylinder(r1 = 6, r2 = 2, h = 57);
|
29
|
-
translate(v = [-35, 0, -30])
|
30
|
-
cylinder(r1 = 6, r2 = 2, h = 57);
|
31
|
-
translate(v = [-30, 0, -30])
|
32
|
-
cylinder(r1 = 6, r2 = 2, h = 54);
|
33
|
-
translate(v = [-25, 0, -30])
|
34
|
-
cylinder(r1 = 6, r2 = 2, h = 54);
|
35
|
-
translate(v = [-20, 0, -30])
|
36
|
-
cylinder(r1 = 6, r2 = 2, h = 54);
|
37
|
-
translate(v = [-15, 0, -30])
|
38
|
-
cylinder(r1 = 6, r2 = 2, h = 54);
|
39
|
-
translate(v = [-10, 0, -30])
|
40
|
-
cylinder(r1 = 6, r2 = 2, h = 54);
|
41
|
-
translate(v = [-5, 0, -30])
|
42
|
-
cylinder(r1 = 6, r2 = 2, h = 57);
|
43
|
-
translate(v = [0, 0, -30])
|
44
|
-
cylinder(r1 = 6, r2 = 2, h = 57);
|
45
|
-
translate(v = [5, 0, -30])
|
46
|
-
cylinder(r1 = 6, r2 = 2, h = 57);
|
47
|
-
translate(v = [10, 0, -30])
|
48
|
-
cylinder(r1 = 6, r2 = 2, h = 60);
|
49
|
-
translate(v = [15, 0, -30])
|
50
|
-
cylinder(r1 = 6, r2 = 2, h = 60);
|
51
|
-
translate(v = [20, 0, -30])
|
52
|
-
cylinder(r1 = 6, r2 = 2, h = 60);
|
53
|
-
translate(v = [25, 0, -30])
|
54
|
-
cylinder(r1 = 6, r2 = 2, h = 63);
|
55
|
-
translate(v = [30, 0, -30])
|
56
|
-
cylinder(r1 = 6, r2 = 2, h = 63);
|
57
|
-
translate(v = [35, 0, -30])
|
58
|
-
cylinder(r1 = 6, r2 = 2, h = 63);
|
59
|
-
translate(v = [40, 0, -30])
|
60
|
-
cylinder(r1 = 6, r2 = 2, h = 66);
|
61
|
-
translate(v = [45, 0, -30])
|
62
|
-
cylinder(r1 = 6, r2 = 2, h = 66);
|
63
|
-
translate(v = [50, 0, -30])
|
64
|
-
cylinder(r1 = 6, r2 = 2, h = 66);
|
65
|
-
translate(v = [55, 0, -30])
|
66
|
-
cylinder(r1 = 6, r2 = 2, h = 69);
|
67
|
-
translate(v = [60, 0, -30])
|
68
|
-
cylinder(r1 = 6, r2 = 2, h = 69);
|
69
|
-
translate(v = [65, 0, -30])
|
70
|
-
cylinder(r1 = 6, r2 = 2, h = 69);
|
71
|
-
translate(v = [70, 0, -30])
|
72
|
-
cylinder(r1 = 6, r2 = 2, h = 72);
|
73
|
-
translate(v = [75, 0, -30])
|
74
|
-
cylinder(r1 = 6, r2 = 2, h = 72);
|
75
|
-
translate(v = [80, 0, -30])
|
76
|
-
cylinder(r1 = 6, r2 = 2, h = 75);
|
77
|
-
translate(v = [85, 0, -30])
|
78
|
-
cylinder(r1 = 6, r2 = 2, h = 69);
|
79
|
-
translate(v = [90, 0, -30])
|
80
|
-
cylinder(r1 = 6, r2 = 2, h = 63);
|
81
|
-
translate(v = [95, 0, -30])
|
82
|
-
cylinder(r1 = 6, r2 = 2, h = 60);
|
83
|
-
translate(v = [100, 0, -30])
|
84
|
-
cylinder(r1 = 6, r2 = 2, h = 54);
|
1
|
+
//created with rubyscad 1.0
|
2
|
+
|
3
|
+
translate(v = [-100, 0, -30])
|
4
|
+
cylinder(r1 = 6, r2 = 2, h = 45);
|
5
|
+
translate(v = [-95, 0, -30])
|
6
|
+
cylinder(r1 = 6, r2 = 2, h = 45);
|
7
|
+
translate(v = [-90, 0, -30])
|
8
|
+
cylinder(r1 = 6, r2 = 2, h = 48);
|
9
|
+
translate(v = [-85, 0, -30])
|
10
|
+
cylinder(r1 = 6, r2 = 2, h = 48);
|
11
|
+
translate(v = [-80, 0, -30])
|
12
|
+
cylinder(r1 = 6, r2 = 2, h = 51);
|
13
|
+
translate(v = [-75, 0, -30])
|
14
|
+
cylinder(r1 = 6, r2 = 2, h = 51);
|
15
|
+
translate(v = [-70, 0, -30])
|
16
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
17
|
+
translate(v = [-65, 0, -30])
|
18
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
19
|
+
translate(v = [-60, 0, -30])
|
20
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
21
|
+
translate(v = [-55, 0, -30])
|
22
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
23
|
+
translate(v = [-50, 0, -30])
|
24
|
+
cylinder(r1 = 6, r2 = 2, h = 60);
|
25
|
+
translate(v = [-45, 0, -30])
|
26
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
27
|
+
translate(v = [-40, 0, -30])
|
28
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
29
|
+
translate(v = [-35, 0, -30])
|
30
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
31
|
+
translate(v = [-30, 0, -30])
|
32
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
33
|
+
translate(v = [-25, 0, -30])
|
34
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
35
|
+
translate(v = [-20, 0, -30])
|
36
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
37
|
+
translate(v = [-15, 0, -30])
|
38
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
39
|
+
translate(v = [-10, 0, -30])
|
40
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
41
|
+
translate(v = [-5, 0, -30])
|
42
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
43
|
+
translate(v = [0, 0, -30])
|
44
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
45
|
+
translate(v = [5, 0, -30])
|
46
|
+
cylinder(r1 = 6, r2 = 2, h = 57);
|
47
|
+
translate(v = [10, 0, -30])
|
48
|
+
cylinder(r1 = 6, r2 = 2, h = 60);
|
49
|
+
translate(v = [15, 0, -30])
|
50
|
+
cylinder(r1 = 6, r2 = 2, h = 60);
|
51
|
+
translate(v = [20, 0, -30])
|
52
|
+
cylinder(r1 = 6, r2 = 2, h = 60);
|
53
|
+
translate(v = [25, 0, -30])
|
54
|
+
cylinder(r1 = 6, r2 = 2, h = 63);
|
55
|
+
translate(v = [30, 0, -30])
|
56
|
+
cylinder(r1 = 6, r2 = 2, h = 63);
|
57
|
+
translate(v = [35, 0, -30])
|
58
|
+
cylinder(r1 = 6, r2 = 2, h = 63);
|
59
|
+
translate(v = [40, 0, -30])
|
60
|
+
cylinder(r1 = 6, r2 = 2, h = 66);
|
61
|
+
translate(v = [45, 0, -30])
|
62
|
+
cylinder(r1 = 6, r2 = 2, h = 66);
|
63
|
+
translate(v = [50, 0, -30])
|
64
|
+
cylinder(r1 = 6, r2 = 2, h = 66);
|
65
|
+
translate(v = [55, 0, -30])
|
66
|
+
cylinder(r1 = 6, r2 = 2, h = 69);
|
67
|
+
translate(v = [60, 0, -30])
|
68
|
+
cylinder(r1 = 6, r2 = 2, h = 69);
|
69
|
+
translate(v = [65, 0, -30])
|
70
|
+
cylinder(r1 = 6, r2 = 2, h = 69);
|
71
|
+
translate(v = [70, 0, -30])
|
72
|
+
cylinder(r1 = 6, r2 = 2, h = 72);
|
73
|
+
translate(v = [75, 0, -30])
|
74
|
+
cylinder(r1 = 6, r2 = 2, h = 72);
|
75
|
+
translate(v = [80, 0, -30])
|
76
|
+
cylinder(r1 = 6, r2 = 2, h = 75);
|
77
|
+
translate(v = [85, 0, -30])
|
78
|
+
cylinder(r1 = 6, r2 = 2, h = 69);
|
79
|
+
translate(v = [90, 0, -30])
|
80
|
+
cylinder(r1 = 6, r2 = 2, h = 63);
|
81
|
+
translate(v = [95, 0, -30])
|
82
|
+
cylinder(r1 = 6, r2 = 2, h = 60);
|
83
|
+
translate(v = [100, 0, -30])
|
84
|
+
cylinder(r1 = 6, r2 = 2, h = 54);
|
data/examples/example020.rb
CHANGED
@@ -1,92 +1,92 @@
|
|
1
|
-
require "rubyscad"
|
2
|
-
|
3
|
-
module Example020
|
4
|
-
extend RubyScad
|
5
|
-
extend Math
|
6
|
-
|
7
|
-
def self.screw(type = 2, r1 = 15, r2 = 20, n = 7, h = 100, t = 8)
|
8
|
-
linear_extrude(height: h, twist: 360*t/n, convexity: t)
|
9
|
-
difference() {
|
10
|
-
circle(r: r2)
|
11
|
-
(0..n-1).each do |i|
|
12
|
-
if (type == 1)
|
13
|
-
rotate(a: i*360/n)
|
14
|
-
polygon(points: [
|
15
|
-
[ 2*r2, 0 ],
|
16
|
-
[ r2, 0 ],
|
17
|
-
[ r1*cos((180/n).radians), r1*sin((180/n).radians) ],
|
18
|
-
[ r2*cos((360/n).radians), r2*sin((360/n).radians) ],
|
19
|
-
[ 2*r2*cos((360/n).radians), 2*r2*sin((360/n).radians) ],
|
20
|
-
])
|
21
|
-
elsif (type == 2)
|
22
|
-
rotate(a: i*360/n)
|
23
|
-
polygon(points: [
|
24
|
-
[ 2*r2, 0 ],
|
25
|
-
[ r2, 0 ],
|
26
|
-
[ r1*cos((90/n).radians), r1*sin((90/n).radians) ],
|
27
|
-
[ r1*cos((180/n).radians), r1*sin((180/n).radians) ],
|
28
|
-
[ r2*cos((270/n).radians), r2*sin((270/n).radians) ],
|
29
|
-
[ 2*r2*cos((270/n).radians), 2*r2*sin((270/n).radians) ],
|
30
|
-
])
|
31
|
-
end
|
32
|
-
end
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.nut(type = 2, r1 = 16, r2 = 21, r3 = 30, s = 6, n = 7, h = 100/5, t = 8/5)
|
37
|
-
difference() {
|
38
|
-
cylinder(fn: s, r: r3, h: h)
|
39
|
-
translate(v: [ 0, 0, -h/2 ]); screw(type, r1, r2, n, h*2, t*2)
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.spring(r1 = 100.0, r2 = 10.0, h = 100.0, hr = 12.0)
|
44
|
-
stepsize = 1.0/16.0
|
45
|
-
|
46
|
-
segment = lambda do |i1, i2|
|
47
|
-
alpha1 = i1 * 360*r2/hr
|
48
|
-
alpha2 = i2 * 360*r2/hr
|
49
|
-
len1 = sin(acos((i1*2-1).radians))*r2
|
50
|
-
len2 = sin(acos((i2*2-1).radians))*r2
|
51
|
-
if (len1 < 0.01)
|
52
|
-
polygon(points: [
|
53
|
-
[ cos(alpha1.radians)*r1, sin(alpha1.radians)*r1 ],
|
54
|
-
[ cos(alpha2.radians)*(r1-len2), sin(alpha2.radians)*(r1-len2) ],
|
55
|
-
[ cos(alpha2.radians)*(r1+len2), sin(alpha2.radians)*(r1+len2) ]
|
56
|
-
])
|
57
|
-
end
|
58
|
-
if (len2 < 0.01)
|
59
|
-
polygon(points: [
|
60
|
-
[ cos(alpha1.radians)*(r1+len1), sin(alpha1.radians)*(r1+len1) ],
|
61
|
-
[ cos(alpha1.radians)*(r1-len1), sin(alpha1.radians)*(r1-len1) ],
|
62
|
-
[ cos(alpha2.radians)*r1, sin(alpha2.radians)*r1 ],
|
63
|
-
])
|
64
|
-
end
|
65
|
-
if (len1 >= 0.01 && len2 >= 0.01)
|
66
|
-
polygon(points: [
|
67
|
-
[ cos(alpha1.radians)*(r1+len1), sin(alpha1.radians)*(r1+len1) ],
|
68
|
-
[ cos(alpha1.radians)*(r1-len1), sin(alpha1.radians)*(r1-len1) ],
|
69
|
-
[ cos(alpha2.radians)*(r1-len2), sin(alpha2.radians)*(r1-len2) ],
|
70
|
-
[ cos(alpha2.radians)*(r1+len2), sin(alpha2.radians)*(r1+len2) ]
|
71
|
-
])
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
linear_extrude(height: 100, twist: 180*h/hr, fn: (hr/r2)/stepsize, convexity: 5) {
|
76
|
-
(stepsize..1+stepsize/2).step(stepsize).each do |i|
|
77
|
-
segment.call(i-stepsize, [i, 1].min)
|
78
|
-
end
|
79
|
-
}
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
translate(x: -30)
|
84
|
-
screw()
|
85
|
-
|
86
|
-
translate(x: 30)
|
87
|
-
nut()
|
88
|
-
|
89
|
-
spring()
|
90
|
-
end
|
91
|
-
|
92
|
-
|
1
|
+
require "rubyscad"
|
2
|
+
|
3
|
+
module Example020
|
4
|
+
extend RubyScad
|
5
|
+
extend Math
|
6
|
+
|
7
|
+
def self.screw(type = 2, r1 = 15, r2 = 20, n = 7, h = 100, t = 8)
|
8
|
+
linear_extrude(height: h, twist: 360*t/n, convexity: t)
|
9
|
+
difference() {
|
10
|
+
circle(r: r2)
|
11
|
+
(0..n-1).each do |i|
|
12
|
+
if (type == 1)
|
13
|
+
rotate(a: i*360/n)
|
14
|
+
polygon(points: [
|
15
|
+
[ 2*r2, 0 ],
|
16
|
+
[ r2, 0 ],
|
17
|
+
[ r1*cos((180/n).radians), r1*sin((180/n).radians) ],
|
18
|
+
[ r2*cos((360/n).radians), r2*sin((360/n).radians) ],
|
19
|
+
[ 2*r2*cos((360/n).radians), 2*r2*sin((360/n).radians) ],
|
20
|
+
])
|
21
|
+
elsif (type == 2)
|
22
|
+
rotate(a: i*360/n)
|
23
|
+
polygon(points: [
|
24
|
+
[ 2*r2, 0 ],
|
25
|
+
[ r2, 0 ],
|
26
|
+
[ r1*cos((90/n).radians), r1*sin((90/n).radians) ],
|
27
|
+
[ r1*cos((180/n).radians), r1*sin((180/n).radians) ],
|
28
|
+
[ r2*cos((270/n).radians), r2*sin((270/n).radians) ],
|
29
|
+
[ 2*r2*cos((270/n).radians), 2*r2*sin((270/n).radians) ],
|
30
|
+
])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.nut(type = 2, r1 = 16, r2 = 21, r3 = 30, s = 6, n = 7, h = 100/5, t = 8/5)
|
37
|
+
difference() {
|
38
|
+
cylinder(fn: s, r: r3, h: h)
|
39
|
+
translate(v: [ 0, 0, -h/2 ]); screw(type, r1, r2, n, h*2, t*2)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.spring(r1 = 100.0, r2 = 10.0, h = 100.0, hr = 12.0)
|
44
|
+
stepsize = 1.0/16.0
|
45
|
+
|
46
|
+
segment = lambda do |i1, i2|
|
47
|
+
alpha1 = i1 * 360*r2/hr
|
48
|
+
alpha2 = i2 * 360*r2/hr
|
49
|
+
len1 = sin(acos((i1*2-1).radians))*r2
|
50
|
+
len2 = sin(acos((i2*2-1).radians))*r2
|
51
|
+
if (len1 < 0.01)
|
52
|
+
polygon(points: [
|
53
|
+
[ cos(alpha1.radians)*r1, sin(alpha1.radians)*r1 ],
|
54
|
+
[ cos(alpha2.radians)*(r1-len2), sin(alpha2.radians)*(r1-len2) ],
|
55
|
+
[ cos(alpha2.radians)*(r1+len2), sin(alpha2.radians)*(r1+len2) ]
|
56
|
+
])
|
57
|
+
end
|
58
|
+
if (len2 < 0.01)
|
59
|
+
polygon(points: [
|
60
|
+
[ cos(alpha1.radians)*(r1+len1), sin(alpha1.radians)*(r1+len1) ],
|
61
|
+
[ cos(alpha1.radians)*(r1-len1), sin(alpha1.radians)*(r1-len1) ],
|
62
|
+
[ cos(alpha2.radians)*r1, sin(alpha2.radians)*r1 ],
|
63
|
+
])
|
64
|
+
end
|
65
|
+
if (len1 >= 0.01 && len2 >= 0.01)
|
66
|
+
polygon(points: [
|
67
|
+
[ cos(alpha1.radians)*(r1+len1), sin(alpha1.radians)*(r1+len1) ],
|
68
|
+
[ cos(alpha1.radians)*(r1-len1), sin(alpha1.radians)*(r1-len1) ],
|
69
|
+
[ cos(alpha2.radians)*(r1-len2), sin(alpha2.radians)*(r1-len2) ],
|
70
|
+
[ cos(alpha2.radians)*(r1+len2), sin(alpha2.radians)*(r1+len2) ]
|
71
|
+
])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
linear_extrude(height: 100, twist: 180*h/hr, fn: (hr/r2)/stepsize, convexity: 5) {
|
76
|
+
(stepsize..1+stepsize/2).step(stepsize).each do |i|
|
77
|
+
segment.call(i-stepsize, [i, 1].min)
|
78
|
+
end
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
translate(x: -30)
|
84
|
+
screw()
|
85
|
+
|
86
|
+
translate(x: 30)
|
87
|
+
nut()
|
88
|
+
|
89
|
+
spring()
|
90
|
+
end
|
91
|
+
|
92
|
+
|
data/examples/example020.scad
CHANGED
@@ -1,62 +1,62 @@
|
|
1
|
-
//created with rubyscad 1.0
|
2
|
-
|
3
|
-
translate(v = [-30, 0])
|
4
|
-
linear_extrude(height = 100, twist = 411, convexity = 8)
|
5
|
-
difference() {
|
6
|
-
circle(r = 20);
|
7
|
-
rotate(a = 0)
|
8
|
-
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
9
|
-
rotate(a = 51)
|
10
|
-
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
11
|
-
rotate(a = 102)
|
12
|
-
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
13
|
-
rotate(a = 154)
|
14
|
-
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
15
|
-
rotate(a = 205)
|
16
|
-
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
17
|
-
rotate(a = 257)
|
18
|
-
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
19
|
-
rotate(a = 308)
|
20
|
-
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
21
|
-
}
|
22
|
-
translate(v = [30, 0])
|
23
|
-
difference() {
|
24
|
-
cylinder($fn = 6, r = 30, h = 20);
|
25
|
-
translate(v = [0, 0, -10])
|
26
|
-
linear_extrude(height = 40, twist = 102, convexity = 2)
|
27
|
-
difference() {
|
28
|
-
circle(r = 21);
|
29
|
-
rotate(a = 0)
|
30
|
-
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
31
|
-
rotate(a = 51)
|
32
|
-
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
33
|
-
rotate(a = 102)
|
34
|
-
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
35
|
-
rotate(a = 154)
|
36
|
-
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
37
|
-
rotate(a = 205)
|
38
|
-
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
39
|
-
rotate(a = 257)
|
40
|
-
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
41
|
-
rotate(a = 308)
|
42
|
-
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
43
|
-
}
|
44
|
-
}
|
45
|
-
linear_extrude(height = 100, twist = 1500.000, $fn = 19.200, convexity = 5) {
|
46
|
-
polygon(points = [[109.998, 0.000], [90.002, 0.000], [85.225, 28.930], [104.161, 35.358]]);
|
47
|
-
polygon(points = [[104.161, 35.358], [85.225, 28.930], [71.402, 54.789], [87.268, 66.963]]);
|
48
|
-
polygon(points = [[87.268, 66.963], [71.402, 54.789], [50.002, 74.833], [61.112, 91.461]]);
|
49
|
-
polygon(points = [[61.112, 91.461], [50.002, 74.833], [23.294, 86.934], [28.470, 106.251]]);
|
50
|
-
polygon(points = [[28.470, 106.251], [23.294, 86.934], [-5.886, 89.808], [-7.194, 109.764]]);
|
51
|
-
polygon(points = [[-7.194, 109.764], [-5.886, 89.808], [-34.442, 83.149], [-42.095, 101.627]]);
|
52
|
-
polygon(points = [[-42.095, 101.627], [-34.442, 83.149], [-59.341, 67.666], [-72.528, 82.702]]);
|
53
|
-
polygon(points = [[-72.528, 82.702], [-59.341, 67.666], [-77.942, 45.000], [-95.263, 55.000]]);
|
54
|
-
polygon(points = [[-95.263, 55.000], [-77.942, 45.000], [-88.271, 17.558], [-107.886, 21.460]]);
|
55
|
-
polygon(points = [[-107.886, 21.460], [-88.271, 17.558], [-89.230, -11.747], [-109.059, -14.358]]);
|
56
|
-
polygon(points = [[-109.059, -14.358], [-89.230, -11.747], [-80.719, -39.806], [-98.656, -48.652]]);
|
57
|
-
polygon(points = [[-98.656, -48.652], [-80.719, -39.806], [-63.640, -63.640], [-77.781, -77.781]]);
|
58
|
-
polygon(points = [[-77.781, -77.781], [-63.640, -63.640], [-39.806, -80.719], [-48.651, -98.655]]);
|
59
|
-
polygon(points = [[-48.651, -98.655], [-39.806, -80.719], [-11.747, -89.231], [-14.358, -109.058]]);
|
60
|
-
polygon(points = [[-14.358, -109.058], [-11.747, -89.231], [17.558, -88.272], [21.460, -107.885]]);
|
61
|
-
polygon(points = [[21.460, -107.885], [17.558, -88.272], [45.001, -77.944], [54.999, -95.261]]);
|
62
|
-
}
|
1
|
+
//created with rubyscad 1.0
|
2
|
+
|
3
|
+
translate(v = [-30, 0])
|
4
|
+
linear_extrude(height = 100, twist = 411, convexity = 8)
|
5
|
+
difference() {
|
6
|
+
circle(r = 20);
|
7
|
+
rotate(a = 0)
|
8
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
9
|
+
rotate(a = 51)
|
10
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
11
|
+
rotate(a = 102)
|
12
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
13
|
+
rotate(a = 154)
|
14
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
15
|
+
rotate(a = 205)
|
16
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
17
|
+
rotate(a = 257)
|
18
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
19
|
+
rotate(a = 308)
|
20
|
+
polygon(points = [[40, 0], [20, 0], [14.672, 3.119], [13.595, 6.339], [15.760, 12.313], [31.520, 24.626]]);
|
21
|
+
}
|
22
|
+
translate(v = [30, 0])
|
23
|
+
difference() {
|
24
|
+
cylinder($fn = 6, r = 30, h = 20);
|
25
|
+
translate(v = [0, 0, -10])
|
26
|
+
linear_extrude(height = 40, twist = 102, convexity = 2)
|
27
|
+
difference() {
|
28
|
+
circle(r = 21);
|
29
|
+
rotate(a = 0)
|
30
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
31
|
+
rotate(a = 51)
|
32
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
33
|
+
rotate(a = 102)
|
34
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
35
|
+
rotate(a = 154)
|
36
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
37
|
+
rotate(a = 205)
|
38
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
39
|
+
rotate(a = 257)
|
40
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
41
|
+
rotate(a = 308)
|
42
|
+
polygon(points = [[42, 0], [21, 0], [15.650, 3.327], [14.501, 6.762], [16.548, 12.929], [33.096, 25.858]]);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
linear_extrude(height = 100, twist = 1500.000, $fn = 19.200, convexity = 5) {
|
46
|
+
polygon(points = [[109.998, 0.000], [90.002, 0.000], [85.225, 28.930], [104.161, 35.358]]);
|
47
|
+
polygon(points = [[104.161, 35.358], [85.225, 28.930], [71.402, 54.789], [87.268, 66.963]]);
|
48
|
+
polygon(points = [[87.268, 66.963], [71.402, 54.789], [50.002, 74.833], [61.112, 91.461]]);
|
49
|
+
polygon(points = [[61.112, 91.461], [50.002, 74.833], [23.294, 86.934], [28.470, 106.251]]);
|
50
|
+
polygon(points = [[28.470, 106.251], [23.294, 86.934], [-5.886, 89.808], [-7.194, 109.764]]);
|
51
|
+
polygon(points = [[-7.194, 109.764], [-5.886, 89.808], [-34.442, 83.149], [-42.095, 101.627]]);
|
52
|
+
polygon(points = [[-42.095, 101.627], [-34.442, 83.149], [-59.341, 67.666], [-72.528, 82.702]]);
|
53
|
+
polygon(points = [[-72.528, 82.702], [-59.341, 67.666], [-77.942, 45.000], [-95.263, 55.000]]);
|
54
|
+
polygon(points = [[-95.263, 55.000], [-77.942, 45.000], [-88.271, 17.558], [-107.886, 21.460]]);
|
55
|
+
polygon(points = [[-107.886, 21.460], [-88.271, 17.558], [-89.230, -11.747], [-109.059, -14.358]]);
|
56
|
+
polygon(points = [[-109.059, -14.358], [-89.230, -11.747], [-80.719, -39.806], [-98.656, -48.652]]);
|
57
|
+
polygon(points = [[-98.656, -48.652], [-80.719, -39.806], [-63.640, -63.640], [-77.781, -77.781]]);
|
58
|
+
polygon(points = [[-77.781, -77.781], [-63.640, -63.640], [-39.806, -80.719], [-48.651, -98.655]]);
|
59
|
+
polygon(points = [[-48.651, -98.655], [-39.806, -80.719], [-11.747, -89.231], [-14.358, -109.058]]);
|
60
|
+
polygon(points = [[-14.358, -109.058], [-11.747, -89.231], [17.558, -88.272], [21.460, -107.885]]);
|
61
|
+
polygon(points = [[21.460, -107.885], [17.558, -88.272], [45.001, -77.944], [54.999, -95.261]]);
|
62
|
+
}
|