Newsgroups: sci.engr.advanced-tv,sci.image.processing,comp.graphics.algorithms,comp.graphics,comp.lang.postscript
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!miner.usbm.gov!rsg1.er.usgs.gov!stc06.ctd.ornl.gov!fnnews.fnal.gov!uwm.edu!math.ohio-state.edu!usc!news.isi.edu!gremlin!charming!mcohen
From: mcohen@charming.nrtc.northrop.com (Martin Cohen)
Subject: Re: Best fit sphere to cloud of points
Message-ID: <D9ptL4.6qA@gremlin.nrtc.northrop.com>
Sender: news@gremlin.nrtc.northrop.com (Usenet News Manager)
Organization: Northrop Grumman Automation Sciences Laboratory, Pico Rivera, CA
References: <Poynton-1705951718580001@ts2-03.inforamp.net> <D93Kpv.4LD@wti.com>
Date: Mon, 5 Jun 1995 19:46:16 GMT
Lines: 37
Xref: glinda.oz.cs.cmu.edu sci.engr.advanced-tv:3020 sci.image.processing:15048 comp.graphics.algorithms:17548 comp.graphics:77860 comp.lang.postscript:33229

In article <D93Kpv.4LD@wti.com> jasper@wti.com (Jon Barber) writes:
>Given a cloud of points, I want to know if 
>those points are on a (fuzzy) sphere, and
>if so, where the center of the sphere is.
>
>I say fuzzy because some tolerance off the
>sphere is acceptable.
>
>Any ideas/pointers?
>-- 
>-   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   - 
>"Jasper" Jon Barber             Phone: (805) 962-8117 x309 (w) 968-0308 (h)
>Wavefront Technologies, Inc.    
>530 East Montecito St.             "ahh, grasshopper"

Instead of fitting a sphere sum(i=1..3)(x_i - a_i)^2 = r^2
in the form

minimize sum(j=1..n) (r - sqrt(sum(i=1..3) (x_j_i - a_i)^2)))
for a_i and r, 
solve this:

minimize sum(j=1..n) (r^2 - (sum(i=1..3) (x_j_i - a_i)^2)))
for a_i and r.

If you write it in the form
minimize sum(j=1..n) (c - sum(i=1..3) (x_j_i^2 - 2 a_i x_i_j)))
where c = r - sum(i=1..3)(a_i), this becomes a linear
least squares problem.

Note that this works for any number of dimensions - I originally
did it for 2 (fitting a circle).

-- 
Marty Cohen (mcohen@nrtc.northrop.com) - Not the guy in Philly
  This is my opinion and is probably not Northrop Grumman's!
          Use this material of your own free will
