Claus Cyrny wrote:
Hi,
I would like to know if there is a tutorial on how to create gears in Inkscape (I am still using 0.42, but would like to update as soon as I have the new Ubuntu release installed). At the Inkscape web site I only found several links to Youtube videos, but none of those was what I was looking for.
TIA,
Claus
Real involute gears? or just artisticly pleasing gears?
You can make simple gearish shapes by combining a star and two circles with boolean operations. See attached svg.
I wrote a python script to generate gears that are somewhat more mathematically correct, but it still lacks the proper involute curve for the tooth profiles. See the attached python script.
And lastly if the tooth profiles are important to you, please check out lib2geom. lib2geom is a 2d geometry toolkit being developed for use in inkscape. I've written a little toy program for generating gears with proper involute tooth profiles. These gears still lack the proper undercutting or addendum modifications for gears with small numbers of teeth. See http://lib2geom.sourceforge.net/ and http://lib2geom.svn.sourceforge.net/viewvc/lib2geom/lib2geom/trunk/src/toys/...
Aaron Spike
import sys from math import *
PHI = radians(20)#float(input("pressure angle")) PC = 10#float(input("Circular Pitch (module)"))
def involute_intersect_angle(Rb, R): Rb, R = float(Rb), float(R) return (sqrt(R**2 - Rb**2) / (Rb)) - (acos(Rb / R))
def point_on_circle(radius, angle): x = radius * cos(angle) y = radius * sin(angle) return (x, y)
def points_to_svgd(p): f = p[0] p = p[1:] svgd = 'M%s,%s' % f for x in p: svgd += 'L%s,%s' % x svgd += 'z' return svgd
def gear(N,phi=PHI,Pc=PC): #Pitch Circle D = N * Pc / pi R = D / 2.0
#Diametrial pitch Pd = N / D
#Base Circle Db = D * cos(phi) Rb = Db / 2.0
#Addendum a = 1.0 / Pd
#Outside Circle Ro = R + a Do = 2 * Ro
#Tooth thickness T = (pi * D) / (2 * N)
#undercut? U = (2 / (sin(phi) ** 2)) needs_undercut = N < U sys.stderr.write("N:%s R:%s Rb:%s\n" % (N,R,Rb))
#Clearance c = 0.0 #Dedendum b = a + c
#Root Circle Rr = R - b Dr = 2 * Rr
two_pi = 2 * pi half_thick_angle = two_pi / (4 * N) pitch_to_base_angle = involute_intersect_angle(Rb, R) pitch_to_outer_angle = involute_intersect_angle(Rb, Ro) - pitch_to_base_angle
#print degrees(half_thick_angle),degrees(pitch_to_base_angle),degrees(pitch_to_outer_angle) centers = [(x * two_pi / N) for x in range(N)]
points = []
for c in centers: #angles pitch1 = c - half_thick_angle base1 = pitch1 - pitch_to_base_angle outer1 = pitch1 + pitch_to_outer_angle
pitch2 = c + half_thick_angle base2 = pitch2 + pitch_to_base_angle outer2 = pitch2 - pitch_to_outer_angle
#points b1 = point_on_circle(Rb, base1) p1 = point_on_circle(R, pitch1) o1 = point_on_circle(Ro, outer1) o2 = point_on_circle(Ro, outer2) p2 = point_on_circle(R, pitch2) b2 = point_on_circle(Rb, base2)
if Rr >= Rb: pitch_to_root_angle = pitch_to_base_angle - involute_intersect_angle(Rb, Rr) root1 = pitch1 - pitch_to_root_angle root2 = pitch2 + pitch_to_root_angle r1 = point_on_circle(Rr, root1) r2 = point_on_circle(Rr, root2) p_tmp = [r1,p1,o1,o2,p2,r2] else: r1 = point_on_circle(Rr, base1) r2 = point_on_circle(Rr, base2) p_tmp = [r1,b1,p1,o1,o2,p2,b2,r2]
points.extend(p_tmp)
svgd = points_to_svgd(points)
svg = """ <g> <circle style="fill:none;stroke:green;" r="%s" /> <circle style="fill:none;stroke:green;" r="%s" /> <circle style="fill:none;stroke:red;" r="%s" /> <circle style="fill:none;stroke:blue;" r="%s" /> <path style="fill:gray;fill-opacity:0.5;stroke:black;" d="%s"/> </g> """ % (Ro, Rr, R, Rb, svgd)
return svg
print "<svg>\n" for teeth in [15,25,50]: print gear(teeth) print "</svg>\n"