This python program fits an ellipse through a given set of points. This ellips is optimal in the least squares sense.
The code is documented in fit_ellipse.pdf
.
I use pythontex to make the pdf from the latex file (first pdflatex, then pythontex, then pdflatex again). See the docs of pythontex. BTW, pythotex is really useful. I use it all the time.
The source of the code can be found in fitEllipse.tex
.
Before moving this code to github, it was available at http://nicky.vanforeest.com/misc/fitEllipse/fitEllipse.html.