Re: Sphere formula

*To*: mathgroup at smc.vnet.net*Subject*: [mg109524] Re: Sphere formula*From*: Ray Koopman <koopman at sfu.ca>*Date*: Mon, 3 May 2010 06:12:25 -0400 (EDT)*References*: <hr65rj$jq6$1@smc.vnet.net> <hrbach$hq9$1@smc.vnet.net>

On May 2, 2:35 am, Ray Koopman <koop... at sfu.ca> wrote: > On May 1, 3:51 am, "Alexander Elkins" <alexander_elk... at hotmail.com> wrote: >> "S. B. Gray" <stev... at ROADRUNNER.COM> wrote in messagenews:hrbach$hq9$1 at smc.vnet.net... >>> On 4/27/2010 1:05 AM, S. B. Gray wrote: >>>> 1. The center of a sphere through 4 points has a very nice determinant >>>> form. (http://mathworld.wolfram.com/Sphere.html) What I want is a nice >>>> formula for the center of a sphere through 3 points, where the center is >>>> in the plane of the three points. I have a formula but it's a horrible >>>> mess of hundreds of lines, even after FullSimplify. >>>> >>>> 2. (Unlikely) Is there a way to get Mathematica to put a long formula >>>> into a matrix/determinant form if there is a nice one? >>>> >>>> Any tips will be appreciated. >>>> >>>> Steve Gray >>> >>> Thanks to everyone who answered my question, but there is a simpler >>> answer. I forgot the simple fact that any linear combination of two >>> vectors lies in the plane of the two vectors. >>> >>> Let the three points be p1,p2,p3. Consider the linear function >>> p=b(p2-p1)+c(p3-p1) where b,c are to be determined and p is the desired >>> center. Now do >>> >>> Solve[{Norm(p-p1)==Norm(p-p2),Norm(p-p1)==Norm(p-p3)},{b,c}]. >>> >>> This gives b,c and therefore p, which will be equidistant from p1,p2, >>> and p3 and lie in their plane. Very simple. (I used (p-p1).(p-p1) etc. >>> instead of Norm.) >>> >>> Steve Gray >> >> Unless I misinterpreted something in this posting, the following does not >> give the expected center point {1, 2, 3} using Ray Koopman' s posted values >> for {p1, p2, p3} as the result: >> >> In[1]:=With[{p1={0.018473,-1.1359,-0.768653}, >> p2={2.51514,5.25315,6.48158}, >> p3={0.818313,-0.881007,-1.0825}}, >> With[{p=b(p2-p1)+c(p3-p1)}, >> p/.NSolve[{(p-p1).(p-p1)==(p-p2).(p-p2), >> (p-p1).(p-p1)==(p-p3).(p-p3)},{b,c}]]] >> >> Out[1]={{0.797494,2.34596,2.76487}} >> [...] > > The fix is simple: just change the definition of p. > > Block[{p1 = {0.018473,-1.1359,-0.768653}, > p2 = {2.51514,5.25315,6.48158}, > p3 = {0.818313,-0.881007,-1.0825}, b,c,p}, > p = (1-b-c)p1 + b*p2 + c*p3; > p /. Flatten@Solve[{(p-p1).(p-p1)==(p-p2).(p-p2), > (p-p1).(p-p1)==(p-p3).(p-p3)},{b,c}]] > > {1.,2.,3.} Or you could shift to put one point at the origin: Block[{p1 = {0.018473,-1.1359,-0.768653}, p2 = {2.51514,5.25315,6.48158}, p3 = {0.818313,-0.881007,-1.0825}, b,c,q,q2,q3}, q2 = p2-p1; q3 = p3-p1; q = b*q2 + c*q3; p1 + q/.Flatten at Solve[{q.q==(q-q2).(q-q2), q.q==(q-q3).(q-q3)},{b,c}]] {1.,2.,3.}