class SolidRuby::Assemblies::Gear

Attributes

height[R]

this library is to be used to easily work with gears and their distances to each other

hub_dia[R]

this library is to be used to easily work with gears and their distances to each other

hub_height[R]

this library is to be used to easily work with gears and their distances to each other

module[R]

this library is to be used to easily work with gears and their distances to each other

teeth[R]

this library is to be used to easily work with gears and their distances to each other

Public Class Methods

new(args = {}) click to toggle source
Calls superclass method SolidRuby::Assemblies::Assembly::new
# File lib/solidruby/assemblies/gear.rb, line 22
def initialize(args = {})
  @module = args[:module] || 1.0
  @teeth = args[:teeth] || 1.0
  @bore = args[:bore] || 0.0
  @height = args[:height] || 3.0
  @hub_dia = args[:hub_dia] || 0.0
  @hub_height = args[:hub_height] || 0.0
  @output_margin_dia = args[:output_margin_dia] || 2
  @output_margin_height = args[:output_margin_height] || 1
  super(args)
end

Public Instance Methods

distance_to(other_gear) click to toggle source
# File lib/solidruby/assemblies/gear.rb, line 56
def distance_to(other_gear)
  if @module != other_gear.module
    raise 'You cannot use two gears with different gear modules.'
    return
  end
  (@module.to_f * (@teeth.to_f + other_gear.teeth.to_f)) / 2.0
end
output() click to toggle source
# File lib/solidruby/assemblies/gear.rb, line 47
def output
  res = cylinder(d: @module * @teeth + @output_margin_dia, h: @height + @output_margin_height)
  if @hub_height.to_f > 0 && @hub_dia.to_f > 0
    res += cylinder(d: @hub_dia + @output_margin_dia, h: @hub_height + @output_margin_height).translate(z: @height)
  end

  res
end
ratio(other_gear) click to toggle source
# File lib/solidruby/assemblies/gear.rb, line 64
def ratio(other_gear)
  @teeth.to_f / other_gear.teeth.to_f
end
show() click to toggle source
# File lib/solidruby/assemblies/gear.rb, line 34
def show
  res = cylinder(d: @module * @teeth, h: @height)

  if @hub_height.to_f > 0 && @hub_dia.to_f > 0
    res += cylinder(d: @hub_dia, h: @hub_height).translate(z: @height)
  end

  if @bore.to_f > 0.0
    res -= cylinder(d: @bore, h: @height + @hub_height + 0.2).translate(z: -0.1)
  end
  res.color('darkgray')
end