
Using least squares regression to calculate a circle from a freehand drawing - curtis
http://vladgotlib.com/circular/
======
8note
The score is a bit silly; to get a better one, just add more points.

A smattering of poits scribbled close together nets me 220000, while a single
big ring earns only 700.

~~~
austin_y
I noticed the same thing. I was able to really boost my score by just drawing
over the 'same' circle a bunch of times. Doing that got my score up into the
7-8 million range.

~~~
kazinator
But that makes sense. If people draw a circle by overlaying multiple
approximations, it gets better.

If there were a contest out of this, it could be disqualified: i.e. you start
and finish on approximately the same point.

------
jwmerrill
Quick version in Desmos:

[https://www.desmos.com/calculator/7dpcup8iwk](https://www.desmos.com/calculator/7dpcup8iwk)

Here you move the points by dragging instead of creating them by drawing,
which I find more fun in some ways, and less fun in others.

Edit: constraining the radius makes the system behave like a hoop attached to
springs
[https://www.desmos.com/calculator/a2pfwqrtmb](https://www.desmos.com/calculator/a2pfwqrtmb)

------
eof
Not that I have a better suggestion (except something might be wrong with
"disbalance"), but this is pretty obviously "that that good"

[http://i.imgur.com/m8MOtUU.jpg](http://i.imgur.com/m8MOtUU.jpg)

------
kazinator
Least _squares_ to calculate a _circle_. How utterly ...

... fitting! :)

<brag>Tried four times; hit 3.5M on third try, then 4.8M, and got
bored.</brag>

------
murkle
If you want to do it properly, use Singular Value Decomposition, eg

[http://tube.geogebra.org/student/m1113573](http://tube.geogebra.org/student/m1113573)

------
guylhem
I'm not sure I understand the use of least squares here.

Why not use a Hough transform with each drawn point voting for a center, then
average the radius?

It's not a critic - just me wondering why.

~~~
teraflop
Using a Hough transform to find a circle with an unknown radius is expensive.
You have a 3D parameter space, and each point has to "vote" for a 2D
subsurface of that space. Discretizing the entire volume at a high resolution
is going to require a lot of memory.

~~~
rawnlq
I agree it is going to expensive but it's not because of memory. You could
probably just try every (x,y) center and have all points vote for the radius,
and just keep max before moving on to next point.

------
fruchtose
There's a bug in your code somewhere:
[http://i.imgur.com/p4tn4Kx.png](http://i.imgur.com/p4tn4Kx.png)

~~~
Maome
You added a point by mis-clicking very near the analyze button. It tried.

~~~
TTPrograms
This is why we use L_1 regression!

------
anodari
This make me remember the Giotto big O history [1]. The pope was looking for a
painter and requested samples to artists and Giotto sent for him just a
circle.

[1]
[https://100swallows.wordpress.com/2007/09/14/giottos-o/](https://100swallows.wordpress.com/2007/09/14/giottos-o/)

------
biot
My best of 11,396,452: [http://imgur.com/aO3xA0l](http://imgur.com/aO3xA0l)

------
ebauch
sometimes I am wondering what get voted up on HN

------
bbcbasic
Sure I can help with server costs. I can eliminate them by pointing you to:
[https://pages.github.com/](https://pages.github.com/)

