#! /usr/bin/python3 # Last edited on 2024-07-27 00:47:07 by stolfi from math import sin, cos, tan, atan2, asin, acos, hypot, sqrt, pi, inf, floor, sqrt import rn import sys def points(dBase, dMin, dMax, np): # Generates a list of {np+1} points {v[i] = (x_i,y_i)} # on an involute of a circle with diameter {dBase} # centered at abscissa {-dBase/2}. # The points span the range of diameters {[dMin _ dMax]}. assert dMin >= dBase, "invalid dMin" assert dMax >= dBase, "invalid dMax" rBase = dBase/2 v = [] for k in range(np+1): f = k/np d = (1-f)*dMin + f*dMax alpha_d = alpha_at_given_d(d, dBase) omega_d = omega_from_alpha(alpha_d) x_d = 0.5*d*cos(omega_d) - rBase y_d = 0.5*d*sin(omega_d) v.append((x_d, y_d)) return v def dPitch_from_pCirc(N, pCirc): # Computes the pitch diameter {dPitch} from the circular pitch {pCirc} # and the number of teeth {N}. dPitch = N*pCirc/pi return dPitch def dBase_from_dPitch(dPitch, theta): # Computes the base circle diameter {dBase} (mm) from the desired # pitch diameter {dPitch} (mm) and the desired pressure angle {theta} # at the latter (radians): dBase = dPitch*cos(theta) return dBase def omega_from_alpha(alpha): # Computes the polar angle {omega} ("inv alpha", radians) # from the curve parameter {alpha}, the angle between local # tangent and local radius (radians): omega = tan(alpha) - alpha return omega def alpha_at_given_d(d, dBase): # Computes the the curve parameter {alpha}, # the angle between local tangent and local radius (radians), # at a specific diameter {d} (mm), given the # base diameter {dBase} (mm): alpha = acos(dBase/d) return alpha def thickness_at_given_d(d, dPitch, theta, N): # Computes the the tooth thickness {th} (mm) # at a specific diameter {d}, given the pitch diameter {dPitch} # the pressure angle {theta} (radians), and the number of teeth {N}: dBase = dBase_from_dPitch(dPitch, theta) alpha = alpha_at_given_d(d, dBase) omega_0 = omega_from_alpha(theta*pi/180) omega = omega_from_alpha(alpha) th = d*((pi/(2*N)) + omega_0 - omega) return th