11-03-2005 05:04 PM
chilly charly, et al.:
It seems the image of my last post regarding Fitting on a Sphere is not viewable from this discussion forum. I apologize for this and urge interested poeple to view it from its URL source:
ftp://sjpublicaccess.mybpip.net/least_sqaure_min_sphere1.bmp
Jordan
11-03-2005 10:48 PM
As I wrote in your other post, I have underestimated the difficulty. I bumped into the same dead corner, although your equations can be further developped into
Sigma(fi) = Sigma(fi.xi) = Sigma(fi.yi)= Sigma(fi.zi)= 0
If Altenbach doesn't come back with an answer before, I'll try to spend some more time on this during the we.
11-04-2005 01:04 PM - edited 11-04-2005 01:04 PM
@chilly charly wrote:
If Altenbach doesn't come back with an answer before, I'll try to spend some more time on this during the we...
Well, let's not overcomplicate things and instead solve the 2D equivalent of fitting a circle in a plane. Almost the same thing, but easier on the ink ;).
A good explanation is given in the maple article by Thomas Schramm (Fitting a Circle to a Number of Points, free registration required), but a quick Google search will probably show others.
Expanding it to three (or more) dimensions seems trivial. 🙂
Message Edited by altenbach on 11-04-2005 11:05 AM
11-04-2005 01:33 PM
11-04-2005 02:04 PM - edited 11-04-2005 02:04 PM
Message Edited by altenbach on 11-04-2005 12:04 PM
11-04-2005 07:14 PM
11-05-2005 05:05 AM
11-07-2005 02:35 PM
Altenbach, et al.:
Thanks to you and others, I satisfactorily understand the "clever change of variables" that makes LabVIEW's "fitting on a sphere" function possible! I wrote a version of it in MatLab for my research purposes and have included it below. You may find some of the references interesting.
I greatly appreciate you and others putting-up with and responding to my questions as I wrested with this one.
Regards,
Jordan
function
params = sphere_fit_linear1(x_i,y_i,z_i)% function params = sphere_fit_linear1(x_i,y_i,z_i)
%
% This approach to fitting a general equation of a sphere to data is based
% on a clever change of variables that reduces the non-linear least-squares
% problem to a linear one!
% My awareness of this possibility was sparked by not understanding how
% LabVIEW's "fitting on a sphere" function was doing this. Understanding
% developed after (1) "stumbling on" Marc Renault's ("Fitting Circles and
% Ellipses to Data Using the Least-Squares Method",
% http://www.math.temple.edu/~renault/ellipses.html) explaination of I. D.
% Coope's published derivation (Circle Fitting by Linear and Nonlinear
% Least Squares, J Optim Theory Appl, 76 (1993) pp. 381-388) and (2) a
% series of interacations on National Instrument's LabVIEW discussion forum
% (http://forums.ni.com/ni/board?board.id=170), particularly with C.
% Altenbach.
% Jordan Alexander 7 Novemember 2005 Luxel Corporation
a_11 = 2*sum(x_i.^2);
a_12 = 2*sum(y_i*x_i');
a_13 = 2*sum(z_i*x_i');
a_14 = sum(x_i);
a_21 = a_12;
a_22 = 2*sum(y_i.^2);
a_23 = 2*sum(z_i*y_i');
a_24 = sum(y_i);
a_31 = a_13;
a_32 = a_23;
a_33 = 2*sum(z_i.^2);
a_34 = sum(z_i);
a_41 = 2*sum(x_i);
a_42 = 2*sum(y_i);
a_43 = 2*sum(z_i);
a_44 = length(x_i);
b_1 = sum((x_i.^2+y_i.^2+z_i.^2)*x_i');
b_2 = sum((x_i.^2+y_i.^2+z_i.^2)*y_i');
b_3 = sum((x_i.^2+y_i.^2+z_i.^2)*z_i');
b_4 = sum(x_i.^2+y_i.^2+z_i.^2);
A = [a_11 a_12 a_13 a_14;a_21 a_22 a_23 a_24;a_31 a_32 a_33 a_34;a_41 a_42 a_43 a_44];
B = [b_1 b_2 b_3 b_4];
params = A\B';