jnweiger / inkscape-gears-dev

Enhanced version of the well known gears extension, allows spokes, center cross, metric module, best evolute shape ...
52 stars 15 forks source link

Inner gears #32

Open coolarm opened 7 years ago

coolarm commented 7 years ago

I want to generate inner gears. . I have adapted existing code that generates outer?? gears through intuition. I am not a mechanical engineer and cant seem to find theory for inner gears either. Can someone with understanding of the theory validate the adapted code? It seems to do what I want, though.

Thank you so much for your time!

def involute_intersect_angle(Rb, R):
   Rb, R = float(Rb), float(R)
   return (sqrt(Rb**2 - R**2) / (R)) - (acos(R / Rb))

def effect(self):

    teeth = self.options.teeth
    pitch = self.unittouu( str(self.options.pitch) + self.options.unit)
    angle = self.options.angle  # Angle of tangent to tooth at circular pitch wrt radial line.
    centerdiameter = self.unittouu( str(self.options.centerdiameter) + self.options.unit)

    # print >>sys.stderr, "Teeth: %s\n"        % teeth

    two_pi = 2.0 * pi

    # Pitch (circular pitch): Length of the arc from one tooth to the next)
    # Pitch diameter: Diameter of pitch circle.
    pitch_diameter = float( teeth ) * pitch / pi
    pitch_radius   = pitch_diameter / 2.0

    # Base Circle
    base_diameter = 2 * pitch_diameter - pitch_diameter * cos( radians( angle ) )
    base_radius   = base_diameter / 2.0

    # Diametrial pitch: Number of teeth per unit length.
    pitch_diametrial = float( teeth )/ pitch_diameter

    # Addendum: Radial distance from pitch circle to outside circle.
    addendum = 1.0 / pitch_diametrial

    # Inner Circle
    inner_radius = pitch_radius - addendum
    inner_diameter = inner_radius * 2.0

    # Tooth thickness: Tooth width along pitch circle.
    tooth  = ( pi * pitch_diameter ) / ( 2.0 * float( teeth ) )

    # Undercut?
    undercut = (2.0 / ( sin( radians( angle ) ) ** 2))
    needs_undercut = teeth < undercut

    # Clearance: Radial distance between top of tooth on one gear to bottom of gap on another.
    clearance = 0.0

    # Dedendum: Radial distance from pitch circle to root diameter.
    dedendum = addendum + clearance

    # Root diameter: Diameter of bottom of tooth spaces. 
    root_radius =  pitch_radius + dedendum
    root_diameter = root_radius * 2.0

    half_thick_angle = two_pi / (4.0 * float( teeth ) )
    pitch_to_base_angle  = involute_intersect_angle( base_radius, pitch_radius )
    pitch_to_inner_angle = involute_intersect_angle( base_radius, inner_radius ) - pitch_to_base_angle

    centers = [(x * two_pi / float( teeth) ) for x in range( teeth ) ]

    points = []

    for c in centers:

        # Angles
        pitch1 = c - half_thick_angle
        base1  = pitch1 - pitch_to_base_angle
        inner1 = pitch1 + pitch_to_inner_angle

        pitch2 = c + half_thick_angle
        base2  = pitch2 + pitch_to_base_angle
        inner2 = pitch2 - pitch_to_inner_angle

        # Points
        b1 = point_on_circle( base_radius,  base1  )
        p1 = point_on_circle( pitch_radius, pitch1 )
        i1 = point_on_circle( inner_radius, inner1 )

        b2 = point_on_circle( base_radius,  base2  )
        p2 = point_on_circle( pitch_radius, pitch2 )
        i2 = point_on_circle( inner_radius, inner2 )

        if root_radius < base_radius:
            pitch_to_root_angle = pitch_to_base_angle - involute_intersect_angle(base_radius, root_radius )
            root1 = pitch1 - pitch_to_root_angle
            root2 = pitch2 + pitch_to_root_angle
            r1 = point_on_circle(root_radius, root1)
            r2 = point_on_circle(root_radius, root2)
            p_tmp = [r1,p1,i1,i2,p2,r2]
        else:
            r1 = point_on_circle(root_radius, base1)
            r2 = point_on_circle(root_radius, base2)
            p_tmp = [r1,b1,p1,i1,i2,p2,b2,r2]

        points.extend( p_tmp )

    path = points_to_svgd( points )
Neon22 commented 7 years ago

I'm hoping to get to this soon but snowed under right now. FYI this notion of inner gears is (I think) equivalent to a Ring gear.