I'm having a problem with a program in C and i would appreciate if anyone could helped me.

In this program we have to help a driver reach his destination, from (xs,ys) to (xt,yt). The problem is that his movement across the line L which connects the 2 points is blocked by circles blocks. So when the driver reaches each of this blocks he has to drive to the side of the smallest arc from the two arcs which the line L separates the circle bock, and then continue his movement on line L.

The programm should works as follows :

1) we should read the data from the program route.dat, the first line has the coordinates of the driver, the second line has the coordinates of the destination, the third line has the number of the blocks,nobst (an integer). The next nobst lines have the coordinates of the center of each circle block and its radius. The blocks are maximum 20.

We also suppose that :

i) xs<xt, so the line which connects the start point and the last point is not vertical and the the start point is always at the left of the finish one

ii) the circle blocks are not intersected

iii) the x-coordinate cx of the center of each circle satisfies xs<cx<xt

iv) the line L which connects the start point and the finish point does not necessarily intersects all the circle blocks

2) the output of the program should consists of only one line with the command

printf(”%f\n”, dist); where dist is the distance from the start point and the finish point

3) the math part of this program is about the arc length and the chord length. If d is the distance from the center of a circle block to the line which connects the start point and the finish point then cosu=d/r, so u=cos^-1(d/r). The arc length is given from s=r.u.

Finally a line intersects a circle if the distance of the center of the circle to the line is smaller than the radius of the circle

4) we can use this data for the route.dat:

0.0 10.0

15.0 0.0

4

2.0 7.5 1.75

3.0 3.0 1.0

7.0 5.0 2.0

12.0 1.7 1.5

So far i have done this:

Code:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.t>
struct point {
double x;
double y;
};
struct line {
double a; /* Slope */
double b; /* y-intercept */
};
struct circle {
double cx, cy; /* Center coordinates */
double r; /* Circle radius */
};
void ReadFile( const char *filename, point *x, point *y, int *nobst )
{
FILE *file;
int i;
if (( file = fopen( filename, "r" )) == NULL )
{
printf ( "Error opening file!\n" );
exit(1);
}
fscanf( file, "%lf %lf", &point->x, &point->y );
fscanf( file, "%lf %lf", &point->x, &point->y );
fscanf( file, "%d", nobst );
for( i = 0; i <*nobst )
{
fscanf( file, "%lf %lf %1f", &circle.cx,&circle.cy,&circle.r)
}
fclose( file );
}
/* Distance between two points */
double PointToPoint(sturct point *p, struct point *q);
/* Distance between a point and a line */
double PointToLine(struct point *p, struct line *l);
int main()
{
Point x;
Point y;
int nobst;
ReadFile( "route.dat", &x, &y, &nobst );
}

Thank you very much