# enclosed circle

15 posts / 0 new
HQA
enclosed circle

I am calculating the corrected image circle for the APASS systems, based on the patterns I see on the flatfields.  I have marked x,y positions for four points on each of the OTA images, and would like to find the radius and center coordinates of the circle that passes through these points.  Anyone want to make the calculation?

C3B

409,3767

3657,455

3737,3519

289,447

C4V

337,3687

3785,3767

3769,311

297,295

I may need to do this for another pair of circles sometime later, so don't throw away your code!

Arne

roe
Plane geometry?

You're talking plane geometry here, right?  Have you seen this done before?  Three points (not on a straight line) define a unique circle but I doubt there is a general solution for 4 points.  On the other hand I have (in the distant past) calculated a best-fit in a least squares sense.  Would that fit your needs ( I would have to knock off a LOT of rust ).

Jim Roe [ROE]

HQA
plane geometry

Hi Jim,

Yes, plane geometry, and these are empirical measurements with some judgement error, so a least squares solution is what I am looking for.  I figured 4 points (one in each quadrant of the detector) would be helpful.

Arne

WAB
plane geometry

Jean Meeus' "Astronomical Algorithms", pg 119, has the algorithm to find the smallest circle include three points on the sky (planetary conjunction type stuff).

Brian D. Warner

roe
Quick look

We can calculate (fairly easily) the center of a circle determined by three points.  With four points there are 4 different combinations of three only.  We could calculate all four of these centers and do a "center of mass" on them as an estimate of the "best" center.  Using that center we can calculate the distance to each point and average those for a "best" radius.  I wouldn't want to defend a Mastser's thesis with that, but would it serve your purpose?

Jim Roe

jji
Fitting a Circle

I was thinking some along the same lines Jim  but even cruder.  Since Arne evidently eyeballed the points to lie on a circle, just find a circle that fit any three points (easy) and adjust it by eyeball to fit all 4.  Your approach is probably better.

No matter how you do it, a true least squared fit is nasty if you do it by hand.  Evidently MatLab has the ability to do it but I have no idea how.

Jim Jones

jji
Least squared fit to a circle

Arne

Is this what you are looking for?

Jim Jones

roe
another thought

Is there some magic in using quadrants?  Why not just use 3 points?

Just sayin'

Jim Roe

CQJ
Circle

If I understand your question correctly, I get a circle center of (1911,1991) and a radius of 2354 pixels, to the nearest pixel or so, for your first set of numbers.  More precisely, the x-coordinate of the center should be 1910.5 pixels, and the radius 2353.5 pixels, but I suspect you want the answer in whole pixels.  The circle misses each point by about 28 pixels in radius.  Is this correct, or did I really goof?

John Centala

roe
My solution

I created a LibreOffice spreadsheet that will calculate the 3 point solution to each of the 4 permutations of 4 data points.  It then averages the x and y of the centers and the radii.  It is available to whomever would like it.

Here are the results for the two data sets

Data set #1

Xavg

1961.4135742344

+/-

-9.0337356185

Yavg

2040.5162933772

+/-

-9.4646045294

Ravg

2315.9726154835

+/-

-6.5563813064

Data set #2

Xavg

2063.0069988802

+/-

-43.7332635044

Yavg

2008.6708135109

+/-

-44.1884649781

Ravg

2434.6225288002

+/-

-31.0926593647

Jim Roe [ROE]

CQJ
Circle

Jim,

When I tried my method on the second set of data, I got the center at (2063, 2009), R=2434, in agreement with your more precise calculation, so I obviously goofed on the first set of numbers, and I'm now not even sure about the second set.

John Centala

roe
Precision

I hope everyone recognizes the stated precision (to 10 decimal places!) is WAY overstated.  I just cut and pasted the values from the spreadsheet, figuring no one on this forum would be misled.

Jim Roe [ROE]

CQJ

Jim,

OK, I agree with your first set of numbers also.  My mistake was using (289, 247) instead of (289, 447) for one of the coordinates.

John Centala

HQA
enclosed circle

Thanks for the prompt responses!  I think I now have enough information for my immediate purposes.

Arne

roe
Revision

After puzzling over my process I decided that a least squares approach could be implemented easily in a modern spread sheet that would give a semblance of greater certainty in the sense that the average deviation of each point from the circle would be minimized.  The idea is to start with a reasonable estimate of the center of the circle (x,y), to calculate the average distance of the points from this trial center with its standard deviation.  Then, at least in Libre Office Calc, to run the Tools>Solver routine which iterates the initial (x,y) values of the center while watching the standard deviation cell.  When a minimum has been reached for the standard deviation the process stops, leaving the final values in place.  Here are the refined values (actually pretty close to the previous estimates):

Case #1

Xavg

1961.5

Yavg

2041.2

Ravg

2315.9

Standard deviation = 6.5

Case #2

Xavg

2062.7

Yavg

2009.4

Ravg

2434.0

Standard deviation = 31.1

Jim Roe [ROE]