What am I doing wrong here?
1) Find point of lowest 'y' coord
2) sort the other points according to polar coordinates (angle), relative to the first point
3) Apply the following algo:
Code: Select all
a = cx = cy = 0;
for(i=1; i < n-1; ++i) {
aa = cross(p[i].x-p[0].x,p[i].y-p[0].y, p[i+1].x-p[0].x,p[i+1].y-p[0].y);
xa = (p[0].x + p[i].x + p[i+1].x)/3;
ya = (p[0].y + p[i].y + p[i+1].y)/3;
cx = (aa*xa + a*cx)/(aa + a);
cy = (aa*ya + a*cy)/(aa + a);
a += aa;
}
printf("%.3lf %.3lfn", cx, cy);
thanks,
bolster
<font size=-1>[ This Message was edited by: bolster on 2001-11-22 06:48 ]</font>