Question: #include #include #define PI 3.14159265 #define EPS 1e-8 double slope(double x1,double y1,double x2,double y2); double angle(double m1, double m2); double y_intercept(double x0, double y0, double

 #include #include #define PI 3.14159265 #define EPS 1e-8 double slope(double x1,double

#include #include #define PI 3.14159265 #define EPS 1e-8 double slope(double x1,double y1,double x2,double y2); double angle(double m1, double m2); double y_intercept(double x0, double y0, double m); void print_results(double m1, double m2, double b1, double b2); int main (void) { /* Declare variables to get user input */ double x1, x2, x3, x4, y1, y2, y3, y4; // declare (x,y) of 4 points /* Declare variables to compute */ double m1, m2; // slope of l1 and l2 lines double b1,b2; // y_intercept of l1 and l2 double angle; // angle between the lines /* Get user input from the keyboard. */ printf("Enter coordinates of two points on line 1 [x1,y1,x2,y2]: "); scanf("%lf %lf %lf %lf",&x1,&y1, &x2,&y2); printf("Enter coordinates of two points on line 2:[x3,y3,x4,y4]: "); scanf("%lf %lf %lf %lf",&x3,&y3,&x4,&y4); /* Compute m1 and b1 for the line l1 */ m1 = slope(x1,y1,x2,y2); b1 = y_intercept(x1,y1,m1); /* Compute m2 and b2 for the line l2 */ m2 = slope(x3,y3,x4,y4); b2 = y_intercept(x3,y3,m2); /* Print results */ print_results(m1,m2,b1,b2); return 0; } double slope(double xa,double ya,double xb,double yb) { //Write a function to find and return the slope of a line. /* YOUR CODE GOES HERE */ return 0; // Don't forget to update the return value } double y_intercept(double x0, double y0, double m) { //Write a function to find and return the y-intercept of a line. /* YOUR CODE GOES HERE */ return 0; // Don't forget to update the return value } double angle(double m1, double m2) { //Write a function to compute and return the angle between the two lines. /* YOUR CODE GOES HERE */ return 0; // Don't forget to update the return value (return angle in degrees, *180/PI) } void print_results(double m1, double m2, double b1, double b2) { // Write a function to print the two line equations, check if the two lines are parallel or intersect /* YOUR CODE GOES HERE */ }

Exercise 1. (20 points) An incomlete C program is given to read the coordinates (x, y) of two distinct points on line 11: y=m12+by and two distinct points on line l2: y = m2x + b2. Your goal is to find the parameters of the lines, and check if the two lines intersect and provide the angle between the two lines. Your task is to complete four functions defined below and given in pe2.c' file. (a) (5 points) Write a function to find and return the slope of a line. The equation to calculate the slope from two points is given as: m = 42-41. Call this function twice to compute m and m2. (b) (5 points) Write a function to find and return the y-intercept of a line. Note that the y-intercept of a line is the value of y at the point where the line crosses the y axis, i.e., when x = 0. Call this function twice to compute b and b2. (c) [5 points) Write a function to compute and return the angle between the two lines. Note that the angle 8 between the lines having slope mu and m2 is given by 6 = mi-m2 You may use atan function given in math.h to compute arctan. (d) [5 points) Write a function to print the two line equations, check if the two lines are parallel or intersect using the angle between the two lines. Note that if e

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!