rubyscad 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -21
  3. data/Gemfile +4 -4
  4. data/LICENSE.txt +21 -21
  5. data/README.md +322 -322
  6. data/Rakefile +1 -1
  7. data/examples/BasicCube.rb +50 -50
  8. data/examples/ChamferCube.rb +96 -96
  9. data/examples/FilletCube.rb +317 -317
  10. data/examples/example001.rb +33 -33
  11. data/examples/example001.scad +11 -11
  12. data/examples/example002.rb +23 -23
  13. data/examples/example002.scad +18 -18
  14. data/examples/example003.rb +19 -19
  15. data/examples/example003.scad +15 -15
  16. data/examples/example004.rb +11 -11
  17. data/examples/example004.scad +6 -6
  18. data/examples/example005.rb +22 -22
  19. data/examples/example005.scad +31 -31
  20. data/examples/example006.rb +46 -46
  21. data/examples/example006.scad +221 -221
  22. data/examples/example007.dxf +2410 -2410
  23. data/examples/example007.rb +53 -53
  24. data/examples/example007.scad +30 -30
  25. data/examples/example008.dxf +3238 -3238
  26. data/examples/example008.rb +34 -34
  27. data/examples/example008.scad +26 -26
  28. data/examples/example009.dxf +3894 -3894
  29. data/examples/example009.rb +33 -33
  30. data/examples/example009.scad +15 -15
  31. data/examples/example010.dat +51 -51
  32. data/examples/example010.rb +12 -12
  33. data/examples/example010.scad +7 -7
  34. data/examples/example011.rb +22 -22
  35. data/examples/example011.scad +3 -3
  36. data/examples/example012.rb +16 -16
  37. data/examples/example012.scad +8 -8
  38. data/examples/example013.dxf +2276 -2276
  39. data/examples/example013.rb +16 -16
  40. data/examples/example013.scad +12 -12
  41. data/examples/example014.rb +14 -14
  42. data/examples/example014.scad +12 -12
  43. data/examples/example015.rb +33 -33
  44. data/examples/example015.scad +22 -22
  45. data/examples/example016.rb +43 -43
  46. data/examples/example016.scad +49 -49
  47. data/examples/example017.rb +170 -170
  48. data/examples/example017.scad +124 -124
  49. data/examples/example018.rb +29 -29
  50. data/examples/example018.scad +74 -74
  51. data/examples/example019.rb +22 -22
  52. data/examples/example019.scad +84 -84
  53. data/examples/example020.rb +92 -92
  54. data/examples/example020.scad +62 -62
  55. data/examples/example021.rb +42 -42
  56. data/examples/example021.scad +159 -159
  57. data/examples/example022.rb +44 -44
  58. data/examples/example022.scad +103 -103
  59. data/lib/rubyscad.rb +2 -2
  60. data/lib/rubyscad/RubyScad.rb +369 -361
  61. data/lib/rubyscad/version.rb +3 -3
  62. data/rubyscad.gemspec +20 -20
  63. metadata +7 -9
@@ -1,33 +1,33 @@
1
- require 'rubyscad'
2
-
3
- class Example001
4
- include RubyScad
5
-
6
- def initialize(args={})
7
- @size = args.fetch(:size, 50).to_f
8
- @hole = args.fetch(:hole, 25).to_f
9
- end
10
-
11
- def r_from_dia(d)
12
- d / 2.0
13
- end
14
-
15
- def rotcy(rot, r, h)
16
- rotate(a: 90, v: rot)
17
- cylinder(r: r, h: h, center: true)
18
- end
19
-
20
- def render
21
- cy_r = r_from_dia(@hole)
22
- cy_h = r_from_dia(@size * 2.5)
23
-
24
- difference() {
25
- sphere(r: r_from_dia(@size))
26
- rotcy([0, 0, 0], cy_r, cy_h)
27
- rotcy([1, 0, 0], cy_r, cy_h)
28
- rotcy([0, 1, 0], cy_r, cy_h)
29
- }
30
- end
31
- end
32
-
33
- Example001.new(size: ARGV.fetch(0, 50), hole: ARGV.fetch(1, 25)).render if __FILE__ == $0
1
+ require 'rubyscad'
2
+
3
+ class Example001
4
+ include RubyScad
5
+
6
+ def initialize(args={})
7
+ @size = args.fetch(:size, 50).to_f
8
+ @hole = args.fetch(:hole, 25).to_f
9
+ end
10
+
11
+ def r_from_dia(d)
12
+ d / 2.0
13
+ end
14
+
15
+ def rotcy(rot, r, h)
16
+ rotate(a: 90, v: rot)
17
+ cylinder(r: r, h: h, center: true)
18
+ end
19
+
20
+ def render
21
+ cy_r = r_from_dia(@hole)
22
+ cy_h = r_from_dia(@size * 2.5)
23
+
24
+ difference() {
25
+ sphere(r: r_from_dia(@size))
26
+ rotcy([0, 0, 0], cy_r, cy_h)
27
+ rotcy([1, 0, 0], cy_r, cy_h)
28
+ rotcy([0, 1, 0], cy_r, cy_h)
29
+ }
30
+ end
31
+ end
32
+
33
+ Example001.new(size: ARGV.fetch(0, 50), hole: ARGV.fetch(1, 25)).render if __FILE__ == $0
@@ -1,11 +1,11 @@
1
- //created with rubyscad 1.0
2
-
3
- difference() {
4
- sphere(r = 25.000);
5
- rotate(a = 90, v = [0, 0, 0])
6
- cylinder(r = 12.500, h = 62.500, center = true);
7
- rotate(a = 90, v = [1, 0, 0])
8
- cylinder(r = 12.500, h = 62.500, center = true);
9
- rotate(a = 90, v = [0, 1, 0])
10
- cylinder(r = 12.500, h = 62.500, center = true);
11
- }
1
+ //created with rubyscad 1.0
2
+
3
+ difference() {
4
+ sphere(r = 25.000);
5
+ rotate(a = 90, v = [0, 0, 0])
6
+ cylinder(r = 12.500, h = 62.500, center = true);
7
+ rotate(a = 90, v = [1, 0, 0])
8
+ cylinder(r = 12.500, h = 62.500, center = true);
9
+ rotate(a = 90, v = [0, 1, 0])
10
+ cylinder(r = 12.500, h = 62.500, center = true);
11
+ }
@@ -1,23 +1,23 @@
1
- require 'rubyscad'
2
-
3
- module Example002
4
- extend RubyScad
5
-
6
- intersection() {
7
- difference() {
8
- union() {
9
- cube(size: 30, center: true)
10
- translate(z:-25)
11
- cube(size: [15, 15, 50], center: true)
12
- }
13
- union() {
14
- cube(size: [50, 10, 10], center: true)
15
- cube(size: [10, 50, 10], center: true)
16
- cube(size: [10, 10, 50], center: true)
17
- }
18
- }
19
- translate(z: 5)
20
- cylinder(h: 50, r1: 20, r2: 5, center: true)
21
- }
22
- end
23
-
1
+ require 'rubyscad'
2
+
3
+ module Example002
4
+ extend RubyScad
5
+
6
+ intersection() {
7
+ difference() {
8
+ union() {
9
+ cube(size: 30, center: true)
10
+ translate(z:-25)
11
+ cube(size: [15, 15, 50], center: true)
12
+ }
13
+ union() {
14
+ cube(size: [50, 10, 10], center: true)
15
+ cube(size: [10, 50, 10], center: true)
16
+ cube(size: [10, 10, 50], center: true)
17
+ }
18
+ }
19
+ translate(z: 5)
20
+ cylinder(h: 50, r1: 20, r2: 5, center: true)
21
+ }
22
+ end
23
+
@@ -1,18 +1,18 @@
1
- //created with rubyscad 1.0
2
-
3
- intersection() {
4
- difference() {
5
- union() {
6
- cube(size = 30, center = true);
7
- translate(v = [0.000, 0.000, -25])
8
- cube(size = [15, 15, 50], center = true);
9
- }
10
- union() {
11
- cube(size = [50, 10, 10], center = true);
12
- cube(size = [10, 50, 10], center = true);
13
- cube(size = [10, 10, 50], center = true);
14
- }
15
- }
16
- translate(v = [0.000, 0.000, 5])
17
- cylinder(h = 50, r1 = 20, r2 = 5, center = true);
18
- }
1
+ //created with rubyscad 1.0
2
+
3
+ intersection() {
4
+ difference() {
5
+ union() {
6
+ cube(size = 30, center = true);
7
+ translate(v = [0.000, 0.000, -25])
8
+ cube(size = [15, 15, 50], center = true);
9
+ }
10
+ union() {
11
+ cube(size = [50, 10, 10], center = true);
12
+ cube(size = [10, 50, 10], center = true);
13
+ cube(size = [10, 10, 50], center = true);
14
+ }
15
+ }
16
+ translate(v = [0.000, 0.000, 5])
17
+ cylinder(h = 50, r1 = 20, r2 = 5, center = true);
18
+ }
@@ -1,19 +1,19 @@
1
- require 'rubyscad'
2
-
3
- module Example003
4
- extend RubyScad
5
-
6
- difference() {
7
- union() {
8
- cube(size: 30, center: true)
9
- cube(size: [40, 15, 15], center: true)
10
- cube(size: [15, 40, 15], center: true)
11
- cube(size: [15, 15, 40], center: true)
12
- }
13
- union() {
14
- cube(size: [50, 10, 10], center: true)
15
- cube(size: [10, 50, 10], center: true)
16
- cube(size: [10, 10, 50], center: true)
17
- }
18
- }
19
- end
1
+ require 'rubyscad'
2
+
3
+ module Example003
4
+ extend RubyScad
5
+
6
+ difference() {
7
+ union() {
8
+ cube(size: 30, center: true)
9
+ cube(size: [40, 15, 15], center: true)
10
+ cube(size: [15, 40, 15], center: true)
11
+ cube(size: [15, 15, 40], center: true)
12
+ }
13
+ union() {
14
+ cube(size: [50, 10, 10], center: true)
15
+ cube(size: [10, 50, 10], center: true)
16
+ cube(size: [10, 10, 50], center: true)
17
+ }
18
+ }
19
+ end
@@ -1,15 +1,15 @@
1
- //created with rubyscad 1.0
2
-
3
- difference() {
4
- union() {
5
- cube(size = 30, center = true);
6
- cube(size = [40, 15, 15], center = true);
7
- cube(size = [15, 40, 15], center = true);
8
- cube(size = [15, 15, 40], center = true);
9
- }
10
- union() {
11
- cube(size = [50, 10, 10], center = true);
12
- cube(size = [10, 50, 10], center = true);
13
- cube(size = [10, 10, 50], center = true);
14
- }
15
- }
1
+ //created with rubyscad 1.0
2
+
3
+ difference() {
4
+ union() {
5
+ cube(size = 30, center = true);
6
+ cube(size = [40, 15, 15], center = true);
7
+ cube(size = [15, 40, 15], center = true);
8
+ cube(size = [15, 15, 40], center = true);
9
+ }
10
+ union() {
11
+ cube(size = [50, 10, 10], center = true);
12
+ cube(size = [10, 50, 10], center = true);
13
+ cube(size = [10, 10, 50], center = true);
14
+ }
15
+ }
@@ -1,11 +1,11 @@
1
- require "rubyscad"
2
-
3
- module Example004
4
- extend RubyScad
5
-
6
- difference() {
7
- cube(size: 30, center: true)
8
- sphere(r: 20)
9
- }
10
- end
11
-
1
+ require "rubyscad"
2
+
3
+ module Example004
4
+ extend RubyScad
5
+
6
+ difference() {
7
+ cube(size: 30, center: true)
8
+ sphere(r: 20)
9
+ }
10
+ end
11
+
@@ -1,6 +1,6 @@
1
- //created with rubyscad 1.0
2
-
3
- difference() {
4
- cube(size = 30, center = true);
5
- sphere(r = 20);
6
- }
1
+ //created with rubyscad 1.0
2
+
3
+ difference() {
4
+ cube(size = 30, center = true);
5
+ sphere(r = 20);
6
+ }
@@ -1,22 +1,22 @@
1
- require "rubyscad"
2
-
3
- module Example005
4
- extend RubyScad
5
-
6
- translate(z: -120) {
7
- difference() {
8
- cylinder(h: 50, r: 100)
9
- translate(z: 10); cylinder(h: 50, r: 80)
10
- translate(v: [100, 0, 35]); cube(size: 50, center: true)
11
- }
12
-
13
- (0..5).each do |i|
14
- echo(360*i/6, Math.sin((360*i/6).radians)*80, Math.cos((360*i/6).radians)*80)
15
- translate(v:[Math.sin((360*i/6).radians)*80, Math.cos((360*i/6).radians)*80, 0])
16
- cylinder(h: 200, r: 10)
17
- end
18
-
19
- translate(z: 200)
20
- cylinder(h: 80, r1: 120, r2: 0)
21
- }
22
- end
1
+ require "rubyscad"
2
+
3
+ module Example005
4
+ extend RubyScad
5
+
6
+ translate(z: -120) {
7
+ difference() {
8
+ cylinder(h: 50, r: 100)
9
+ translate(z: 10); cylinder(h: 50, r: 80)
10
+ translate(v: [100, 0, 35]); cube(size: 50, center: true)
11
+ }
12
+
13
+ (0..5).each do |i|
14
+ echo(360*i/6, Math.sin((360*i/6).radians)*80, Math.cos((360*i/6).radians)*80)
15
+ translate(v:[Math.sin((360*i/6).radians)*80, Math.cos((360*i/6).radians)*80, 0])
16
+ cylinder(h: 200, r: 10)
17
+ end
18
+
19
+ translate(z: 200)
20
+ cylinder(h: 80, r1: 120, r2: 0)
21
+ }
22
+ end
@@ -1,31 +1,31 @@
1
- //created with rubyscad 1.0
2
-
3
- translate(v = [0.000, 0.000, -120]) {
4
- difference() {
5
- cylinder(h = 50, r = 100);
6
- translate(v = [0.000, 0.000, 10])
7
- cylinder(h = 50, r = 80);
8
- translate(v = [100, 0, 35])
9
- cube(size = 50, center = true);
10
- }
11
- echo(0, 0.000, 80.000);
12
- translate(v = [0.000, 80.000, 0])
13
- cylinder(h = 200, r = 10);
14
- echo(60, 69.282, 40.000);
15
- translate(v = [69.282, 40.000, 0])
16
- cylinder(h = 200, r = 10);
17
- echo(120, 69.282, -40.000);
18
- translate(v = [69.282, -40.000, 0])
19
- cylinder(h = 200, r = 10);
20
- echo(180, 0.000, -80.000);
21
- translate(v = [0.000, -80.000, 0])
22
- cylinder(h = 200, r = 10);
23
- echo(240, -69.282, -40.000);
24
- translate(v = [-69.282, -40.000, 0])
25
- cylinder(h = 200, r = 10);
26
- echo(300, -69.282, 40.000);
27
- translate(v = [-69.282, 40.000, 0])
28
- cylinder(h = 200, r = 10);
29
- translate(v = [0.000, 0.000, 200])
30
- cylinder(h = 80, r1 = 120, r2 = 0);
31
- }
1
+ //created with rubyscad 1.0
2
+
3
+ translate(v = [0.000, 0.000, -120]) {
4
+ difference() {
5
+ cylinder(h = 50, r = 100);
6
+ translate(v = [0.000, 0.000, 10])
7
+ cylinder(h = 50, r = 80);
8
+ translate(v = [100, 0, 35])
9
+ cube(size = 50, center = true);
10
+ }
11
+ echo(0, 0.000, 80.000);
12
+ translate(v = [0.000, 80.000, 0])
13
+ cylinder(h = 200, r = 10);
14
+ echo(60, 69.282, 40.000);
15
+ translate(v = [69.282, 40.000, 0])
16
+ cylinder(h = 200, r = 10);
17
+ echo(120, 69.282, -40.000);
18
+ translate(v = [69.282, -40.000, 0])
19
+ cylinder(h = 200, r = 10);
20
+ echo(180, 0.000, -80.000);
21
+ translate(v = [0.000, -80.000, 0])
22
+ cylinder(h = 200, r = 10);
23
+ echo(240, -69.282, -40.000);
24
+ translate(v = [-69.282, -40.000, 0])
25
+ cylinder(h = 200, r = 10);
26
+ echo(300, -69.282, 40.000);
27
+ translate(v = [-69.282, 40.000, 0])
28
+ cylinder(h = 200, r = 10);
29
+ translate(v = [0.000, 0.000, 200])
30
+ cylinder(h = 80, r1 = 120, r2 = 0);
31
+ }
@@ -1,46 +1,46 @@
1
- require "rubyscad"
2
-
3
- module Example006
4
- extend RubyScad
5
-
6
- def self.edgeprofile()
7
- render(convexity: 2)
8
- difference() {
9
- cube(size: [20, 20, 150], center: true)
10
- translate(v: [-10, -10, 0])
11
- cylinder(h: 80, r: 10, center: true)
12
- translate(v:[-10, -10, 40])
13
- sphere(r: 10);
14
- translate(v: [-10, -10, -40])
15
- sphere(r: 10)
16
- }
17
- end
18
-
19
- difference() {
20
- cube(size: 100, center: true)
21
- [[0, 0, 0], [1, 0, 0], [0, 1, 0]].each do |rot|
22
- rotate(a: 90, v: rot) {
23
- [[1, 1, 0], [-1, 1, 90], [-1, -1, 180], [1, -1, 270]].each do |p|
24
- translate(v: [ p[0]*50, p[1]*50, 0 ])
25
- rotate(a: p[2], v: [0, 0, 1])
26
- edgeprofile()
27
- end
28
- }
29
- end
30
- [
31
- [ 0, 0, [ [0, 0] ] ],
32
- [ 90, 0, [ [-20, -20], [20, 20] ] ],
33
- [ 180, 0, [ [-20, -25], [-20, 0], [-20, 25], [20, -25], [20, 0], [20, 25] ] ],
34
- [ 270, 0, [ [0, 0], [-25, -25], [25, -25], [-25, +25], [25, 25] ] ],
35
- [ 0, 90, [ [-25, -25], [0, 0], [25, 25] ] ],
36
- [ 0, -90, [ [-25, -25], [25, -25], [-25, 25], [25, 25] ] ]
37
- ].each do |i|
38
- rotate(a: i[0], v: [0, 0, 1])
39
- rotate(a: i[1], v: [1, 0, 0])
40
- translate(y: -50) {
41
- i[2].each { |j| translate(v: [j[0], 0, j[1]]); sphere(r: 10) }
42
- }
43
- end
44
- }
45
- end
46
-
1
+ require "rubyscad"
2
+
3
+ module Example006
4
+ extend RubyScad
5
+
6
+ def self.edgeprofile()
7
+ render(convexity: 2)
8
+ difference() {
9
+ cube(size: [20, 20, 150], center: true)
10
+ translate(v: [-10, -10, 0])
11
+ cylinder(h: 80, r: 10, center: true)
12
+ translate(v:[-10, -10, 40])
13
+ sphere(r: 10);
14
+ translate(v: [-10, -10, -40])
15
+ sphere(r: 10)
16
+ }
17
+ end
18
+
19
+ difference() {
20
+ cube(size: 100, center: true)
21
+ [[0, 0, 0], [1, 0, 0], [0, 1, 0]].each do |rot|
22
+ rotate(a: 90, v: rot) {
23
+ [[1, 1, 0], [-1, 1, 90], [-1, -1, 180], [1, -1, 270]].each do |p|
24
+ translate(v: [ p[0]*50, p[1]*50, 0 ])
25
+ rotate(a: p[2], v: [0, 0, 1])
26
+ edgeprofile()
27
+ end
28
+ }
29
+ end
30
+ [
31
+ [ 0, 0, [ [0, 0] ] ],
32
+ [ 90, 0, [ [-20, -20], [20, 20] ] ],
33
+ [ 180, 0, [ [-20, -25], [-20, 0], [-20, 25], [20, -25], [20, 0], [20, 25] ] ],
34
+ [ 270, 0, [ [0, 0], [-25, -25], [25, -25], [-25, +25], [25, 25] ] ],
35
+ [ 0, 90, [ [-25, -25], [0, 0], [25, 25] ] ],
36
+ [ 0, -90, [ [-25, -25], [25, -25], [-25, 25], [25, 25] ] ]
37
+ ].each do |i|
38
+ rotate(a: i[0], v: [0, 0, 1])
39
+ rotate(a: i[1], v: [1, 0, 0])
40
+ translate(y: -50) {
41
+ i[2].each { |j| translate(v: [j[0], 0, j[1]]); sphere(r: 10) }
42
+ }
43
+ end
44
+ }
45
+ end
46
+