Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAXCIRCLES 20
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 s;
point t;
int nobst;
circle c[MAXCIRCLES];
ReadFile( "route.dat", &x, &y, &nobst );
line l;
point close;
double d;
double xray = 0.0;
double around = 0.0;
double angle;
double travel;
int i;
double asin(),sqrt();
double distance();
points_to_line(s,t,&l);
for (i=1; i<=nobst; i++) {
closes_point(c[i].c,,l,close);
d = distance(c[i].c,close);
if ((d>=0) && (d<c[i].r) && point_in_box(close,s,t){
xray += 2*sqrt(c[i].r*c[i].r) - d*d;
angle = acos(d/c[i].r);
around += ((2*angle)/(2*PI)) * (2*PI*c[i].r);
}
}
dist = distance(s,t) - xray + around;
printf("f\n",dist);
}
Can you correct it for me? it has many errors but i'm tired trying to solve this.