[SciPy-user] Fitting sphere to 3d data points

James Vincent jjv5 at nih.gov
Thu Jan 25 06:46:58 CST 2007


	Is it possible to fit a sphere to 3D data points using  
scipy.optimize.leastsq? I'd like to minimize the residual for the  
distance from the actual x,y,z point and the fitted sphere surface. I  
can see how to minimize for z, but that's not really what I'm looking  
for. Is there a better way to do this? Thanks for any help.

params = a,b,c and r
a,b,c are the fitted center point of the sphere, r is the radius

err = distance-to-center - radius
err = sqrt( x-a)**2 + (y-b)**2 + (z-c)**2) - r

James J. Vincent, Ph.D.
National Cancer Institute
National Institutes of Health
Laboratory of Molecular Biology
Building 37, Room 5120
37 Convent Drive, MSC 4264
Bethesda, MD 20892 USA

jjv5 at nih.gov

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070125/f9311e9d/attachment.html 

More information about the SciPy-user mailing list