Saturday, January 14, 2012

Best Fit Circle: find radius given center

Today we want to consider a part of the problem of finding a best fit circle to a set of measured points (and do it more rigorously than my previous attempt). Given a center (a, b) of a circle, we want to find the best fit radius, r, to a set of given points Pi = (xi , yi), for i = 1 to n.

In other words, we have a set of points and a candidate center for what we think is a good approximation to a circle (or a circular arc). We want to find the best radius for that center with those points and have a means of quantifying how good of a fit we have. If we can find this, we can decide which of a set of candidate centers is best.

The usual thing to do when looking for a best fit shape is to minimize the sum of squares of the errors. If we knew the radius we might calculate the sum of squares of the errors as

So, for each point, we find out how far it is from the candidate center, find the difference between that distance and the radius to get the error, and then square the error. And then we add all of those squared errors together to get SSE(r). We want to minimize SSE(r), which is a simple problem in differential calculus. When SSE’(r) = 0, SSE(r) is at a minimum, maximum, or perhaps a point of inflection. Then

Observe that the best fit radius is just the average distance from the candidate center to each point. Seems sensible. Also, observe that
and so, by the second derivative test, SSE(r) is at a minimum.

To see it all put together into a practical solution, see Best Fit Circle: find the center using Excel.

Wednesday, January 4, 2012

Field Measurement of Circular Arcs

There are a number of simple cases for field measurement of a circle. A full circle can be measured across its diameter or around its circumference to determine its area. (To use the circumference to determine the area, first use the formula C = 2πr to determine the radius and then use the radius to determine the area which gives A = C2/(4π).) Half circles and quarter circles are similarly straightforward.

But suppose you want to measure a circular arc which has an unknown central angle, θ, such that 0 < θ < 180°. There are three things that are normally easy to measure for such circles and they only require a tape measure:

  1. chord distance (also called the run of the arc – denoted u)
  2. rise of the arc (i)
  3. arc length (s) – arc length measurements are easy for existing items if there is a (normally vertical) surface to hold the tape against; not as easy for proposed items unless approximation is acceptable

The following diagram illustrates:

There are number of reasons why you might be interested in the rise, run approach to defining a circular arc. If you are laying out an arc, it may be infeasible to run a tape measure around the center point of the arc – perhaps due to the size or interfering objects. Also, measuring unusual angles requires specialized equipment (such as a transit) which requires set up time. (If you are using a total station this whole discussion is moot, so we are assuming we’re trying to do something without it.) The rise/run approach is also the approach used in some blue prints for defining curved walls. Carpenters and linear measurements are on good working terms, and we like to leverage this where we can.

But whatever the reason you might want to use this approach, you can calculate both ways. First of all, let’s list all of the relevant equations:



Now, let’s suppose we know u and i. We determine the remaining variables from these.
Manipulating equation (4):


So, we need a and θ (or at least cos θ) to find r, which we do by manipulating equations (1) and (3).
Manipulating equation (3):
Manipulating equation (1):

Substitute (6) and (7) into equation (5):


Now that we have r we can use that number in equation (7) to find θ, etc. I omit all of the rest of the gory details, but here are the final results for solving the unknowns in terms of different combinations of known values (note that θ is understood to be in radian measure and the reader is left to discern what order to calculate the different values in).

I have not addressed how to solve the cases where s and either u, i, or a are given as they are more difficult.  Perhaps a future post will address these cases.