How to find an ellipse, given five points?

Is there a way to find the parameters $$A, B, \alpha, x_0, y_0$$ for the ellipse formula $$\frac{(x \cos\alpha+y\sin\alpha-x_0\cos\alpha-y_0\sin\alpha)^2}{A^2}+\frac{(-x \sin\alpha+y\cos\alpha+x_0\sin\alpha-y_0\cos\alpha)^2}{B^2}=1$$ given five points of the ellipse?

Here is one way to determine the equation of an ellipse given 5 points. (From there, you can work out the parameters that you want.)

Every ellipse has the form $ax^2+bxy+cy^2+dx+ey+f=0$. We'll find $a,b,c,d,e,f$ given 5 points.

Let $(p_1,q_1),\dots,(p_5,q_5)$ be your 5 points. Consider the following linear equations in the variables $a,b,c,d,e,f$: $ax^2+bxy+cy^2+dx+ey+f=0$, $ap_1^2+bp_1q_1+cq_1^2+dp_1+eq_1+f = 0$,...,$ap_5^2+bp_5q_5+cq_5^2+dp_5+eq_5+f = 0$. Note that we're treating $x^2, xy,y^2,x,y,1$ as coefficients in the first equation. Similarly, $p_i^2,p_iq_i, q_i^2, p_i,q_i,1$ are coefficients in the remaining 5 equations.

Since all 5 points lie on the same ellipse, the above linear equations must have common solution. From this, we see that the equation of the ellipse is given by setting the determinant of the matrix of coefficients of the above 6 equations to $0$.

• I don't get it. I have five linear equations using the five points. What do I have to do with the sixth equation? And what should I do with the determinant containing the values x and y? – tangens Jul 1 '12 at 14:37
• The 6th equation is also linear when you treat the monomials in $x$ and $y$ as the coefficients. Take the determinant of the matrix (see GEdgar's answer below) and set it equal to zero. This should give you an equation in $x$ and $y$. This is the equation of your ellipse. You can then rearrange it to put it in any form that you like. – jrajchgot Jul 1 '12 at 18:11

What jrajchgot said, but written as a determinant... The conic section passing through the five points $(p_1,q_1),\dots,(p_5,q_5)$ has equation $ax^2+bxy+cy^2+dx+ey+f=0$ which may be written as the determinant equation $$\left|\begin{array} &x^2 & xy & y^2 & x & y & 1 \\ p_1^2 & p_1q_1 & q_1^2 & p_1 & q_1 & 1 \\ p_2^2 & p_2q_2 & q_2^2 & p_2 & q_2 & 1 \\ p_3^2 & p_3q_3 & q_3^2 & p_3 & q_3 & 1 \\ p_4^2 & p_4q_4 & q_4^2 & p_4 & q_4 & 1 \\ p_5^2 & p_5q_5 & q_5^2 & p_5 & q_5 & 1 \end{array}\right| = 0$$

What about using the DLT : http://en.wikipedia.org/wiki/Direct_linear_transformation ?

The solution is the null-space of the matrix

$$\left(\begin{array} & p_1^2 & p_1q_1 & q_1^2 & p_1 & q_1 & 1 \\ p_2^2 & p_2q_2 & q_2^2 & p_2 & q_2 & 1 \\ p_3^2 & p_3q_3 & q_3^2 & p_3 & q_3 & 1 \\ p_4^2 & p_4q_4 & q_4^2 & p_4 & q_4 & 1 \\ p_5^2 & p_5q_5 & q_5^2 & p_5 & q_5 & 1 \end{array}\right)$$

which can be found using SVD decomposition.

• This is the only answer that actually gives concrete and practical instructions. Thank you! – Torsten Bronger Jun 17 '15 at 14:20

Expanding on previous answers (I wonder why people just can't be clear?) Assume M is the 6 X 6 matrix described (I think technically, it's not a matrix since the top row is composed of variables x²,xy, etc.) with all rows below that consisting of the terms as described (eg. M2,1 = (p1)². Then consider the minors of M which I'll designate by mi where i = 1,..6. [Note that a minor is constructed by eliminating the entire row and column that the specified element is in. In this case, the specified element is always in the first row and i indicates the column. (eg. m1 is the minor for M1,1 (and M1,1 is x², m2 = minor(M1,2); M1,2 = xy, noting that x², xy, etc. are variables, not values (i.e. treated as names not values).] Why work with minors? because the determinant of M is the sum of the determinants of its minors (actually the sum of the products of the minors and their cofactors). Why is this useful? because this means that det(M) = +x² * det(m1) - xy * det(m2) + y² * det(m3) -x * det(m4) + y * det(m5) - det(m6). This is the equation of the determinant of M in terms of the determinants of its minors. Setting this expression equal to 0 gives an equation of 6 variables (x², xy, y², x, y, 1) with 6 parameters (det(m1), -det(m2),... etc.) In other words: for the general equation of the ellipse ax²+bxy+cy²+dx+ey+f=0 the parameters a...f are the determinants of the respective minors (times their cofactor). a = +det(m1), etc. and these minors are each 5x5 matrices with coefficients given by the various products of pi and qi. The determinant of a 5x5 matrix is trivially (if not quickly) computed. For clarity, the cofactor is +1 or -1 and determines whether the parameter is the det(mi) or -det(mi), for minor mi the cofactor is computed from the sum of the row and column number of its associated element in M. Since all mi's are the minors of the element M1,i the definition of the general cofactor (-1)(r+c) reduces to (-1)(1+i), which is +1,-1,+1,-1,+1,-1; which explains how the signs of the terms are obtained. This is what jrojchgot meant by saying setting the determinant M to zero solved the problem: the determinants of the minors times their respective cofactors gives us the 6 parameters a,b,c,d,e,& f. And the minors are simply 5x5 matrices of values (given 5 points (qi,pi) are known). HTH

• Could you please use TeX for arranging formulas? – Ramil May 7 '17 at 19:56