The program still returns NAN... tracked it down to the function. One small error.. the includes must be in front of the function too, it's not much different than writing them in separate files.
/* BEGIN THE CALCARC FUNCTION */
#include
#include
double calcarc(double update,double rad,double chord,int a)
{
/* variable declarations */
double theta;
double rsquare;
double arc;
printf( "In startof calcarc, current total is %lf\n", update);
rsquare = pow(rad, 2);
printf( "rsquare %lf, chordsquare, %lf\n", rsquare, pow(chord,2));
printf( "argument to acos is %lf\n", ( ( (2 * rsquare) - pow(chord, 2) ) / (2 * rsquare) ));
printf( "acos is %lf\n", acos( ( (2 * rsquare) - pow(chord, 2) ) / (2 * rsquare) ));
theta = acos( ( (2 * rsquare) - pow(chord, 2) ) / (2 * rsquare) );
printf( "theta %lf\n", theta);
if (theta == 0)
{
printf("In calcarc, circle # %d does not intersect the line (tangent)\n", a+1);
return update;
}
else
{
printf("In calcarc, circle # %d intersects the line, calculating arc distance\n", a+1);
arc = theta * rad;
update = update - chord + arc;
printf( "In endof calcarc, current total is %lf\n", update);
return update;
}
}
The problem is that acos is not defined for some reason.. it's returning NAN instead of 2pi. I can't figure out why right now.. gotta go to bed.