Class: SolidRuby::Primitives::Cylinder
- Inherits:
-
Primitive
- Object
- SolidRubyObject
- Primitive
- SolidRuby::Primitives::Cylinder
- Defined in:
- lib/solidruby/primitives/cylinder.rb
Instance Attribute Summary
Attributes inherited from SolidRubyObject
#attributes, #children, #siblings, #transformations
Instance Method Summary collapse
- #get_point_on(args = {}) ⇒ Object
-
#initialize(args = {}) ⇒ Cylinder
constructor
A new instance of Cylinder.
- #to_rubyscad ⇒ Object
Methods inherited from SolidRubyObject
#&, alias_attr, #debug, #debug?, #mirror, #place, #rotate, #rotate_around, #save, #scale, #translate, #union, #walk_tree, #walk_tree_classes
Constructor Details
#initialize(args = {}) ⇒ Cylinder
Returns a new instance of Cylinder.
21 22 23 24 25 26 27 |
# File 'lib/solidruby/primitives/cylinder.rb', line 21 def initialize(args={}) d = args[:diameter] || args[:d] d /= 2.0 unless d.nil? @r = args[:radius] || args[:r] || d @h = args[:height] || args[:h] super(args) end |
Instance Method Details
#get_point_on(args = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/solidruby/primitives/cylinder.rb', line 33 def get_point_on(args = {}) # a cube the same size as the cylinder args[:x] = @r*Math.sqrt(2) args[:y] = @r*Math.sqrt(2) args[:z] = @h args[:centered] = true args[:centered_z] = false args[:transformations] = @transformations calculate_point_on(args) end |
#to_rubyscad ⇒ Object
29 30 31 |
# File 'lib/solidruby/primitives/cylinder.rb', line 29 def to_rubyscad RubyScadBridge.new.cylinder(@attributes) end |