print ("This program will calculate the Pitch Diameter of gears in metric units.")
import math
### Formula for calculating the Pitch Diameter of gears:
# PitchDiameter = (NumberOfTeeth * NormalDiametralPitch)/(math.cos(HelixAngle) )
###########################################
# Enter the NumberOfTeeth, NormalDiametralPitch, HelixAngle
# Convert HelixAngle from degrees to radians
def SolveForPitchDiameter():
print ("Solving for the Pitch Diameter of gears in metric units.")
# Enter the NumberOfTeeth
NumberOfTeeth = float(input("Enter the number of teeth: ") )
# Enter the NormalDiametralPitch (number of teeth per cm)
NormalDiametralPitch = float(input("Enter the Normal Diametral Pitch (number of teeth per cm): ") )
# Enter the HelixAngle
HelixAngle = float(input("Enter the Helix Angle: ") )
# Calculate the top of the fraction
TopOfFraction = (NumberOfTeeth * NormalDiametralPitch)
print("The fraction is: ", TopOfFraction)
# Convert degrees to radians
HelixAngleInRadians = (math.radians(HelixAngle) )
print("The helix angle in radians is: ", HelixAngleInRadians)
# Calculate the cosine
CosineOfHelixAngle = math.cos(HelixAngleInRadians)
print("The cosine of the helix angle is: ", CosineOfHelixAngle)
# Calculate the pitch diameter
PitchDiameter = (TopOfFraction/CosineOfHelixAngle)
print ("The pitch diameter is: ", PitchDiameter, " cm.")
ContinueCalculations = "y"
# Check to see if the user wants to continue to calculate the pitch diameter
while (ContinueCalculations=="y"):
SolveForPitchDiameter()
ContinueCalculations = input("Would like to do another calculation for the pitch diameter of gears? (y/n): ")
print("==================================")
print ("Thank you to www.fxsolver.com for assistance with this formula.")