/* * Program to calculate the depth and double-depth of threads with * a v-form threading tool. * * 21 April 1998 */ #include main(argc, argv) int argc; char *argv[]; { double ddepth, depth, fdepth, input, pitch, tpi, atof(); int metric; metric = 0; /* * do we have all the arguments? */ if (argc < 2) { fprintf(stderr, "\nUsage:\n\t%s TPI\n\t\tor\n\t%s -m pitch\n\n", argv[0], argv[0]); exit(1); } /* * Get the arugments from the command line */ if (argv[1][0] == '-') { /* * if it starts with a dash -- it has to be an option */ if ( argv[1][1] == 'm' ){ input = atof(argv[2]); metric++; } else { fprintf( stderr, "\n%s: Unknown switch!\n", argv[0]); exit(1); } } else { input = atof(argv[1]); } if ( metric >= 1 ) { pitch = input; tpi = 1.0/input; } else { tpi = input; pitch = 1.0/input; } /* * calculate the double depth */ depth = pitch * 0.8660; ddepth = depth * 2.0; fdepth = ddepth * 0.75; /* * print out a reminder of the input data and the calculated output */ if (metric == 0) { printf("\nFor a thread of:\t\t%8.2f TPI\n", tpi); printf("\tthe pitch is:\t\t%8.4f\"/thread\n", pitch); printf("\tthe sharp V depth is:\t\t%8.4f\"\n", depth); printf("\tthe sharp V double depth is:\t%8.4f\"\n", ddepth); printf("\tthe formed double depth is:\t%8.4f\"\n\n", fdepth); } else { printf("\nFor a thread pitch of:\t\t%8.2f mm\n", pitch); printf("\tthe sharp V depth is:\t\t%8.2f mm\n", depth); printf("\tthe sharp V double depth is:\t%8.2f mm\n", ddepth); printf("\tthe formed double depth is:\t%8.4f mm\n\n", fdepth); } exit(0); }