How can I calculate center point from set of coordinates with accuracy?
For example from set of observations:
point xcoord ycoord accuracy tim
+1 for very interesting problem ... Here is my approach in C++
global tables and variables to store all needed:
const int N=5; // number of measurement circles
struct _circle { double x,y,r; _circle() { x=0; y=0; r=0.0; } } circle[N],circle0,circle1;
circle[]
- measured positionscircle0
- original real position (unknown for you)circle1
- computed more accurate positionhere are my random measurements (copy your measured values instead):
int i;
double r,a,x0,x1,y0,y1;
// set real position
circle0.x=50.0;
circle0.y=50.0;
circle0.r=25.0;
// set meassured positions
Randomize();
for (i=0;i<N;i++)
{
r=circle0.r*(0.2+(0.3*double(Random(101))*0.01));
a= 2.0*M_PI* double(Random(101))*0.01;
circle[i]=circle0;
circle[i].x+=r*cos(a);
circle[i].y+=r*sin(a);
}
This is how to compute Average style position:
// compute more accurate position (average style)
circle1.x=0.0;
circle1.y=0.0;
circle1.r=circle0.r;
for (i=0;i<N;i++)
{
circle1.x+=circle[i].x;
circle1.y+=circle[i].y;
}
circle1.x/=N;
circle1.y/=N;
for (i=0;i<N;i++)
{
r=circle1.x-circle[i].x; r*=r;
a=circle1.y-circle[i].y; a*=a;
r=circle[i].r-sqrt(a+r);
// if (circle1.r>r) circle1.r=r; // best accuracy
if (circle1.r<r) circle1.r=r; // worse accuracy
}
This is how to compute Geometry style position:
// compute more accurate position (geometry style)
x0=circle[i].x; x1=x0;
y0=circle[i].y; y1=y0;
for (i=0;i<N;i++)
{
a=circle[i].x; if (x0>a) x0=a; if (x1<a) x1=a;
a=circle[i].y; if (y0>a) y0=a; if (y1<a) y1=a;
}
circle1.x=0.5*(x0+x1); x1-=x0; x1*=x1;
circle1.y=0.5*(y0+y1); y1-=y0; y1*=y1;
circle1.r=1.0*sqrt(x1+y1);
And here are some previews of my code output: