Circle Fitting

A set of points can be fitted to the equation of a circle (circular regression) by minimizing either an algebraic or a geometric distance.

To fit a set of data points to the equation of a circle with center $(x_0,y_0)$ and radius $r$, the function to be minimized is

\begin{displaymath}
S = \sum \left( (x_i - x_0)^{2} + (y_i - y_0)^{2} - r^2 \right)^2
\end{displaymath} (4.114)

where the orthogonal distance between the points and the model is minimized. To solve the problem, it is convenient to change variables and minimize the algebraic form:
\begin{displaymath}
S = \sum \left( z_i + Bx_i + Cy_i + D \right)^2
\end{displaymath} (4.115)

where $z_i = x^2_i + y^2_i$ has been introduced for simplicity. The problem reduces to solving the symmetric linear system $3 \times 3$:
\begin{displaymath}
\begin{array}{lllll}
\sum z_i x_i & + B \sum x^{2}_i & + C ...
... + B \sum x_i & + C \sum y_i & + D \sum 1 & = 0 \\
\end{array}\end{displaymath} (4.116)

which can be solved easily. Once the parameters $B$, $C$, and $D$ have been obtained, the original circle parameters can be recovered:
\begin{displaymath}
x_0 = - \frac{B}{2} \quad y_0 = -\frac{C}{2} \quad r^2 = x^2_0 + y^2_0 - D
\end{displaymath} (4.117)

The same result can be obtained using the linear solvers discussed earlier. For example, consider an algebraic representation of a circle:

\begin{displaymath}
f(\mathbf{x}) = a \mathbf{x}^\top \mathbf{x} + \mathbf{b}^{\top} \mathbf{x} + c = 0
\end{displaymath} (4.118)

where $\mathbf {x}$ is the locus of points on the circle.

Given a set of noisy points on the circle, the parameters $(a,b_x,b_y,c)$ are estimated as the least-squares solution of the homogeneous system (4.118), subject to a suitable normalization constraint to eliminate scale ambiguity. As will be discussed in detail in later examples, normalizing the input data is computationally advantageous because the different unknowns are associated with data of very different magnitudes.

The algebraic solution is often used as an initial estimate for iterative methods that minimize a different metric. Geometric fitting requires minimizing the distances $d^2_i = \left( \Vert \mathbf{x}_i - (x_0,y_0)^\top \Vert - r \right)^2$. This requires a nonlinear least-squares solver, such as Levenberg–Marquardt, and computation of the derivatives of the cost function.

Another option is to parameterize the problem in a space other than Cartesian space. Using the parametric form of the circle equation,

\begin{displaymath}
\begin{array}{l}
x = x_0 + r \cos \varphi \\
y = y_0 + r \sin \varphi \\
\end{array}\end{displaymath} (4.119)

the quantities to be minimized become
\begin{displaymath}
\begin{array}{l}
x_i - x_0 + r \cos \varphi_i \approx 0 \\
y_i - y_0 + r \sin \varphi_i \approx 0 \\
\end{array}\end{displaymath} (4.120)

and are easy to differentiate. An additional unknown $\varphi_i$, an auxiliary variable, is associated with each input datum $(x_i,y_i)$. This results in a nonlinear system with $3+n$ unknowns and $2n$ equations.

Paolo medici
2026-10-19