POV-Ray : Newsgroups : povray.advanced-users : Least Squares fitting : Least Squares fitting Server Time
15 Jul 2024 12:50:58 EDT (-0400)
  Least Squares fitting  
From: Bald Eagle
Date: 10 Mar 2023 18:40:00
Message: <web.640bbedd42ffa061f9dae3025979125@news.povray.org>
So, I've had a few ideas that I've wanted to pursue, and for those, I need a few
tools to perform the tasks more rigorously than "by eye".

I looked at converting some Javascript code, but gave up on that,
https://jsxgraph.uni-bayreuth.de/wiki/index.php/Least-squares_circle_fitting
then found a semi-encouraging post,
https://www.codeproject.com/Questions/228108/Linear-least-squares-circle-fit-in-C-or-Cplusplus
and then found the original paper,
https://ir.canterbury.ac.nz/bitstream/handle/10092/11104/coope_report_no69_1992.pdf?sequence=1
which I thought I could puzzle out - the solution seemed tantalizingly close,
https://towardsdatascience.com/building-linear-regression-least-squares-with-linear-algebra-2adf071dd5dd
https://online.stat.psu.edu/stat462/node/132/
But good ole' Coope just used too many x's and changes of variables, and
sparsely described methods of getting from point A to point B.

Luckily, I found some "good" c++ code, and I was able to successfully convert
the Taubin algebraic solution before I left for work:
https://people.cas.uab.edu/~mosya/cl/CPPcircle.html
and then got back home and worked on the geometric Levenberg-Marquardt fit, only
to find that it's written with a host of ugly "goto" statements.  :O :(

I somehow navigated a path to simulate that in SDL, code the few dependencies,
and fake or ignore the rest.  Got stuck in an endless while loop somewhere when
I started whittling down the circle to an arc of pi*0.6, but fixed that, and...

Seems to be working well enough.   So now I have a regular linear least squares
regression macro, and at least one set of (seemingly) fully functional circle
fitting macros.


Onwards we trudge....


Post a reply to this message


Attachments:
Download 'leastsquares_circle.png' (37 KB)

Preview of image 'leastsquares_circle.png'
leastsquares_circle.png


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.