Least Squares Circle

Approximation without constraints

We want to find a circle that fits the given set of points best in a sense of least squares approximation. Let a circle be represented as
x2+y2+2Ax+2By+C=0.
Then, the center of the circle is (-A,-B) and the radius is
r=   _______
ÖA2+B2- C
 
.
Assume this circle is used to approximate the given set of points pi (i=1,2,¼,n). Then, the squared error with respect to pi=(xi,yi) is (xi2+yi2+2Axi+2Byi+C)2. Accordingly, the total squared error is given by
f = å
(xi2+yi2+2Axi+2Byi+C)2.
We thus want to find A,B,C such that f is minimized, which is equivalent to solving the following system of linear equations:
f
A
,    f
B
,    f
C
.
Explicitly, we need to solve

       2åxi2 A+2åxiyi B+åxi C+å(xi2+yi2)xi=0

       2åxiyi A+2åyi2 B+åyi C+å(xi2+yi2)yi=0

       2åxi A+2åyi B+n C+å(xi2+yi2)=0

Approximation with two constraints

We want to find a circle
x2+y2+2Ax+2By+C=0
(2-1)
such that it interpolates two points (x1, y1) and (x2, y2) and approximates the remaining given points in a sense of least squares approximation. By substituting (x1, y1) and (x2, y2) into the above equation, we have

x12+y12+2x1A+2y1B+C=0

x22+y22+2x2A+2y2B+C=0
Subtracting the first from the second equation gives

2(x1-x2)A+2(y1-y2)B+x12+y12-x22-y22=0.
Assume that |x1-x2| > |y1-y2|. Then, we may express A in terms of B to reduce numerical noise, i.e.,

A= y1-y2
x2-x1
B+ x12+y12-x22-y22
2(x2-x1)
=aB +b.
Replacing A in (2-1) gives

f(B,C,x,y)=2(xa+y)B+C+x2+y2+2xb = 0.
Let f(B,C,xi,yi)=åf2(B,C,xi,yi). We then want to find B and C such that f is minimized, which is equivalent to solving the following equations:

       [(df)/(dB)]=2å[2(xia+yi)B+C+xi2+yi2+2xib]2(xia+yi)=0

       [(df)/(dC)]=2å[2(xia+yi)B+C+xi2+yi2+2xib]=0

Let

       a00=4å(xia+yi)2,

       a01=a10=2å(xia+yi),

       a11=n,

       b0=-2å(xi2+yi2+2xib)(xia+yi), and

       b1=-å(xi2+yi2+2xib).

Then, the above system of equations can be written as

a00B+a01C=b0

a10B+a11C=b1
Solving the above equations gives a circle whose center is (-A,-B) and radius Ö[(A2+B2+C)].

In the case where |x1-x2| < |y1-y2|, we may express B in terms A and obtain the circle similarly.

RETURN