Class: SolidRuby::Primitives::Sphere

Inherits:
Primitive show all
Defined in:
lib/solidruby/primitives/sphere.rb

Instance Attribute Summary

Attributes inherited from SolidRubyObject

#attributes, #children, #siblings, #transformations

Instance Method Summary collapse

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 = {}) ⇒ Sphere

Returns a new instance of Sphere.



21
22
23
24
25
# File 'lib/solidruby/primitives/sphere.rb', line 21

def initialize(args={})
  d = args[:diameter] || args[:d]
  @r = args[:radius] || args[:r] || d/2.0
  super(args)
end

Instance Method Details

#get_point_on(args = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/solidruby/primitives/sphere.rb', line 27

def get_point_on(args = {})
  #approximate a cube the size of this sphere
  args[:x] = @r*Math.sqrt(2)
  args[:y] = @r*Math.sqrt(2)
  args[:z] = @r*Math.sqrt(2)
  args[:centered] = true
  args[:centered_z] = true
  args[:transformations] = @transformations
  calculate_point_on(args)
end

#to_rubyscadObject



38
39
40
# File 'lib/solidruby/primitives/sphere.rb', line 38

def to_rubyscad
  RubyScadBridge.new.sphere(@attributes)
end