# Arcs Of Best Fit For Large Nos. of X&Y

1. Dec 9, 2013

### tomtomtom1

Hi everyone

I was hoping someone could help with a problem I’m having.

I am often given large amounts of X & Y data which relate to the edges of highways.
Sometimes they are just a hand full approx 20 and other times there are approx 400.

I use the data to find arcs that best fit the x & y data which is then used to calculate various other aspects of the highway (which I wont bore you with).

My question is this; does anyone know of any calculators (online/excel/etc) that is available where by I can copy and paste in large rows of X&Y data and then the calculator then produces the arc of best fit i.e. the calculator should return the XY coordinates of the center of the circle and its radius.

I am not that fussed as to how the arc of best fit is calculated i.e. may or may not use least squares, I just need something that is able to handle large rows of XY data.

Can anyone help?

2. Dec 9, 2013

### Office_Shredder

Staff Emeritus
Well, if you just want a circle that makes sense you can do the following:

Average the X and Y coordinates independently to get the X and Y coordinates of the center of the circle, call these $X_0$ and $Y_0$

For each (X,Y) data pair, calculate
$$\sqrt{ (X-X_0)^2 + (Y-Y_0)^2 }$$
the distance from that point to the center of your circle. Average all of these distances, and that is the radius of your circle.

I make no claim that this is optimal in any way, but it's probably pretty close. You should be able to make a spreadsheet in excel to do the calculations upon copy/pasting of data (with maybe a single dragging when doing the distance/averaging calculation but there's probably an excel command to avoid that)

3. Dec 9, 2013

### JJacquelin

There is a very simple method to compute the radius and the coordinates of an arc of circle fitting a data set of points (x,y), even if the measurements are scattered : see pages 12-13 in this paper :
It is easy to write a computer program with a mathematical software such as Matlab, Mathematica, Mathcad, etc...

Last edited: Dec 9, 2013
4. Dec 9, 2013

### jbriggs444

As I understand the situation, the X and Y coordinates are for a segment of a circular arc. There is no guarantee that they are uniformly separated. If you average the X and Y coordinates, this will not be a good estimate for the center of the circle. Nor will it be a particularly good estimate of the center of the arc.

One approach might be to assume that the points do not define more than about 3/4 of a circle. Start as you have outlined to determine the centroid of the sampled points. Compute the angle that each of the points make with the computed centroid, sort them and find the largest gap (modulo 360 degrees).

Split the points at the gap and sort by angle. At this point you could assume that the center lies on the perpendicular bisector of the line connecting the two extreme points and use least squares (or similar) to determine a radius. Given a radius, you could then try to refine the estimate of the center line.

This is all off the top of my head and may be hideously clumsy.

5. Dec 9, 2013

### Office_Shredder

Staff Emeritus
I misunderstood the question, I thought it was for a full circle as opposed to just a partial arc. The question makes a lot more sense now.