从三个点中找出圆心的算法是什么? [英] What is the algorithm for finding the center of a circle from three points?
问题描述
我在圆周上有三个点:
pt A =(A.x,A.y);
pt B =(B.x,B.y);
pt C =(Cx,Cy);
我如何计算圆心?
我找到了答案并实现了一个工作解决方案:
pt circleCenter(pt A,pt B,pt C){
float yDelta_a = By - Ay;
float xDelta_a = B.x - A.x;
float yDelta_b = C.y - B.y;
float xDelta_b = C.x - B.x;
pt center = P(0,0);
float aSlope = yDelta_a / xDelta_a;
float bSlope = yDelta_b / xDelta_b;
center.x =(aSlope * bSlope *(Ay-Cy)+ bSlope *(Ax + Bx)
- aSlope *(B.x + Cx))/(2 *(bSlope-aSlope) );
center.y = -1 *(center.x - (A.x + B.x)/ 2)/ aSlope +(A.y + B.y)/ 2;
return center;
}
深度计算。这里有一个简单的步骤: http://paulbourke.net/geometry/circlesphere/。一旦你有圆的方程,你可以简单地把它放在一个涉及H和K的形式中。(h,k)点将成为中心。
(在链接上向下滚动以获得方程式)
I have three points on the circumference of a circle:
pt A = (A.x, A.y); pt B = (B.x, B.y); pt C = (C.x, C.y);
How do I calculate the center of the circle?
Implementing it in Processing (Java).
I found the answer and implemented a working solution:
pt circleCenter(pt A, pt B, pt C) {
float yDelta_a = B.y - A.y;
float xDelta_a = B.x - A.x;
float yDelta_b = C.y - B.y;
float xDelta_b = C.x - B.x;
pt center = P(0,0);
float aSlope = yDelta_a/xDelta_a;
float bSlope = yDelta_b/xDelta_b;
center.x = (aSlope*bSlope*(A.y - C.y) + bSlope*(A.x + B.x)
- aSlope*(B.x+C.x) )/(2* (bSlope-aSlope) );
center.y = -1*(center.x - (A.x+B.x)/2)/aSlope + (A.y+B.y)/2;
return center;
}
It can be a rather in depth calculation. There is a simple step-by-step here: http://paulbourke.net/geometry/circlesphere/. Once you have the equation of the circle, you can simply put it in a form involving H and K. The point (h,k) will be the center.
(scroll down a little ways at the link to get to the equations)
这篇关于从三个点中找出圆心的算法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!