How can I calculate an ellipse from a group of points ?

enter image description here

Result: center point, x-radius, y-radius ?

I'm not mathematician so I don't really know the best parameter style for ellipses. This ellipse is aligned to X and Y axes and I usually go with center point and 2 radii in x and y directions.


Finding parameters

An ellipse (and in fact any conic section) is described by an equation of the form


Any multiple of this equation describes the same ellipse. The parameters $a$ through $f$ can be found up to that multiple by knowing $5$ points on the ellipse:

$$\begin{pmatrix} x_1^2 & y_1^2 & x_1y_1 & x_1 & y_1 & 1 \\ x_2^2 & y_2^2 & x_2y_2 & x_2 & y_2 & 1 \\ x_3^2 & y_3^2 & x_3y_3 & x_3 & y_3 & 1 \\ x_4^2 & y_4^2 & x_4y_4 & x_4 & y_4 & 1 \\ x_5^2 & y_5^2 & x_5y_5 & x_5 & y_5 & 1 \\ \end{pmatrix} \cdot \begin{pmatrix} a \\ b \\ c \\ d \\ e \\ f \end{pmatrix} =\begin{pmatrix} 0 \\ 0 \\ 0 \\ 0 \\ 0 \end{pmatrix} $$

If you have more than five data points, you may choose any five of them. If your data points are not perfectly accurate, then look into Ellipse fitting methods.

Changing the representation

To turn the parameters you found into center, radii and orientation you can follow the steps which I outlined in this answer.

  • $\begingroup$ I edited the matrix which has slips in the first and second columns (supposed to be $x_1^2$, not $x_1$, etc.). Now they are fixed. $\endgroup$ Apr 24 '14 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.