Finding center and radius of sphere
14 次查看(过去 30 天)
显示 更早的评论
I'm looking to calculate the radius of a sphere knowing only 3 points on the circumference. I know its mathematically possible I just don't know how to write a program that will do this. I intend to use the equation of a sphere:
(sqrt((x-xc)^2)+((y-yc)^2)+((z-zc)^2))) = r
Where the center is (xc,yz,zc) and a point on the circumference is (x,y,z). I will select 3 points on the sphere to plug into this equation.
I need to calculate the center and the radius. Does anyone know how to write a program that will do this?
1 个评论
OCDER
2017-9-11
Were you referring to selecting 3 points on the circumference of a circular plane that intersects the center of a sphere? https://math.stackexchange.com/questions/1076177/3d-coordinates-of-circle-center-given-three-point-on-the-circle
If so, might want to put the last equation required to solve this.
回答(2 个)
Image Analyst
2017-9-12
See circlefit3d: https://www.mathworks.com/matlabcentral/fileexchange/34792-circlefit3d-fit-circle-to-three-points-in-3d-space
This will give you the center (xCenter, yCenter, zCenter) and the radius given 3 points on the circumference (widest part, not like on some small cap) of the sphere. So that's all you need to define a sphere.
0 个评论
Walter Roberson
2017-9-11
Three points are not sufficient for that. You have four unknowns, not three: xc, yc, zc, and r makes four.
2 个评论
Walter Roberson
2017-9-11
syms x x1 x2 x3 x4 y y1 y2 y3 y4 z z1 z2 z3 z4 xc yc zc real
syms r nonnegative
eqn = (sqrt((x-xc)^2)+((y-yc)^2)+((z-zc)^2)) == r^2;
eqn1 = subs(eqn, [x y z], [x1 y1 z1]);
eqn2 = subs(eqn, [x y z], [x2 y2 z2]);
eqn3 = subs(eqn, [x y z], [x3 y3 z3]);
eqn4 = subs(eqn, [x y z], [x4 y4 z4]);
sol = solve([eqn1, eqn2, eqn3, eqn4],[xc yc zc r])
This will find 28 solutions: four points are not enough to determine the which side of the given points the centre is; you need five points for that.
Image Analyst
2017-9-12
I'm not sure I buy that you need 4. Three points define a circle, and since the points are on the circumference (widest part of the sphere, not any old place, you got everything you need.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!