bestfitcircle.c:46: error: called object is not a function
bestfitcircle.c:46: error: called object is not a function
That is the error message that I get for the following C program.
Code:
#include <stdio.h>
#include <math.h>
main() {
int count, points, x_sum = 0, y_sum = 0;
float x_avg, y_avg, sigma[7], k_prime, h_prime, h, k, r = 0;
for(count = 0; count < 7; count++){
sigma[count] = 0;
}
printf("How many points?\n");
scanf("%d", &points);
float x[points], y[points], x_prime[points], y_prime[points];
for(count = 0; count < points; count++){
printf("Insert x of point #%d:\n", count+1);
scanf("%f", &x[count]);
printf("Insert y of point #%d:\n", count+1);
scanf("%f", &y[count]);
}
for(count = 0; count < points; count++){
x_sum = x_sum + x[count];
y_sum = y_sum + y[count];
}
x_avg = x_sum / points;
y_avg = y_sum / points;
for(count = 0; count < points; count++){
x_prime[count] = x[count] - x_avg;
y_prime[count] = y[count] - y_avg;
}
for(count = 0; count < points; count++){
sigma[0] = sigma[0] + pow(x_prime[count],2);
sigma[1] = sigma[1] + (x_prime[count] * y_prime[count]);
sigma[2] = sigma[2] + pow(x_prime[count],3);
sigma[3] = sigma[3] + (x_prime[count] * pow(y_prime[count],2));
sigma[4] = sigma[4] + pow(y_prime[count],2);
sigma[5] = sigma[5] + (y_prime[count] * pow(x_prime[count],2));
sigma[6] = sigma[6] + pow(y_prime[count],3);
}
k_prime = ((sigma[0] * (sigma[5] + sigma[6])) + (sigma[1] * (sigma[2] + sigma[3]))) / (2 * ((sigma[4] * sigma[0]) - (sigma[1] * sigma[1])));
h_prime = (((1 / 2)(sigma[2] + sigma[3])) - (k_prime * sigma[1])) / sigma[0];
k = k_prime + y_avg;
h = h_prime + x_avg;
for(count = 0; count < points; count++){
r = r + sqrt(pow(x_prime[count]-h,2) + pow(y_prime[count]-k,2));
}
r = r / points;
printf("Best-fit circle center is: %f, %f\nBest-fit circle radius is: %f\n", h, k, r);
}
I have not a clue what the problem is.