#include #include #include "mygraph.h" #include "mydebug.h" #include "point.h" extern int DEBUG; #define ZERO_DELTA 0.0000001 void read_line( line * the_line){ if ( DEBUG & LINE_LEVEL ) { fprintf(stderr,"DEBUG: Entering read_line\n"); } printf ("Enter the endpoints of a line\n"); read_point(&(the_line->e1)); read_point(&(the_line->e2)); if ( DEBUG & LINE_LEVEL ) { fprintf(stderr,"DEBUG: Exiting read_line, (%f, %f) to ( %f, %f)\n", the_line->e1.x,the_line->e1.y,the_line->e2.x,the_line->e2.y); } } void print_line ( line a_line) { if ( DEBUG & LINE_LEVEL ) { fprintf(stderr,"DEBUG: Entering print_line\n"); } printf ("The line is : "); print_point (a_line.e1); print_point (a_line.e2); printf ("\n"); if ( DEBUG & LINE_LEVEL ) { fprintf(stderr,"DEBUG: Exiting print_line\n"); } } int calculate_slope (line aline, float * slope){ float deltax, deltay; if ( DEBUG_LINE ) { fprintf(stderr,"DEBUG: Entering calculate_slope\n"); fprintf(stderr,"DEBUG: The line is, (%f, %f) to ( %f, %f)\n", aline.e1.x,aline.e1.y,aline.e2.x,aline.e2.y); } deltax = aline.e1.x - aline.e2.x; deltay = aline.e1.y - aline.e2.y; if ( DEBUG_LINE && DEBUG_MED ) { fprintf(stderr,"Delta x = %f, Delta y = %f\n",deltax, deltay); } if (fabs(deltax) < ZERO_DELTA) { if ( DEBUG_LINE && DEBUG_MED ) { fprintf(stderr, "DEBUG: This represents a 0 delta x, slope infinity\n"); } return (-1); } *slope = deltay/deltax; if ( DEBUG_LINE ) { fprintf(stderr,"DEBUG: Exiting calculate_slope\n"); } return(0); }