Challenging Question - to find 3 points radius and centre

N

newbie04

Hi all, I wonder who knows to solve the follwing Question :

say i got 3 points

column "A1" = a(x1,y1,z1),
column "A2" = b(x2,y2,z2).
column "A3" = c(x3,y3,z3).

How to find the centre of these 3 pts and the radius? This questio
assigned to me is much much beyond my limit and VB knowledge.Ca
someone help?

Thks and i really appreciate any help
 
D

Dana DeLouis

I am probably wrong here, but does one need 4 points to uniquely determine a
sphere (x,y,z)? It appears to me that it may be true. (I can only find
4-point solutions also.)
 
V

Vasant Nanavati

Hi Dana:

I agree that you would need 4 points in space to uniquely determine a
sphere, since the locus of all points equidistant from 3 given points would
be a straight line.

Regards,

Vasant.
 
N

newbie04

Hi Rob van Gelder,

Thks for the url. But how the things work in 3 dimensions? Thks
 
D

Dana DeLouis

It looks to me that the general solution is rather complex to do on a
worksheet. Therefore, I only attempted this as a vba solution. I don't
know how your data is set up. Therefore, I have set this up using A1:C4,
with x's in Column 'A', etc. I think I've done this correctly, but I have
not fully tested it. You will have to adjust it to your own situation.
HTH. Dana

Sub Demo()
'// = = = = = = = = = = = = = = =
'// By: Dana DeLouis
'// Center of Sphere, 4-Point
'// Finds Center of Sphere given 4 (x,y,z) points
'// This Demo uses A1:C4, with each column holding x,y,z values
'// = = = = = = = = = = = = = = =

'Input array
Dim v

'Temp variables
Dim k, t, t1, t2, t3, t4
Dim vt, vx, vy, vz, v1

'Sphere centered at {x,y,z}, with Radius r
Dim x, y, z, r
Dim Sphere

With WorksheetFunction
' Get Data
v = [A1:C4]

'// Vectors of x^2+y^2+z^2
vt = Array( _
.SumSq(.Index(v, 1, 0)), _
.SumSq(.Index(v, 2, 0)), _
.SumSq(.Index(v, 3, 0)), _
.SumSq(.Index(v, 4, 0)))

'// Vector of x's, y's, z's, & 1's
vx = .Transpose(.Index(v, 0, 1))
vy = .Transpose(.Index(v, 0, 2))
vz = .Transpose(.Index(v, 0, 3))
v1 = Array(1, 1, 1, 1)

k = .MDeterm(.Transpose(Array(vx, vy, vz, v1)))

'Center @ x
x = .MDeterm(.Transpose(Array(vt, vy, vz, v1))) / k / 2

'Center @ y
y = .MDeterm(.Transpose(Array(vt, vx, vz, v1))) / k / -2

'Center @ z
z = .MDeterm(.Transpose(Array(vt, vx, vy, v1))) / k / 2

'Radius
r = Sqr(.SumSq(x, y, z) - (.MDeterm(.Transpose(Array(vt, vx, vy, vz))) /
k))

'You may want to return the solution as an Array
Sphere = Array(x, y, z, r)

End With
End Sub
 
R

Rob van Gelder

As others have stated, you'll need 4 points for a sphere.

You'll end up lots of sphere solutions with just 3 points. I'd say infinite
# solutions, but i'm not a math guru.

What you *can* do is find the smallest sphere which will fit through a
triangle. Probably not what you're after though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top