       Re: Sphere through 4 points

• To: mathgroup at smc.vnet.net
• Subject: [mg85415] Re: [mg85401] Sphere through 4 points
• From: danl at wolfram.com
• Date: Sun, 10 Feb 2008 05:10:05 -0500 (EST)
• References: <200802090915.EAA16803@smc.vnet.net>

```> 	Given 4 points in 3-space not lying in a plane, I want the
> center and radius of the incident sphere. I know about the elegant
> determinant solution (4 or 5 determinants, each 4x4, plus a few
> arithmetic operations) and I'm using that, but maybe someone has coded
> a faster version.
> 	Thanks for any information.
>
> Steve Gray
>

Not sure if this is faster, but could do:

{x, y, z, vars, rsq, coeffs, polys, lpolys, cen},
vars = {x, y, z};
polys = (vars.vars - rsq) /.
Thread[vars -> (vars - Transpose[data])];
lpolys = Expand[Rest[polys] - First[polys]];
coeffs = CoefficientArrays[lpolys, vars];
cen = LinearSolve[Last[coeffs], First[coeffs]];
{cen, Sqrt[rsq]} /.
First[Solve[(First[polys] /. Thread[vars -> cen]) == 0]]
]

In:= SeedRandom;
data = RandomReal[{-5, 5}, {4, 3}];

Out= {{-2.25666, -13.9661, 7.0018}, 15.1774}

Can do around 200+ per second, on my laptop.