Question: Please answer the following question using C and show the executables, thank you. (2) Intersection Test In many areas of science (e.g., computer graphics, computational
Please answer the following question using C and show the executables, thank you.

(2) Intersection Test In many areas of science (e.g., computer graphics, computational geometry, image analysis, robotics, physics), it is often necessary to determine whether or not two line segments intersect. Assume that we have two 2D line segments one line segment has endpoints (Ax,Ay) and (Bx,By) and the other segment has endpoints (Cx,Cy) and (Dx,Dy). Write a C program called intersectionTester that asks the user for the eight values of the integer coordinates for two line segments and then displays a message indicating whether or not the line segments intersect. Assume that all coordinates are entered as integer values. Here are some examples: (Ax, Ay)(Ck, Cy) (2,17) (3,17) (7, 19) (Bx, By) 15, 10) (8, 10) (15, 10) 7, 10) (15, 10) (Dx, Dy) (3, 6) (3, 6) (3, 6) (4, 18) (3, 17) (2,17) (, 17) (12, 17 (18, 17) (15, 18) (15, 14) (4, 14) (1,10 (15, 10) (2,10) (7,10) (12, 10) (18, 10) (4, 6) (15, 6) (15, 4) (3, 6) (4, 3) In your code, you should write a function called calculate() that takes all 8 integer parameters and returns 1 if the line segments intersect and 0 otherwise. To determine intersection, you will need to handle vertical and horizontal lines as special cases. Otherwise, you can use the following equations to determine whether or not the line segments intersect t - (Ax-Cx) (Cy-Dy) - (Ay-Cy) (Cx-Dx) (Ax-Bx)(Cy-Dy) (Ay-By) (Cx-Dx) u (Bx-Ax) (Ay-Cy)(Ay-By) (Ax-Cx) (Ax-Bx) (Cy-Dy) (Ay-By) (Cx-Dx) When using the above equations, if O St1 and 0S u1 then the line segments intersect. This extra check ensures that the intersection of the two lines actually lies on the segments. In your main function, you may hard code some calls to calculate() with the coordinates for the 8 examples in the image above. Make sure that they all give the correct answer. Your output must be in this format (color added for highlighting purposes only): Line segments 2,17)-(15,10) and 7, 19-3,6) intersect Line segments 2,17)-(15,10) and , 10)-3,6) do not intersect Line segments 3,17)-3, 6) and 7, 10)->(15,10) do not intersect Line segments 4,18)-4,14) and 4, 6)->4, 3) do not intersect Line segments (15,18)-> (15, 6) and (15, 14)->(15, 4) intersect Line segments 3,17)-3, 6) and 1, 10)->(15,10) intersect Line segments 2,17)-(12,17) and 7, 17)->(18,17) intersect. Line segments 2,10)-7,10) and (12, 10)-> (18,10) do not intersect
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
