Newsgroups: comp.graphics
Path: cantaloupe.srv.cs.cmu.edu!das-news.harvard.edu!noc.near.net!uunet!mcsun!sun4nl!tnofel!felfs!rytg7
From: rytg7@fel.tno.nl (Q. van Rijt)
Subject: Re: Sphere from 4 points?
Organization: TNO Physics and Electronics Laboratory
Date: Thu, 22 Apr 93 08:40:10 GMT
Message-ID: <1993Apr22.084010.3787@fel.tno.nl>
References: <1qkgbuINNs9n@shelley.u.washington.edu> <spworleyC5Jy7r.6Bo@netcom.com> <1qtit4INN9cm@edna.cc.swin.edu.au>
Lines: 26

There is another useful method based on Least Sqyares Estimation of the sphere equation parameters.

The points (x,y,z) on a spherical surface with radius R and center (a,b,c) can be written as 

   (x-a)^2 + (y-b)^2 + (z-c)^2 = R^2

This equation can be rewritten into the following form:  

   2ax + 2by + 2cz + R^2 - a^2 - b^2 -c^2 = x^2 + y^2 + z^2

Approximate the left hand part by   F(x,y,z) = p1.x + p2.x + p3.z + p4.1

For all datapoints, i.c. 4, determine the 4 parameters p1..p4 which minimise the average error |F(x,y,z) - x^2 - y^2 - z^2|^2.

In 'Numerical Recipes in C' can be found algorithms to solve these parameters.

The best fitting sphere will have 
- center (a,b,c) = (p1/2, p2/2, p3/2)
- radius R = sqrt(p4 + a.a + b.b + c.c).

So, at last, will this solve you sphere estination problem, at least for the most situations I think ?.

Quick van Rijt, rytg7@fel.tno.nl



