Module: CrystalScad::Extras
- Included in:
- CrystalScad
- Defined in:
- lib/crystalscad/Extras.rb
Defined Under Namespace
Classes: Triangle
Instance Method Summary collapse
Instance Method Details
#knurl(y) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/crystalscad/Extras.rb', line 62 def knurl(y) x = 1.5 height = 1.5 res = cube(([x,y,height])) res -= cylinder(d:0.9,h:height*1.42,fn:16).rotate(y:45).translate(x:0) res -= cylinder(d:0.9,h:height*1.42,fn:16).rotate(y:-45).translate(x:1.5) res end |
#knurled_cube(size) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/crystalscad/Extras.rb', line 72 def knurled_cube(size) x = size[0] y = size[1] z = size[2] res = nil (x / 1.5).ceil.times do |i| (z / 1.5).ceil.times do |f| res += knurl(y).translate(x:i*1.5,z:f*1.5) end end res *= cube([x,y,z]) res end |
#knurled_cylinder(args = {}) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/crystalscad/Extras.rb', line 91 def knurled_cylinder(args={}) res = cylinder(args) height = args[:h] r = args[:d] / 2.0 24.times do |i| (height/2).ceil.times do |f| res -= cylinder(d:0.9,h:height*2).rotate(y:45).translate(y:-r,z:f*2) res -= cylinder(d:0.9,h:height*2).rotate(y:-45).translate(y:-r,z:f*2) end res.rotate(z:15) end res end |