Class: GearProfile
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Shape
#*, #+, #-, #align, #back, #bbox, #bottom, #center, #cx, #cy, #cz, #extrude, #front, #left, #maxx, #maxy, #maxz, #minx, #miny, #minz, #mirror, #mirror_x, #mirror_y, #mirror_z, #move, #move_x, #move_y, #move_z, #revolve, #right, #rot_x, #rot_y, #rot_z, #rotate, #scale, #scale_x, #scale_y, #scale_z, #top, #transform, #xcenter, #xsize, #ycenter, #ysize, #zcenter, #zsize, #~@
Constructor Details
#initialize(pitch_dia, module_ = 4, p_angle = 20) ⇒ GearProfile
pitch_dia - effective diameter of gear
(not the same as outer diameter)
module_ - ratio of pitch diameter to number of teeth (basically the
arc length of the tooth spacing)
p_angle - pressure angle.
it seems 20 deg angle is better for torque, but
14.5 deg angle is better for backlash.
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/rcad/gears.rb', line 22
def initialize(pitch_dia, module_=4, p_angle=20)
@pitch_dia = pitch_dia.to_f
@module_ = module_.to_f
@p_angle = p_angle.to_f
if @pitch_dia % @module_ != 0
raise ArgumentError, "non-integer number of teeth!"
end
end
|
Instance Attribute Details
#module_ ⇒ Object
Returns the value of attribute module_.
13
14
15
|
# File 'lib/rcad/gears.rb', line 13
def module_
@module_
end
|
#p_angle ⇒ Object
Returns the value of attribute p_angle.
13
14
15
|
# File 'lib/rcad/gears.rb', line 13
def p_angle
@p_angle
end
|
#pitch_dia ⇒ Object
Returns the value of attribute pitch_dia.
13
14
15
|
# File 'lib/rcad/gears.rb', line 13
def pitch_dia
@pitch_dia
end
|
Instance Method Details
#addendum ⇒ Object
46
47
48
|
# File 'lib/rcad/gears.rb', line 46
def addendum
1.0 / diametrical_pitch
end
|
#circular_pitch ⇒ Object
42
43
44
|
# File 'lib/rcad/gears.rb', line 42
def circular_pitch
Math::PI / diametrical_pitch
end
|
#dedendum ⇒ Object
58
59
60
|
# File 'lib/rcad/gears.rb', line 58
def dedendum
whole_depth - addendum
end
|
#diametrical_pitch ⇒ Object
38
39
40
|
# File 'lib/rcad/gears.rb', line 38
def diametrical_pitch
1.0 / module_
end
|
#num_teeth ⇒ Object
34
35
36
|
# File 'lib/rcad/gears.rb', line 34
def num_teeth
(pitch_dia / module_).to_int
end
|
#outer_dia ⇒ Object
50
51
52
|
# File 'lib/rcad/gears.rb', line 50
def outer_dia
pitch_dia + 2.0 * addendum
end
|
#render ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/rcad/gears.rb', line 71
def render
tooth_tip_thickness = tooth_thickness - addendum * Math::sin(p_angle)
half_t_root_angle = Math::atan(tooth_thickness / 2 / (root_dia / 2))
half_t_angle = Math::atan(tooth_thickness / 2 / (pitch_dia / 2))
half_t_tip_angle = Math::atan(tooth_tip_thickness / 2 / (outer_dia / 2))
root_r = root_dia / 2
pitch_r = pitch_dia / 2
outer_r = outer_dia / 2
points = []
(1..num_teeth).each do |i|
angle = (2 * Math::PI / num_teeth) * i
points << to_polar(root_r, angle - half_t_root_angle)
points << to_polar(pitch_r, angle - half_t_angle)
points << to_polar(outer_r, angle - half_t_tip_angle)
points << to_polar(outer_r, angle + half_t_tip_angle)
points << to_polar(pitch_r, angle + half_t_angle)
points << to_polar(root_r, angle + half_t_root_angle)
end
polygon(points)
end
|
#root_dia ⇒ Object
62
63
64
|
# File 'lib/rcad/gears.rb', line 62
def root_dia
pitch_dia - 2 * dedendum
end
|
#tooth_thickness ⇒ Object
tooth thickness at pitch dia
67
68
69
|
# File 'lib/rcad/gears.rb', line 67
def tooth_thickness
Math::PI / 2.0 / diametrical_pitch
end
|
#whole_depth ⇒ Object
54
55
56
|
# File 'lib/rcad/gears.rb', line 54
def whole_depth
module_ < 1.25 ? (2.4 * module_) : (2.25 * module_)
end
|