# Plotting an Ellipse after an Ellipse Fit

I wonder if someone can assist my understanding as I'm a bit stumped with this...

I have taken the following (x,y) data which lies roughly on an ellipse:

$$\begin{pmatrix} 0.000234491 & 6855810 \\ 0.341848914 & 6856102 \\ 0.640414035 & 6874479 \\ 0.863239913 & 6908917 \\ 0.985101853 & 6955917 \\ 0.984332848 & 7006108 \\ 0.867029832 & 7056389 \\ 0.639589281 & 7100398 \\ 0.333714725 & 7134165 \\ 0.002441713 & 7147290 \\ -0.342779385 & 7146184 \\ -0.655455534 & 7137322 \\ -0.641777617 & 7136216 \\ -0.860267224 & 7116067 \\ -0.983690351 & 7072538 \\ -0.983008472 & 7021338 \\ -0.869967818 & 6973290 \\ -0.630288354 & 6923542 \\ -0.348927005 & 6889049 \\ \end{pmatrix}$$

If you were to plot this in Mathcad you will get the following:

Now, it is my intention to perform a best fit on these points to give me an equation of an ellipse. What I have done is to implement the algorithm based upon this paper - http://autotrace.sourceforge.net/WSCG98.pdf

The fit is against the following equation:

$ax^2 + bxy + cy^2 +dx + ey + f = 0$

Now, the fitting algorithm gives me the following co-effiecients:

\begin{align} & a=0.99999999999513789 \\ & b=0.0000031183817557930131 \\ & c=0.000000000045507950324787355 \\ & d=-21.87186231583247 \\ & e=-0.00063773270848852459 \\ & f=2233.2983593954009 \\ \end{align}

With a center of $(0.0116,7006431)$ which looks ok to me.

Now, here is the bit I'm stumped...

I just expected to be able to plot an ellipse centered on $(0.0116,7006431)$ that best fits the data points above. I assumed I could feed my original (x,y) data into :

$F(x,y) = ax^2 + bxy + cy^2 +dx + ey + f$

And this would give me data points lying on an ellipse which I could superimpose onto the original data.

What I get is as follows:

I guess my question is - what am I misunderstanding here? How do I use the output from the fit (a, b, ... f) to plot an ellipse which is centered on $(0.0116,7006431)$ and can be superimposed onto the original data?

Many thanks in advanced for any pointers/assistance.

You don't have a function $F(x,y)$, that would imply that you have some 3d object. you have an expression $ax^2+bxy+cy^2+dx+ey+f=0$.

You need to plug in $a,b,c,d,e$ and $f$ for $ax^2+bxy+cy^2+dx+ey+f$, and then, for each coordinate pair you want plug in either x or y, and then solve for the variable you didn't plug in.

What you did was make a form of error plot.

• Ahh ok... I was being daft!
– Mike
May 14, 2014 at 9:07
• happens to the best of us :) May 14, 2014 at 9:24

Ok, what I have done is to determine the y value from the x:

I have then determined y from x and plotted on top of the original data (blue points are the fitted values, red are the original):

• I have a problem with the reconstruction of the procedure in the mentioned article. In (eq 28) there is the explicite condition that $a_1^T \cdot C_1 \cdot a_1 = 1$ which requires a correction by division by about $288443.686$ and then the first resulting coefficient $a \ne 1$. However, to reproduce your data/function, it seems to be required that $a=1$ instead, such that the condition involving $C_1$ does not hold. What's going on here? Aug 11, 2014 at 12:19