From: Nicolaj Baramsky on 8 Aug 2010 08:38 Hey Guys, my situation: I have a couple of thousends of data pairs which should be placed on a circle. Well at least a few of them. Lets say, I measured a distance of 1 mm of the surface of a cylinder (d=10mm) which has defects (about 80%) on its surface in the middle of the measured distance. I have about 10k data pairs. The problem is, that the x and y values of the data pairs are set anywhere in space, dependent on how I adjusted the measuring gadget. The aim is to calculate the difference of volume from the intact cylinder to the cylinder with defects. But the defects are too small for getting them in another method, like weighing. >>>> First question: How do i get the best fitting 10 mm circle on the datapairs at the edges of my measured data? What is your idea? It doesn't work by constructing a lot of perpendicular bisector of the sides and let them cross each other, so I get a lot of middle points of the circle (which i have to average afterwards), because the lines are too close to each other, so the crossing points are wide spread, too wide for a proper average. My next idea is to interpolate a function which is best a circle function. >>>> How can I interpolate my own "type" of function (no polynome, no sin or cos, but a circle function) with my data? Thanks for every comment on that! Regards from Hamburg, Nicolaj
From: Miroslav Balda on 8 Aug 2010 10:11 "Nicolaj Baramsky" <nicolaj.baramskyREMOVETHIS(a)tu-harburg.de> wrote in message <i3m8fd$38u$1(a)fred.mathworks.com>... > Hey Guys, > > my situation: I have a couple of thousends of data pairs which should be placed on a circle. Well at least a few of them. > > Lets say, I measured a distance of 1 mm of the surface of a cylinder (d=10mm) which has defects (about 80%) on its surface in the middle of the measured distance. I have about 10k data pairs. > > The problem is, that the x and y values of the data pairs are set anywhere in space, dependent on how I adjusted the measuring gadget. > > The aim is to calculate the difference of volume from the intact cylinder to the cylinder with defects. But the defects are too small for getting them in another method, like weighing. > > >>>> First question: How do i get the best fitting 10 mm circle on the datapairs at the edges of my measured data? What is your idea? > > It doesn't work by constructing a lot of perpendicular bisector of the sides and let them cross each other, so I get a lot of middle points of the circle (which i have to average afterwards), because the lines are too close to each other, so the crossing points are wide spread, too wide for a proper average. > > My next idea is to interpolate a function which is best a circle function. > >>>> How can I interpolate my own "type" of function (no polynome, no sin or cos, but a circle function) with my data? > > > Thanks for every comment on that! > > Regards from Hamburg, > Nicolaj Hi Nicolaj, Maybe that the FEX file ID 22642 could help you. Mira
From: Jan Simon on 8 Aug 2010 14:39 Dear Nicolaj, there are some further circle fit functions in the FEX. Just search for "circle fit". Kind regards from Heidelberg, Jan
From: Nicolaj Baramsky on 9 Aug 2010 04:06 Thanks for your answers! This is a good beginning. I looked through all of this methods, but it seems they all give me the "best fitting circle" into my data, so they return the "best" radius. I need to find the best fitting location for a circle with a fixed radius. It is not possible for me to integrate that into one of the curce fitting algorithms (like Taubin). Can you give me a hint? Thanks a lot! Nicolaj
From: Miroslav Balda on 9 Aug 2010 17:08
"Nicolaj Baramsky" <nicolaj.baramskyREMOVETHIS(a)tu-harburg.de> wrote in message <i3octd$66$1(a)fred.mathworks.com>... > Thanks for your answers! This is a good beginning. > > I looked through all of this methods, but it seems they all give me the "best fitting circle" into my data, so they return the "best" radius. > I need to find the best fitting location for a circle with a fixed radius. > It is not possible for me to integrate that into one of the curce fitting algorithms (like Taubin). > > Can you give me a hint? > > Thanks a lot! > > Nicolaj Hi Nicolaj, Your task could be solved by the following code: ---------------------------------------------- % Nicolaj.m % Needs FEX functions: % www.mathworks.com/matlabcentral/fileexchange/9033 % www.mathworks.com/matlabcentral/fileexchange/9035 % www.mathworks.com/matlabcentral/fileexchange/17534 close all err = inp('error ',0.1); % measuremet error cp = inp('Center',[2,1]); % Center point % Generate data: r = 3; phi = 2*pi/10*(0:9)'; XY = [cos(phi), sin(phi)]*r; xy = XY + ones(length(phi),1)*cp + randn(length(phi),2)*err; % residuals: r2 = r*r; res = @(p) (xy(:,1)-p(1)).^2 + (xy(:,2)-p(2)).^2 - r2; [p,ssq,cnt] = LMFnlsq(res,rand(2,1),'Display',-1) fig(4); plot(xy(:,1),xy(:,2),'o'); hold on; grid XY = XY + ones(length(phi),1)*p'; plot(XY(:,1),XY(:,2),'*r'); plot(cp(1),cp(2),'xb', p(1),p(2),'hr') axis equal ---------------------------------------------- with one of solutions: >> Nicolaj error = 0.1000 => Center = 2.0000 ... 1.0000 => ******************************************************************* itr nfJ SUM(r^2) x dx ******************************************************************* 0 1 8.1157e+002 2.7219e-001 0.0000e+000 1.9881e-001 0.0000e+000 1 2 3.8459e+001 1.6296e+000 -1.3574e+000 8.3130e-001 -6.3248e-001 2 3 2.1078e+000 2.0275e+000 -3.9789e-001 1.0218e+000 -1.9050e-001 3 4 2.0892e+000 2.0366e+000 -9.1278e-003 1.0265e+000 -4.6802e-003 4 5 2.0892e+000 2.0366e+000 -1.6348e-005 1.0265e+000 -8.5803e-006 p = 2.0366 1.0265 ssq = 2.0892 cnt = 4 It is obvious that the solution has been reached in 4 iterations, in which the sum of squares of residuals dropped down by 2 orders. The plotted results are quite good. Hope it helps. Mira |