本文介紹了從三個點找到圓心的算法是什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我在圓周上有三個點:
pt A = (A.x, A.y);
pt B = (B.x, B.y);
pt C = (C.x, C.y);
如何計算圓心?
在 Processing (Java) 中實現它.
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;
}
推薦答案
這可能是一個相當深入的計算.這里有一個簡單的分步說明:http://paulbourke.net/geometry/circlesphere/.一旦你有了圓的方程,你就可以簡單地把它變成一個包含 H 和 K 的形式.點 (h,k) 將是圓心.
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)
這篇關于從三個點找到圓心的算法是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!